OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
DefaultStateIOPlugin.hpp
Go to the documentation of this file.
1
25#ifndef OPENSWMM_ENGINE_DEFAULT_STATE_IO_PLUGIN_HPP
26#define OPENSWMM_ENGINE_DEFAULT_STATE_IO_PLUGIN_HPP
27
28#include "../../../include/openswmm/plugin_sdk/IStateIOPlugin.hpp"
29
30#include <string>
31#include <vector>
32
33namespace openswmm {
34
41public:
43
44 PluginState state() const noexcept override { return state_; }
45
46 int initialize(const std::vector<std::string>& init_args,
47 const IPluginComponentInfo* info) override;
48
49 int validate(const SimulationContext& ctx) override;
50
51 bool can_read(const std::string& path) const override;
52
53 int read_state(const std::string& path, SimulationContext& ctx) override;
54
55 int write_state(const std::string& path, const SimulationContext& ctx) override;
56
57 std::vector<std::string> warnings() const override { return warnings_; }
58
59 int finalize(const SimulationContext& ctx) override;
60
61 const char* last_error_message() const noexcept override {
62 return last_error_.c_str();
63 }
64
65private:
67 std::string last_error_;
68 std::vector<std::string> warnings_;
69};
70
71} /* namespace openswmm */
72
73#endif /* OPENSWMM_ENGINE_DEFAULT_STATE_IO_PLUGIN_HPP */
Default state-IO plugin: OpenSWMM binary + legacy SWMM5 hot-start.
Definition DefaultStateIOPlugin.hpp:40
PluginState state() const noexcept override
Query the current plugin state.
Definition DefaultStateIOPlugin.hpp:44
int validate(const SimulationContext &ctx) override
Validate configuration against the loaded model.
Definition DefaultStateIOPlugin.cpp:61
int write_state(const std::string &path, const SimulationContext &ctx) override
Write the current simulation state to a file.
Definition DefaultStateIOPlugin.cpp:121
std::vector< std::string > warnings() const override
Non-fatal warnings accumulated during the last call.
Definition DefaultStateIOPlugin.hpp:57
bool can_read(const std::string &path) const override
Cheap format sniff used to dispatch a path to the right plugin.
Definition DefaultStateIOPlugin.cpp:75
int finalize(const SimulationContext &ctx) override
Finalize and release resources.
Definition DefaultStateIOPlugin.cpp:66
int initialize(const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
Initialize from [PLUGINS] arguments.
Definition DefaultStateIOPlugin.cpp:52
const char * last_error_message() const noexcept override
Get the last error message.
Definition DefaultStateIOPlugin.hpp:61
int read_state(const std::string &path, SimulationContext &ctx) override
Read state from a file and apply it to the simulation context.
Definition DefaultStateIOPlugin.cpp:94
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:179
Interface for state / hot-start IO plugins.
Definition IStateIOPlugin.hpp:53
PluginState
Plugin lifecycle states.
Definition PluginState.hpp:67
@ UNLOADED
Library not yet loaded (or was closed).
Definition NodeCoupling.cpp:15
Central, reentrant simulation context.
Definition SimulationContext.hpp:274