OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::twoD::RuntimeSources Struct Reference

#include <RuntimeCoupling.hpp>

Collaboration diagram for openswmm::twoD::RuntimeSources:

Public Member Functions

RuntimeSource * find (const std::string &id, int cell)
 Find a source prescription by its exact registry key.
 
const RuntimeSource * find (const std::string &id, int cell) const
 Find a source prescription by its exact registry key.
 
void rebuild (int count)
 Recreate enabled source-to-cell gather indices.
 
void replace (RuntimeSource value)
 Upsert a source prescription while preserving accumulated receipts.
 
void prune () noexcept
 Remove disabled row offsets from every cell gather list.
 
bool clear (const std::string &id, int cell=-1) noexcept
 Disable one source-cell key or every cell belonging to a source id.
 
void syncReceipts (const RuntimeSources &old)
 Copy matching accepted receipts into a staged source registry.
 
bool active () const
 Test whether any retained runtime prescription is enabled.
 
double nextTime (double now) const
 Find the next enabled prescription expiry strictly after now.
 
bool expire (double now)
 Disable all enabled prescriptions whose expiry has been reached.
 

Public Attributes

std::vector< RuntimeSource > rows
 
std::vector< std::vector< std::size_t > > cells
 
std::unordered_map< std::string, std::unordered_map< int, std::size_t > > index
 

Member Function Documentation

◆ active()

bool openswmm::twoD::RuntimeSources::active ( ) const
inline

Test whether any retained runtime prescription is enabled.

Returns
True if at least one row.enabled is true, otherwise false. Expiry time is not inspected; expire() must run first for time-based status.
Note
Read-only, allocation-free; serialize with registry mutations.
Here is the caller graph for this function:

◆ clear()

bool openswmm::twoD::RuntimeSources::clear ( const std::string & id,
int cell = -1 )
inlinenoexcept

Disable one source-cell key or every cell belonging to a source id.

Parameters
[in]idBorrowed exact source identifier.
[in]cellNonnegative cell key to clear, or any negative value for all cells under id.
Returns
False for an absent id/cell; true when a matching key exists, even if already disabled.
Postcondition
Removes disabled entries from gather lists, preserving rows/index/receipts for later reporting or replacement. Requires exclusive access; no allocation or exceptions.
Here is the call graph for this function:

◆ expire()

bool openswmm::twoD::RuntimeSources::expire ( double now)
inline

Disable all enabled prescriptions whose expiry has been reached.

Parameters
[in]nowFinite elapsed simulation time, seconds; until <= now expires.
Postcondition
Keeps row identity and cumulative receipts; prunes disabled cell gather indices.
Returns
True when at least one enabled source was disabled; false otherwise.
Note
Requires exclusive registry access. No allocation or exceptions.
Here is the call graph for this function:

◆ find() [1/2]

RuntimeSource * openswmm::twoD::RuntimeSources::find ( const std::string & id,
int cell )
inline

Find a source prescription by its exact registry key.

Parameters
[in]idBorrowed case-sensitive source identifier.
[in]cellZero-based source cell key; may identify a disabled retained row.
Returns
Borrowed pointer into rows, or NULL when the key is absent. Pointer may be invalidated by vector growth, replacement or registry destruction; never free it.
Precondition
index matches rows. No allocation or mutation; serialize access with registry edits.
Here is the caller graph for this function:

◆ find() [2/2]

const RuntimeSource * openswmm::twoD::RuntimeSources::find ( const std::string & id,
int cell ) const
inline

Find a source prescription by its exact registry key.

Parameters
[in]idBorrowed case-sensitive source identifier.
[in]cellZero-based source cell key; may identify a disabled retained row.
Returns
Borrowed pointer into rows, or NULL when the key is absent. Pointer may be invalidated by vector growth, replacement or registry destruction; never free it.
Precondition
index matches rows. No allocation or mutation; serialize access with registry edits.
Here is the call graph for this function:

◆ nextTime()

double openswmm::twoD::RuntimeSources::nextTime ( double now) const
inline

Find the next enabled prescription expiry strictly after now.

Parameters
[in]nowFinite elapsed simulation time, seconds.
Returns
Earliest enabled until > now in elapsed seconds, or positive infinity if none exists.
Note
Read-only; expired/equal-time rows are skipped without disabling them. No allocation; serialize with edits.

◆ prune()

void openswmm::twoD::RuntimeSources::prune ( )
inlinenoexcept

Remove disabled row offsets from every cell gather list.

Precondition
Cell offsets reference valid rows. Requires exclusive registry access.
Postcondition
rows, id/cell keys and all receipts remain intact; cell-list iterators may be invalidated. No allocation or exceptions.
Here is the caller graph for this function:

◆ rebuild()

void openswmm::twoD::RuntimeSources::rebuild ( int count)
inline

Recreate enabled source-to-cell gather indices.

Parameters
[in]countNonnegative mesh cell count, in cells.
Precondition
Every enabled row.cell lies in [0,count); rows/index are otherwise coherent.
Postcondition
Replaces cells with count vectors of enabled row offsets. Does not rebuild the id/cell index or clear receipts.
Exceptions
std::out_of_rangeFor an enabled cell outside count; partial cells may already be written.
Note
May allocate/throw and invalidates cell-list references. Requires exclusive registry access; no rollback.
Here is the caller graph for this function:

◆ replace()

void openswmm::twoD::RuntimeSources::replace ( RuntimeSource value)
inline

Upsert a source prescription while preserving accumulated receipts.

Parameters
[in]valueOwned draft with valid id/cell and transport tuple extent; moved into rows.
Postcondition
Existing keys retain their receipt; new keys receive zeroed species receipt arrays sized to concentrations. Caller must rebuild cell gathers after changing placement/enabling.
Note
No validation is performed. Vector/map allocations may throw after index/receipt changes, so this low-level method is not transactional; edit a private draft when rollback is needed. Existing row pointers may be invalidated.
Here is the call graph for this function:

◆ syncReceipts()

void openswmm::twoD::RuntimeSources::syncReceipts ( const RuntimeSources & old)
inline

Copy matching accepted receipts into a staged source registry.

Parameters
[in]oldBorrowed prior registry with coherent index/rows; distinct from this registry when edits are in flight.
Postcondition
Every matching (id,cell) receives the previous receipt, including species vectors; unmatched drafts remain unchanged.
Note
Allocations may throw after earlier rows were copied. No topology rebuild or input retention; caller publishes only a fully prepared private draft.
Here is the call graph for this function:

Member Data Documentation

◆ cells

std::vector<std::vector<std::size_t> > openswmm::twoD::RuntimeSources::cells

◆ index

std::unordered_map<std::string, std::unordered_map<int, std::size_t> > openswmm::twoD::RuntimeSources::index

◆ rows

std::vector<RuntimeSource> openswmm::twoD::RuntimeSources::rows

The documentation for this struct was generated from the following file: