OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::climate::ClimateFileReader Class Reference

Stateful forward-only daily climate-file reader with one month cache. One owner serializes open/lookup/close; no concurrent queries. Request months in chronological order in a compatible ordered file. No rewind/index is kept for past months. Parsers are permissive and do not qualify all missing-value flags/calendar dates; successful lookup can return entirely NaN fields. More...

#include <ClimateFile.hpp>

Collaboration diagram for openswmm::climate::ClimateFileReader:

Public Member Functions

 ClimateFileReader ()=default
 Construct a closed reader with no cached month and zero day offset. Initial temperature encoding is tenths Celsius and wind encoding WDMV. No file IO or format validation occurs until open().
 
 ~ClimateFileReader ()
 Close the owned stream, ignoring fclose status. Caller first ends all concurrent/borrowed use; no final diagnostic is emitted.
 
 ClimateFileReader (const ClimateFileReader &)=delete
 Disallow copying the uniquely owned file/cursor state. No callable copy operation is provided.
 
ClimateFileReader & operator= (const ClimateFileReader &)=delete
 Disallow copy assignment of owned stream/cached cursor state.
 
bool open (const std::string &path, double start_oa_date, int unit_system, int temp_units=-1)
 Close any previous stream, open a file and detect its first-line format.
 
void close ()
 Close the stream and invalidate cached month and saved read-ahead line. Ignores fclose status. Resets format to UNKNOWN; retains day offset, numeric buffer bytes and unit/header configuration for later open(). Safe when closed.
 
bool getRecord (double oa_date, DailyClimateRecord &rec)
 Fetch the day at a shifted serial date from the current/next month buffer.
 
void setDayOffset (double days)
 Store the date shift used by subsequent lookups.
 
ClimateFileFormat format () const
 Read the recognized first-line format without further IO.
 
bool isOpen () const
 Test ownership of a currently open stream.
 

Detailed Description

Stateful forward-only daily climate-file reader with one month cache. One owner serializes open/lookup/close; no concurrent queries. Request months in chronological order in a compatible ordered file. No rewind/index is kept for past months. Parsers are permissive and do not qualify all missing-value flags/calendar dates; successful lookup can return entirely NaN fields.

Constructor & Destructor Documentation

◆ ClimateFileReader() [1/2]

openswmm::climate::ClimateFileReader::ClimateFileReader ( )
default

Construct a closed reader with no cached month and zero day offset. Initial temperature encoding is tenths Celsius and wind encoding WDMV. No file IO or format validation occurs until open().

Here is the caller graph for this function:

◆ ~ClimateFileReader()

openswmm::climate::ClimateFileReader::~ClimateFileReader ( )

Close the owned stream, ignoring fclose status. Caller first ends all concurrent/borrowed use; no final diagnostic is emitted.

Here is the call graph for this function:

◆ ClimateFileReader() [2/2]

openswmm::climate::ClimateFileReader::ClimateFileReader ( const ClimateFileReader & )
delete

Disallow copying the uniquely owned file/cursor state. No callable copy operation is provided.

Here is the call graph for this function:

Member Function Documentation

◆ close()

void openswmm::climate::ClimateFileReader::close ( )

Close the stream and invalidate cached month and saved read-ahead line. Ignores fclose status. Resets format to UNKNOWN; retains day offset, numeric buffer bytes and unit/header configuration for later open(). Safe when closed.

Here is the caller graph for this function:

◆ format()

ClimateFileFormat openswmm::climate::ClimateFileReader::format ( ) const
inline

Read the recognized first-line format without further IO.

Returns
Detected enum while open, UNKNOWN after close or failed open. Recognition does not guarantee valid rows/coverage.

◆ getRecord()

bool openswmm::climate::ClimateFileReader::getRecord ( double oa_date,
DailyClimateRecord & rec )

Fetch the day at a shifted serial date from the current/next month buffer.

Parameters
oa_dateFinite supported SWMM/OLE date in days since 1899-12-30; day_offset is added before calendar decoding. Time-of-day does not select subdaily data.
[out]recAssigned four daily fields on true: temperatures Fahrenheit, evaporation inches/day (US) or mm/day (SI), wind mph. Missing values become NaN. Retained on false.
Returns
False for a required buffer operation while closed or day outside [1,31]; true does not imply any field exists, even at EOF or for missing month data. Cache fills consume the file forward without seeking. Chronological, compatible requests/input are required; requesting past/skipped months is not a random lookup and can associate permissively parsed rows with the requested month. Read errors and malformed rows are not reported separately.
Here is the caller graph for this function:

◆ isOpen()

bool openswmm::climate::ClimateFileReader::isOpen ( ) const
inline

Test ownership of a currently open stream.

Returns
True exactly when file_ is nonnull, including an exhausted/error stream; this does not establish coverage or validate the current buffer.

◆ open()

bool openswmm::climate::ClimateFileReader::open ( const std::string & path,
double start_oa_date,
int unit_system,
int temp_units = -1 )

Close any previous stream, open a file and detect its first-line format.

Parameters
pathUTF-8 filename opened through fopen_utf8 in text mode; no path resolution.
start_oa_dateUnused compatibility argument; this method does not skip to that date. setDayOffset() separately changes subsequent lookup dates.
unit_systemZero for US, one for SI. User-format temperatures use this selection; returned evaporation uses inches/day or mm/day respectively.
temp_unitsNonnegative override stored after format detection (0=C10, 1=C,2=F); -1 retains detection/previous encoding. Only GHCND uses this encoding.
Returns
True after recognizing a format, false for open/first-read/detection failure, leaving the reader closed. True does not prove data coverage or validity. Preserves day_offset and some previous unit/header state across close/reopen. Non-GHCND's first line is saved for parsing; GHCND consumes its header. Errors have no stored message. Long lines are read in bounded chunks rather than explicitly rejected.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

ClimateFileReader & openswmm::climate::ClimateFileReader::operator= ( const ClimateFileReader & )
delete

Disallow copy assignment of owned stream/cached cursor state.

Returns
No runtime result; this overload is deleted.
Here is the call graph for this function:

◆ setDayOffset()

void openswmm::climate::ClimateFileReader::setDayOffset ( double days)
inline

Store the date shift used by subsequent lookups.

Parameters
daysFinite offset in days, normally a whole number. Positive reads later file dates, negative earlier dates. No rounding/validation, rewind or cache reset occurs; changing it must preserve the forward-month request discipline.
Here is the caller graph for this function:

The documentation for this class was generated from the following files: