OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches

Stores the full user-flags data: schema definitions + per-object values. More...

#include <UserFlags.hpp>

Collaboration diagram for openswmm::UserFlags:

Public Types

using ValueMap = std::unordered_map<std::string, UserFlagValue, CiHash, CiEqual>
 

Public Member Functions

void define (UserFlagDef def)
 Insert or replace an exact-case flag schema.
 
bool undefine (const std::string &name)
 Remove a schema and matching assignment suffixes.
 
bool is_defined (const std::string &name) const
 Test exact-case schema membership.
 
const UserFlagDef & get_def (const std::string &name) const
 Borrow an exact-case schema definition.
 
const std::vector< UserFlagDef > & all_defs () const noexcept
 Borrow schema definitions in insertion order.
 
std::size_t def_count () const noexcept
 Count schema definitions.
 
void set (const std::string &object_type, const std::string &object_name, const std::string &flag_name, UserFlagValue value)
 Assign an owned variant value using a case-insensitive composite key.
 
bool unset (const std::string &object_type, const std::string &object_name, const std::string &flag_name)
 Remove a case-insensitive composite assignment.
 
bool has_value (const std::string &object_type, const std::string &object_name, const std::string &flag_name) const
 Test case-insensitive composite assignment membership.
 
const UserFlagValue & get_value (const std::string &object_type, const std::string &object_name, const std::string &flag_name) const
 Borrow a case-insensitive composite assignment value.
 
std::optional< UserFlagValue > try_get_value (const std::string &object_type, const std::string &object_name, const std::string &flag_name) const
 Copy a case-insensitive composite assignment when present.
 
const ValueMap & all_values () const noexcept
 Borrow the complete case-insensitive assignment map.
 
std::size_t value_count () const noexcept
 Count stored composite assignments.
 
void clear () noexcept
 Erase all schemas and assignments.
 

Static Public Member Functions

static std::string make_key (const std::string &object_type, const std::string &object_name, const std::string &flag_name)
 Join three unmodified components with colon delimiters.
 

Detailed Description

Stores the full user-flags data: schema definitions + per-object values.

Part of SimulationContext. Accessible at runtime via the C API and Python bindings.

Lookup key for per-object values is the composite string "OBJECTTYPE:OBJECTNAME:FLAGNAME" with original spelling and ASCII-insensitive value lookup. Schema definition lookup remains exact-case; callers normalize schema names when required.

Member Typedef Documentation

◆ ValueMap

using openswmm::UserFlags::ValueMap = std::unordered_map<std::string, UserFlagValue, CiHash, CiEqual>

Composite-key value map; case-insensitive so object-name lookups match the engine's legacy-parity name semantics, while the stored key keeps the first-seen spelling for faithful [USER_FLAG_VALUES] round-trips.

Member Function Documentation

◆ all_defs()

const std::vector< UserFlagDef > & openswmm::UserFlags::all_defs ( ) const
inlinenoexcept

Borrow schema definitions in insertion order.

Returns
Reference to the owned vector; do not retain element references across schema edits.
Here is the caller graph for this function:

◆ all_values()

const ValueMap & openswmm::UserFlags::all_values ( ) const
inlinenoexcept

Borrow the complete case-insensitive assignment map.

Returns
Owned map reference; edits can invalidate iterators, and replacing/erasing entries invalidates borrowed values.
Here is the caller graph for this function:

◆ clear()

void openswmm::UserFlags::clear ( )
inlinenoexcept

Erase all schemas and assignments.

Invalidates borrowed schema/value references and iterators; vector/map capacity is not explicitly released.

◆ def_count()

std::size_t openswmm::UserFlags::def_count ( ) const
inlinenoexcept

Count schema definitions.

Returns
Number of exact-case schema entries.
Here is the caller graph for this function:

◆ define()

void openswmm::UserFlags::define ( UserFlagDef def)
inline

Insert or replace an exact-case flag schema.

Replacing preserves schema insertion order and existing assignments, including values whose variant no longer matches the schema type. Adding can invalidate borrowed schema references.

Parameters
[in]defDefinition passed by value and moved into storage; name/type/description are not normalized or validated.
Here is the caller graph for this function:

◆ get_def()

const UserFlagDef & openswmm::UserFlags::get_def ( const std::string & name) const
inline

Borrow an exact-case schema definition.

Parameters
[in]nameExact-case schema key; this schema map does not normalize case.
Returns
Engine-owned definition reference, invalidated by schema vector mutation or container destruction.
Exceptions
std::out_of_rangeWhen the exact schema key is absent.
Here is the caller graph for this function:

◆ get_value()

const UserFlagValue & openswmm::UserFlags::get_value ( const std::string & object_type,
const std::string & object_name,
const std::string & flag_name ) const
inline

Borrow a case-insensitive composite assignment value.

Parameters
[in]object_typeBorrowed object-category token; copied into the composite key.
[in]object_nameBorrowed object ID; no model-object existence check is performed.
[in]flag_nameBorrowed flag token; no schema/type validation is performed by this value-map operation.
Returns
Reference to the owned variant, valid until that entry is replaced/erased or the container is destroyed.
Here is the call graph for this function:

◆ has_value()

bool openswmm::UserFlags::has_value ( const std::string & object_type,
const std::string & object_name,
const std::string & flag_name ) const
inline

Test case-insensitive composite assignment membership.

Parameters
[in]object_typeBorrowed object-category token; copied into the composite key.
[in]object_nameBorrowed object ID; no model-object existence check is performed.
[in]flag_nameBorrowed flag token; no schema/type validation is performed by this value-map operation.
Returns
True when the composite key is present.
Here is the call graph for this function:

◆ is_defined()

bool openswmm::UserFlags::is_defined ( const std::string & name) const
inline

Test exact-case schema membership.

Parameters
[in]nameExact-case schema key; this schema map does not normalize case.
Returns
True if that exact schema key exists.
Here is the caller graph for this function:

◆ make_key()

static std::string openswmm::UserFlags::make_key ( const std::string & object_type,
const std::string & object_name,
const std::string & flag_name )
inlinestatic

Join three unmodified components with colon delimiters.

Performs no escaping, normalization or validation. Callers needing an unambiguous composite identity must ensure components contain no colons.

Parameters
[in]object_typeBorrowed object-category token; copied into the composite key.
[in]object_nameBorrowed object ID; no model-object existence check is performed.
[in]flag_nameBorrowed flag token; no schema/type validation is performed by this value-map operation.
Returns
New owned string object_type + colon + object_name + colon + flag_name.
Here is the caller graph for this function:

◆ set()

void openswmm::UserFlags::set ( const std::string & object_type,
const std::string & object_name,
const std::string & flag_name,
UserFlagValue value )
inline

Assign an owned variant value using a case-insensitive composite key.

Overwrites an equivalent key while preserving its first stored spelling. Components are not uppercased; the map folds ASCII case. Caller serializes reads/edits; no engine lifecycle check occurs here.

Parameters
[in]object_typeBorrowed object-category token; copied into the composite key.
[in]object_nameBorrowed object ID; no model-object existence check is performed.
[in]flag_nameBorrowed flag token; no schema/type validation is performed by this value-map operation.
[in]valueVariant passed by value and moved into the map; no conversion to a declared schema type.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_get_value()

std::optional< UserFlagValue > openswmm::UserFlags::try_get_value ( const std::string & object_type,
const std::string & object_name,
const std::string & flag_name ) const
inline

Copy a case-insensitive composite assignment when present.

Parameters
[in]object_typeBorrowed object-category token; copied into the composite key.
[in]object_nameBorrowed object ID; no model-object existence check is performed.
[in]flag_nameBorrowed flag token; no schema/type validation is performed by this value-map operation.
Returns
Independent value copy, or std::nullopt for an absent key. String values may allocate while copying.
Here is the call graph for this function:

◆ undefine()

bool openswmm::UserFlags::undefine ( const std::string & name)
inline

Remove a schema and matching assignment suffixes.

Renumbers following schema slots, then removes values whose suffix after the second colon equals name case-sensitively. Mixed-case assignment spellings can therefore survive; components containing colons are ambiguous to this suffix scan.

Parameters
[in]nameExact-case schema key; this schema map does not normalize case.
Returns
True when the exact schema key existed; false leaves all assignments unchanged.

◆ unset()

bool openswmm::UserFlags::unset ( const std::string & object_type,
const std::string & object_name,
const std::string & flag_name )
inline

Remove a case-insensitive composite assignment.

Parameters
[in]object_typeBorrowed object-category token; copied into the composite key.
[in]object_nameBorrowed object ID; no model-object existence check is performed.
[in]flag_nameBorrowed flag token; no schema/type validation is performed by this value-map operation.
Returns
True when an equivalent key was erased.
Here is the call graph for this function:

◆ value_count()

std::size_t openswmm::UserFlags::value_count ( ) const
inlinenoexcept

Count stored composite assignments.

Returns
Number of case-insensitively distinct composite keys.
Here is the caller graph for this function:

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