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

RDII interface file manager (USE = read/override, SAVE = export). More...

#include <RdiiInterface.hpp>

Collaboration diagram for openswmm::rdii_iface::RdiiInterfaceFile:

Public Member Functions

 ~RdiiInterfaceFile ()
 Close the owned stream, ignoring flush/close failure. Caller first ends active access; does not publish any additional record.
 
int openForRead (SimulationContext &ctx, const std::string &path)
 Replace the owned stream with a binary or text RDII input and prime a record.
 
int openForWrite (const std::string &path, int rdii_step, const std::vector< int > &node_idx)
 Close prior IO, truncate a binary RDII destination and write its header.
 
void applyFlows (SimulationContext &ctx, double current_date)
 Add the bracketing record's RDII flow into the context node accumulators.
 
void saveFlows (double current_date, const std::vector< double > &node_flows)
 Append a native double date and float cfs values for selected node indices.
 
void close ()
 Close owned IO and clear writing/have-record flags. Ignores fclose status; retains step, format, node mapping, flow buffers and dates. Safe when already closed. Does not reset or clear any context inflow accumulator.
 
bool isOpen () const
 Test stream ownership without checking EOF or error state.
 
bool isWriting () const
 Read the current mode flag without checking stream/error state.
 
int step () const
 Read the last stored record-validity duration.
 

Detailed Description

RDII interface file manager (USE = read/override, SAVE = export).

Owns a native FILE cursor; serialize all operations and do not copy this object while owning a stream. Binary IO uses native integer/float layout and model node order, with no endian conversion or identity fingerprint.

Constructor & Destructor Documentation

◆ ~RdiiInterfaceFile()

openswmm::rdii_iface::RdiiInterfaceFile::~RdiiInterfaceFile ( )
inline

Close the owned stream, ignoring flush/close failure. Caller first ends active access; does not publish any additional record.

Here is the call graph for this function:

Member Function Documentation

◆ applyFlows()

void openswmm::rdii_iface::RdiiInterfaceFile::applyFlows ( SimulationContext & ctx,
double current_date )

Add the bracketing record's RDII flow into the context node accumulators.

Parameters
[in,out]ctxCompatible initialized node arrays in the model used at open; adds cfs to rdii_inflow without clearing it. Duplicate indices add repeatedly.
current_dateFinite supported absolute SWMM/OLE day; query monotonically forward because the file cursor cannot rewind. Applies on [record_start,record_end). No-op if closed/writing, before the next start or beyond complete records. Advances through expired records, ignores individual indices invalid in ctx, and skips absolute flow below FLOW_TOL. Negative flows and nonfinite data are not rejected; caller owns per-step accumulator reset and complete file-data qualification.
Here is the call graph for this function:

◆ close()

void openswmm::rdii_iface::RdiiInterfaceFile::close ( )

Close owned IO and clear writing/have-record flags. Ignores fclose status; retains step, format, node mapping, flow buffers and dates. Safe when already closed. Does not reset or clear any context inflow accumulator.

Here is the caller graph for this function:

◆ isOpen()

bool openswmm::rdii_iface::RdiiInterfaceFile::isOpen ( ) const
inline

Test stream ownership without checking EOF or error state.

Returns
True exactly when fp_ is nonnull; not proof of a usable record.

◆ isWriting()

bool openswmm::rdii_iface::RdiiInterfaceFile::isWriting ( ) const
inline

Read the current mode flag without checking stream/error state.

Returns
Stored writing flag; close resets it to false.

◆ openForRead()

int openswmm::rdii_iface::RdiiInterfaceFile::openForRead ( SimulationContext & ctx,
const std::string & path )

Replace the owned stream with a binary or text RDII input and prime a record.

Parameters
ctxBorrowed compatible model for binary index bounds/text node-name lookup; name/count arrays must agree. Hydraulic state is not modified.
pathUTF-8 filename, opened through fopen_utf8; no relative-path resolution.
Returns
Zero after a valid header, -1 for open/reopen failure, -2 for invalid header or unresolved node. Zero can still mean no complete first record (priming result is ignored). Closes a previous stream first. Bad header closes the new stream; partial header metadata can remain. Binary data uses native layout. Exceptions can leave a partially initialized open owner; caller/destructor must close it.
Here is the call graph for this function:

◆ openForWrite()

int openswmm::rdii_iface::RdiiInterfaceFile::openForWrite ( const std::string & path,
int rdii_step,
const std::vector< int > & node_idx )

Close prior IO, truncate a binary RDII destination and write its header.

Parameters
pathUTF-8 destination; no staging or atomic replacement is performed.
rdii_stepRecord validity seconds; nonpositive input defaults to 300.
node_idxCopied project node indices in output order, nonempty and count representable as int32. Indices are not validated/deduplicated here.
Returns
Zero after attempting header writes, -1 for failed open, -2 for empty list. Write results are unchecked, so zero does not guarantee persisted bytes. Caller keeps native-layout/model ordering compatible and serializes all writes/close.
Here is the call graph for this function:

◆ saveFlows()

void openswmm::rdii_iface::RdiiInterfaceFile::saveFlows ( double current_date,
const std::vector< double > & node_flows )

Append a native double date and float cfs values for selected node indices.

Parameters
current_dateFinite supported absolute SWMM/OLE start day, normally ordered and separated by step(); no interval/date validation occurs here.
node_flowsBorrowed project-indexed cfs vector. Missing/out-of-range indices (including stored negative indices converted to size_t) write zero; values narrow to float without finite/range checks. No-op unless open for writing. fwrite failures are ignored, no explicit flush or success status is supplied, and the caller serializes against close().

◆ step()

int openswmm::rdii_iface::RdiiInterfaceFile::step ( ) const
inline

Read the last stored record-validity duration.

Returns
Seconds from the successful/partial header or write setup; zero initially. close() retains this value, so it does not prove an active/valid reader.
Here is the caller graph for this function:

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