![]() |
OpenSWMM Engine
6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
|
Interface for state / hot-start IO plugins. More...
#include <IStateIOPlugin.hpp>
Public Member Functions | |
| virtual | ~IStateIOPlugin ()=default |
| virtual PluginState | state () const noexcept=0 |
| Query the current plugin state. | |
| virtual int | initialize (const std::vector< std::string > &init_args, const IPluginComponentInfo *info)=0 |
| Initialize from [PLUGINS] arguments. | |
| virtual int | validate (const SimulationContext &ctx)=0 |
| Validate configuration against the loaded model. | |
| virtual bool | can_read (const std::string &path) const |
| Cheap format sniff used to dispatch a path to the right plugin. | |
| virtual int | read_state (const std::string &path, SimulationContext &ctx)=0 |
| Read state from a file and apply it to the simulation context. | |
| virtual int | write_state (const std::string &path, const SimulationContext &ctx)=0 |
| Write the current simulation state to a file. | |
| virtual std::vector< std::string > | warnings () const |
| Non-fatal warnings accumulated during the last call. | |
| virtual int | finalize (const SimulationContext &ctx)=0 |
| Finalize and release resources. | |
| virtual const char * | last_error_message () const noexcept |
| Get the last error message. | |
Interface for state / hot-start IO plugins.
|
virtualdefault |
|
inlinevirtual |
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 in openswmm::DefaultStateIOPlugin.
|
pure virtual |
Finalize and release resources.
| ctx | Simulation context. |
Implemented in openswmm::DefaultStateIOPlugin.
|
pure virtual |
Initialize from [PLUGINS] arguments.
| init_args | Tokenized arguments from the [PLUGINS] line. |
| info | Back-pointer to IPluginComponentInfo. |
Implemented in openswmm::DefaultStateIOPlugin.
|
inlinevirtualnoexcept |
Get the last error message.
Reimplemented in openswmm::DefaultStateIOPlugin.
|
pure virtual |
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. |
Implemented in openswmm::DefaultStateIOPlugin.
|
pure virtualnoexcept |
Query the current plugin state.
Implemented in openswmm::DefaultStateIOPlugin.
|
pure virtual |
Validate configuration against the loaded model.
| ctx | Simulation context (after input parsing). |
Implemented in openswmm::DefaultStateIOPlugin.
|
inlinevirtual |
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 in openswmm::DefaultStateIOPlugin.
|
pure virtual |
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. |
Implemented in openswmm::DefaultStateIOPlugin.