![]() |
OpenSWMM Engine
6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
|
Default state-IO plugin: OpenSWMM binary + legacy SWMM5 hot-start. More...
#include <DefaultStateIOPlugin.hpp>
Public Member Functions | |
| DefaultStateIOPlugin ()=default | |
| 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. | |
| bool | can_read (const std::string &path) const override |
| Cheap format sniff used to dispatch a path to the right plugin. | |
| int | read_state (const std::string &path, SimulationContext &ctx) override |
| Read state from a file and apply it to the simulation context. | |
| int | write_state (const std::string &path, const SimulationContext &ctx) override |
| Write the current simulation state to a file. | |
| std::vector< std::string > | warnings () const override |
| Non-fatal warnings accumulated during the last call. | |
| int | finalize (const SimulationContext &ctx) override |
| Finalize and release resources. | |
| const char * | last_error_message () const noexcept override |
| Get the last error message. | |
Public Member Functions inherited from openswmm::IStateIOPlugin | |
| virtual | ~IStateIOPlugin ()=default |
Default state-IO plugin: OpenSWMM binary + legacy SWMM5 hot-start.
|
default |
|
overridevirtual |
Cheap format sniff used to dispatch a path to the right plugin.
Implementations should peek at file extension and/or a small fixed-size header (magic number) and return true if this plugin can read the file. Must NOT perform a full parse — the engine calls this on every registered state plugin in registration order to pick the first match.
| path | Path to a candidate state file. |
Reimplemented from openswmm::IStateIOPlugin.
|
overridevirtual |
Finalize and release resources.
| ctx | Simulation context. |
Implements openswmm::IStateIOPlugin.
|
overridevirtual |
Initialize from [PLUGINS] arguments.
| init_args | Tokenized arguments from the [PLUGINS] line. |
| info | Back-pointer to IPluginComponentInfo. |
Implements openswmm::IStateIOPlugin.
|
inlineoverridevirtualnoexcept |
Get the last error message.
Reimplemented from openswmm::IStateIOPlugin.
|
overridevirtual |
Read state from a file and apply it to the simulation context.
Called BEFORE simulation start (engine in INITIALIZED state). Restores node depths/heads/volumes, link flows/depths/volumes, subcatchment runoff, and any solver-internal state (infiltration, groundwater, snowpack) exposed via SimulationContext accessors.
Missing objects (present in the file but not in the model, or vice versa) are reported via warnings() and do NOT cause a non-zero return — the caller decides how strict to be.
| path | Path to the state file. |
| ctx | Simulation context to populate. |
Implements openswmm::IStateIOPlugin.
|
inlineoverridevirtualnoexcept |
Query the current plugin state.
Implements openswmm::IStateIOPlugin.
|
overridevirtual |
Validate configuration against the loaded model.
| ctx | Simulation context (after input parsing). |
Implements openswmm::IStateIOPlugin.
|
inlineoverridevirtual |
Non-fatal warnings accumulated during the last call.
Typical contents: "node 'J3' present in hot-start file but not in model — skipped". Cleared at the start of each read_state()/write_state() call.
Reimplemented from openswmm::IStateIOPlugin.
|
overridevirtual |
Write the current simulation state to a file.
Safe to call repeatedly during a run for scheduled checkpoints and once at the end for the final snapshot. Implementations should NOT hold the file open between calls — each call opens, writes, fsyncs, and closes.
| path | Destination path. |
| ctx | Simulation context to serialize. |
Implements openswmm::IStateIOPlugin.