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

Default input plugin that reads/writes SWMM .inp files. More...

#include <DefaultInputPlugin.hpp>

Inheritance diagram for openswmm::DefaultInputPlugin:
Collaboration diagram for openswmm::DefaultInputPlugin:

Public Member Functions

 DefaultInputPlugin ()
 Construct and register all built-in section handlers.
 
PluginState state () const noexcept override
 Query the current plugin state.
 
int initialize (const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
 Initialize from [PLUGINS] arguments.
 
int validate (const SimulationContext &ctx) override
 Validate configuration against the loaded model.
 
int read (const std::string &path, SimulationContext &ctx) override
 Read model data from a file into the simulation context.
 
int write (const std::string &path, const SimulationContext &ctx) override
 Write model data from the simulation context to a file.
 
int finalize (const SimulationContext &ctx) override
 Finalize and release resources.
 
const char * last_error_message () const noexcept override
 Get the last error message.
 
std::vector< std::string > skipped_sections () const override
 Sections or elements that were skipped during the last read().
 
input::SectionRegistryregistry () noexcept
 Access the section registry (for custom section registration).
 
- Public Member Functions inherited from openswmm::IInputPlugin
virtual ~IInputPlugin ()=default
 

Detailed Description

Default input plugin that reads/writes SWMM .inp files.

Owns a SectionRegistry populated with all built-in SWMM section handlers. The registry maps section tags (JUNCTIONS, CONDUITS, etc.) to handler functions that populate the SimulationContext.

Constructor & Destructor Documentation

◆ DefaultInputPlugin()

openswmm::DefaultInputPlugin::DefaultInputPlugin ( )

Construct and register all built-in section handlers.

Member Function Documentation

◆ finalize()

int openswmm::DefaultInputPlugin::finalize ( const SimulationContext ctx)
overridevirtual

Finalize and release resources.

Parameters
ctxSimulation context.
Returns
0 on success.
Postcondition
state() == PluginState::FINALIZED on success.

Implements openswmm::IInputPlugin.

◆ initialize()

int openswmm::DefaultInputPlugin::initialize ( const std::vector< std::string > &  init_args,
const IPluginComponentInfo info 
)
overridevirtual

Initialize from [PLUGINS] arguments.

Parameters
init_argsTokenized arguments from the [PLUGINS] line.
infoBack-pointer to IPluginComponentInfo.
Returns
0 on success.
Postcondition
state() == PluginState::INITIALIZED on success.

Implements openswmm::IInputPlugin.

◆ last_error_message()

const char * openswmm::DefaultInputPlugin::last_error_message ( ) const
inlineoverridevirtualnoexcept

Get the last error message.

Reimplemented from openswmm::IInputPlugin.

◆ read()

int openswmm::DefaultInputPlugin::read ( const std::string &  path,
SimulationContext ctx 
)
overridevirtual

Read model data from a file into the simulation context.

Populates all SoA arrays, name indices, options, and tables in the SimulationContext. The caller (SWMMEngine::open()) is responsible for calling cross-reference resolution after this method returns.

Implementations should also populate ctx.plugin_specs if the input format supports plugin declarations, so the engine can load output/report plugins after reading.

Input plugins are injected into the engine before open() is called — they cannot be discovered via [PLUGINS] because the input file has not been read yet at that point.

Parameters
pathPath to the input file.
ctxSimulation context to populate.
Returns
0 on success, non-zero error code on failure.

Implements openswmm::IInputPlugin.

Here is the call graph for this function:

◆ registry()

input::SectionRegistry & openswmm::DefaultInputPlugin::registry ( )
inlinenoexcept

Access the section registry (for custom section registration).

◆ skipped_sections()

std::vector< std::string > openswmm::DefaultInputPlugin::skipped_sections ( ) const
inlineoverridevirtual

Sections or elements that were skipped during the last read().

Returns identifiers for any input sections or elements that had no handler and were ignored. For .inp files these are section tags like "MY_UNKNOWN_SECTION". Other formats may return their own identifiers (e.g., JSON keys).

Returns
Vector of skipped section/element identifiers (empty by default).

Reimplemented from openswmm::IInputPlugin.

◆ state()

PluginState openswmm::DefaultInputPlugin::state ( ) const
inlineoverridevirtualnoexcept

Query the current plugin state.

Implements openswmm::IInputPlugin.

◆ validate()

int openswmm::DefaultInputPlugin::validate ( const SimulationContext ctx)
overridevirtual

Validate configuration against the loaded model.

Parameters
ctxSimulation context (after input parsing).
Returns
0 on success.
Postcondition
state() == PluginState::VALIDATED on success.

Implements openswmm::IInputPlugin.

◆ write()

int openswmm::DefaultInputPlugin::write ( const std::string &  path,
const SimulationContext ctx 
)
overridevirtual

Write model data from the simulation context to a file.

Serializes the full model state to the specified file path in the format supported by this plugin.

Parameters
pathPath to the output file.
ctxSimulation context to serialize.
Returns
0 on success, non-zero error code on failure.

Implements openswmm::IInputPlugin.

Here is the call graph for this function:

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