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

SoA collection of all time series and curves in the model. More...

#include <TableData.hpp>

Collaboration diagram for openswmm::TableData:

Public Member Functions

std::size_t count () const noexcept
 Count stored time-series and curve tables.
 
Table & operator[] (int idx)
 Borrow a mutable stored table.
 
const Table & operator[] (int idx) const
 Borrow an immutable stored table.
 
int add (const std::string &id, TableType type)
 Append an empty table and index its copied name.
 
void rebuild_index ()
 Rebuilds by_name from tables.
 
int find_by_kind (std::string_view name, bool want_timeseries) const noexcept
 Find the first indexed table matching a case-insensitive name and kind.
 
void reset_cursors () noexcept
 Reset all cursors (call before re-running a simulation).
 

Public Attributes

std::vector< Table > tables
 All tables in index order.
 
std::unordered_map< std::string, std::vector< int >, CiHash, CiEqual > by_name
 Case-insensitive name → table indices, ascending.
 

Detailed Description

SoA collection of all time series and curves in the model.

Indexed by table index (integer). Lookup by name is done via the SimulationContext name-to-index hash map.

Member Function Documentation

◆ add()

int openswmm::TableData::add ( const std::string & id,
TableType type )
inline

Append an empty table and index its copied name.

Name index uses ASCII-insensitive equality and appends index in increasing order. tables push precedes map insertion; allocation failure may leave the lookup index incomplete. Existing table references may be invalidated.

Parameters
[in]idBorrowed table ID copied verbatim; duplicate and case-equivalent names are allowed.
[in]typeTable type stored without enum validation.
Returns
New table index.
Here is the caller graph for this function:

◆ count()

std::size_t openswmm::TableData::count ( ) const
inlinenoexcept

Count stored time-series and curve tables.

Returns
Owned table vector size, independent of name-index synchronization.
Here is the caller graph for this function:

◆ find_by_kind()

int openswmm::TableData::find_by_kind ( std::string_view name,
bool want_timeseries ) const
inlinenoexcept

Find the first indexed table matching a case-insensitive name and kind.

Normally lowest matching index because add/rebuild_index keep ordered lists. Caller must maintain a coherent map and valid stored indices after direct edits.

Parameters
[in]nameBorrowed name, matched through the ASCII-insensitive name map.
[in]want_timeseriesTrue accepts TIMESERIES only; false accepts every non-TIMESERIES type.
Returns
First matching indexed row, or -1.
Here is the caller graph for this function:

◆ operator[]() [1/2]

Table & openswmm::TableData::operator[] ( int idx)
inline

Borrow a mutable stored table.

Caller rebuilds the name index after changing table IDs or structure; mutable access is not lifecycle/thread guarded.

Parameters
[in]idxExisting index in [0,count()); unchecked, including negatives.
Returns
Owned table reference; vector growth/erasure or container destruction can invalidate it.

◆ operator[]() [2/2]

const Table & openswmm::TableData::operator[] ( int idx) const
inline

Borrow an immutable stored table.

Parameters
[in]idxExisting table index; unchecked.
Returns
Owned reference, invalidated by vector relocation/erasure or destruction.

◆ rebuild_index()

void openswmm::TableData::rebuild_index ( )
inline

Rebuilds by_name from tables.

Required after any structural change that is not an append — in practice only ObjectDeleter's erase-and-renumber, which is already O(n). Anything that mutates tables directly without calling this leaves lookups stale.

Here is the caller graph for this function:

◆ reset_cursors()

void openswmm::TableData::reset_cursors ( )
inlinenoexcept

Reset all cursors (call before re-running a simulation).

Member Data Documentation

◆ by_name

std::unordered_map<std::string, std::vector<int>, CiHash, CiEqual> openswmm::TableData::by_name

Case-insensitive name → table indices, ascending.

Replaces the linear ieq scan that find_timeseries() / find_curve() used to run over every table. That scan was the load path's worst complexity defect: [TIMESERIES] and [CURVES] rows repeat their object's name on every row in standard SWMM files, so parsing a model with many long series cost O(total_rows x n_tables) string compares before anything else happened.

A name maps to a list because legacy keeps TSERIES and CURVE in separate hash tables, so one name may legitimately denote both a timeseries and a curve. Lists are in ascending index order (add() only appends), which is what makes a hash hit return the same winner the old first-match scan did — the duplicate-name parity the name-case tests pin.

◆ tables

std::vector<Table> openswmm::TableData::tables

All tables in index order.


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