OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
DefaultStateIOPlugin.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
40
41#ifndef OPENSWMM_ENGINE_DEFAULT_STATE_IO_PLUGIN_HPP
42#define OPENSWMM_ENGINE_DEFAULT_STATE_IO_PLUGIN_HPP
43
45
46#include <string>
47#include <vector>
48
49namespace openswmm {
50
57public:
59
60 PluginState state() const noexcept override { return state_; }
61
62 int initialize(const std::vector<std::string>& init_args,
63 const IPluginComponentInfo* info) override;
64
65 int validate(const SimulationContext& ctx) override;
66
67 bool can_read(const std::string& path) const override;
68
69 int read_state(const std::string& path, SimulationContext& ctx) override;
70
71 int write_state(const std::string& path, const SimulationContext& ctx) override;
72
73 std::vector<std::string> warnings() const override { return warnings_; }
74
75 int finalize(const SimulationContext& ctx) override;
76
77 const char* last_error_message() const noexcept override {
78 return last_error_.c_str();
79 }
80
81private:
83 std::string last_error_;
84 std::vector<std::string> warnings_;
85};
86
87} /* namespace openswmm */
88
89#endif /* OPENSWMM_ENGINE_DEFAULT_STATE_IO_PLUGIN_HPP */
Interface for state / hot-start IO plugins.
PluginState state() const noexcept override
Query the current plugin state.
Definition DefaultStateIOPlugin.hpp:60
int validate(const SimulationContext &ctx) override
Validate configuration against the loaded model.
Definition DefaultStateIOPlugin.cpp:77
int write_state(const std::string &path, const SimulationContext &ctx) override
Write the current simulation state to a file.
Definition DefaultStateIOPlugin.cpp:137
std::vector< std::string > warnings() const override
Non-fatal warnings accumulated during the last call.
Definition DefaultStateIOPlugin.hpp:73
bool can_read(const std::string &path) const override
Cheap format sniff used to dispatch a path to the right plugin.
Definition DefaultStateIOPlugin.cpp:91
int finalize(const SimulationContext &ctx) override
Finalize and release resources.
Definition DefaultStateIOPlugin.cpp:82
int initialize(const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
Initialize from [PLUGINS] arguments.
Definition DefaultStateIOPlugin.cpp:68
const char * last_error_message() const noexcept override
Get the last error message.
Definition DefaultStateIOPlugin.hpp:77
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:110
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:195
Interface for state / hot-start IO plugins.
Definition IStateIOPlugin.hpp:69
PluginState
Plugin lifecycle states.
Definition PluginState.hpp:83
@ UNLOADED
Library not yet loaded (or was closed).
Definition PluginState.hpp:84
Definition NodeCoupling.cpp:16
Central, reentrant simulation context.
Definition SimulationContext.hpp:353