OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
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
 
 ~SectionRegistry ()=default
 
void register_builtin (std::string_view tag, SectionHandler handler)
 Register a built-in section handler.
 
void register_custom (std::string_view tag, SectionHandler handler)
 Register a custom (user-defined) section handler. (R09)
 
bool has (std::string_view tag) const
 Check if a section tag has a registered handler.
 
bool is_custom (std::string_view tag) const
 Check if a section tag is a custom (non-builtin) handler.
 
void dispatch (std::string_view tag, SimulationContext &ctx, const std::vector< std::string > &lines) const
 Dispatch a section to its handler.
 
std::vector< std::string > registered_tags () const
 List all registered section tags (built-in + custom).
 

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

◆ ~SectionRegistry()

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

Member Function Documentation

◆ dispatch()

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

Dispatch a section to its handler.

If no handler is registered for tag, the section is silently skipped (and the caller may issue a warning).

Parameters
tagSection tag (without brackets, any case).
ctxSimulation context.
linesLines in the section.

◆ has()

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

Check if a section tag has a registered handler.

Parameters
tagSection tag (without brackets, any case).
Returns
true if a handler is registered.

◆ is_custom()

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

Check if a section tag is a custom (non-builtin) handler.

Parameters
tagSection tag (without brackets).
Returns
true if registered via register_custom().

◆ register_builtin()

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

Register a built-in section handler.

Parameters
tagSection tag without brackets (e.g., "JUNCTIONS"). Case is normalized to uppercase before storage.
handlerHandler function.

◆ register_custom()

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

Register a custom (user-defined) section handler. (R09)

Custom handlers override built-in handlers with the same tag. Use this to:

  • Add entirely new section types to the input file.
  • Override built-in parsing with custom logic.
Parameters
tagSection tag without brackets (e.g., "MY_SECTION").
handlerCustom handler function.

Example:

registry.register_custom("MY_CUSTOM", [](SimulationContext& ctx,
const std::vector<std::string>& lines) {
for (const auto& line : lines) {
// parse custom section content
}
});
Central, reentrant simulation context.
Definition SimulationContext.hpp:141

◆ registered_tags()

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

List all registered section tags (built-in + custom).


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