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

Registry that maps section tags (e.g., "[JUNCTIONS]") to handlers. More...

#include <SectionRegistry.hpp>

Collaboration diagram for openswmm::input::SectionRegistry:

Public Member Functions

 SectionRegistry ()=default
 Create empty built-in/custom handler maps.
 
 ~SectionRegistry ()=default
 Destroy owned handler function objects and any captures they own.
 
void register_builtin (std::string_view tag, SectionHandler handler)
 Store or replace one built-in section callback.
 
void register_custom (std::string_view tag, SectionHandler handler)
 Store or replace a callback that takes precedence over a built-in.
 
bool has (std::string_view tag) const
 Test whether either normalized handler map contains a tag.
 
bool is_custom (std::string_view tag) const
 Test whether the normalized custom map contains a tag.
 
void dispatch (std::string_view tag, SimulationContext &ctx, const std::vector< std::string > &lines) const
 Invoke a custom callback first, otherwise a built-in, otherwise no-op.
 
std::vector< std::string > registered_tags () const
 Copy the union of normalized built-in/custom tags.
 

Detailed Description

Registry that maps section tags (e.g., "[JUNCTIONS]") to handlers.

Two types of sections:

  • Built-in sections: Registered by InputReader at startup for all standard SWMM 5.x sections.
  • Custom sections: Registered by user code via register_custom() for new or extension sections. Custom sections can override built-ins.

Constructor & Destructor Documentation

◆ SectionRegistry()

openswmm::input::SectionRegistry::SectionRegistry ( )
default

Create empty built-in/custom handler maps.

◆ ~SectionRegistry()

openswmm::input::SectionRegistry::~SectionRegistry ( )
default

Destroy owned handler function objects and any captures they own.

Member Function Documentation

◆ dispatch()

void openswmm::input::SectionRegistry::dispatch ( std::string_view tag,
SimulationContext & ctx,
const std::vector< std::string > & lines ) const

Invoke a custom callback first, otherwise a built-in, otherwise no-op.

Does not catch callback/allocation exceptions or synthesize unknown-section warnings. Callbacks must not retain line references beyond their valid lifetime. Caller serializes registry mutation and dispatch.

Parameters
[in]tagBorrowed tag without brackets; copied and normalized using Tokenizer::to_upper(). No bracket stripping or whitespace trimming occurs.
[in,out]ctxCaller-owned context forwarded by reference; callback controls mutations and error recording.
[in]linesBorrowed section lines passed synchronously; may include retained comment rows according to InputReader policy.
Here is the caller graph for this function:

◆ has()

bool openswmm::input::SectionRegistry::has ( std::string_view tag) const

Test whether either normalized handler map contains a tag.

Parameters
[in]tagBorrowed tag without brackets; copied and normalized using Tokenizer::to_upper(). No bracket stripping or whitespace trimming occurs.
Returns
True when custom or built-in map contains the key, even if its std::function is empty.
Here is the caller graph for this function:

◆ is_custom()

bool openswmm::input::SectionRegistry::is_custom ( std::string_view tag) const

Test whether the normalized custom map contains a tag.

Parameters
[in]tagBorrowed tag without brackets; copied and normalized using Tokenizer::to_upper(). No bracket stripping or whitespace trimming occurs.
Returns
True when a custom entry exists; does not compare it with built-in registration.

◆ register_builtin()

void openswmm::input::SectionRegistry::register_builtin ( std::string_view tag,
SectionHandler handler )

Store or replace one built-in section callback.

Does not remove an overriding custom callback. Empty function objects are accepted and throw std::bad_function_call when invoked. Caller serializes registration and dispatch.

Parameters
[in]tagBorrowed tag without brackets; copied and normalized using Tokenizer::to_upper(). No bracket stripping or whitespace trimming occurs.
[in]handlerFunction object passed by value and moved into the registry; captured references must outlive dispatches.

◆ register_custom()

void openswmm::input::SectionRegistry::register_custom ( std::string_view tag,
SectionHandler handler )

Store or replace a callback that takes precedence over a built-in.

Empty function objects are accepted; dispatch then throws std::bad_function_call. No internal synchronization.

Parameters
[in]tagBorrowed tag without brackets; copied and normalized using Tokenizer::to_upper(). No bracket stripping or whitespace trimming occurs.
[in]handlerFunction object passed by value and moved into owned storage; captured references remain caller-managed.
Here is the caller graph for this function:

◆ registered_tags()

std::vector< std::string > openswmm::input::SectionRegistry::registered_tags ( ) const

Copy the union of normalized built-in/custom tags.

Returns
Owned unsorted tag vector without duplicates; hash-map iteration order is unspecified.

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