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:
60
64 PluginState state() const noexcept override { return state_; }
65
70 int initialize(const std::vector<std::string>& init_args,
71 const IPluginComponentInfo* info) override;
72
76 int validate(const SimulationContext& ctx) override;
77
84 bool can_read(const std::string& path) const override;
85
94 int read_state(const std::string& path, SimulationContext& ctx) override;
95
104 int write_state(const std::string& path, const SimulationContext& ctx) override;
105
108 std::vector<std::string> warnings() const override { return warnings_; }
109
113 int finalize(const SimulationContext& ctx) override;
114
118 const char* last_error_message() const noexcept override { return last_error_.c_str(); }
119
120private:
122 std::string last_error_;
123 std::vector<std::string> warnings_;
124};
125
126} /* namespace openswmm */
127
128#endif /* OPENSWMM_ENGINE_DEFAULT_STATE_IO_PLUGIN_HPP */
Interface for state / hot-start IO plugins.
DefaultStateIOPlugin()=default
Construct an UNLOADED stateless hot-start facade with empty diagnostics.
PluginState state() const noexcept override
Read the last assigned lifecycle marker without synchronization.
Definition DefaultStateIOPlugin.hpp:64
int validate(const SimulationContext &ctx) override
Mark VALIDATED without inspecting model compatibility.
Definition DefaultStateIOPlugin.cpp:90
int write_state(const std::string &path, const SimulationContext &ctx) override
Save current model/solver state through HotStartManager.
Definition DefaultStateIOPlugin.cpp:154
std::vector< std::string > warnings() const override
Copy warnings collected by the last read_state()/write_state() cycle.
Definition DefaultStateIOPlugin.hpp:108
bool can_read(const std::string &path) const override
Probe a leading hot-start signature or a recognized filename suffix.
Definition DefaultStateIOPlugin.cpp:104
int finalize(const SimulationContext &ctx) override
Mark FINALIZED without opening/closing a persistent stream.
Definition DefaultStateIOPlugin.cpp:95
int initialize(const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
Mark INITIALIZED and clear last_error.
Definition DefaultStateIOPlugin.cpp:83
const char * last_error_message() const noexcept override
Borrow the stored diagnostic text without clearing it.
Definition DefaultStateIOPlugin.hpp:118
int read_state(const std::string &path, SimulationContext &ctx) override
Open and apply a hot-start through HotStartManager.
Definition DefaultStateIOPlugin.cpp:123
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:201
Interface for state / hot-start IO plugins.
Definition IStateIOPlugin.hpp:71
PluginState
Plugin lifecycle states.
Definition PluginState.hpp:86
@ UNLOADED
Library not yet loaded (or was closed).
Definition PluginState.hpp:87
Definition ExchangeLaw.hpp:60
Central, reentrant simulation context.
Definition SimulationContext.hpp:390