OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
IStateIOPlugin.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
44
54
55#ifndef OPENSWMM_ISTATE_IO_PLUGIN_HPP
56#define OPENSWMM_ISTATE_IO_PLUGIN_HPP
57
58#include <string>
59#include <vector>
60#include "PluginState.hpp"
61
62namespace openswmm {
63
66
72public:
77 virtual ~IStateIOPlugin() = default;
78
84 virtual PluginState state() const noexcept = 0;
85
98 virtual int initialize(const std::vector<std::string>& init_args,
99 const IPluginComponentInfo* info) = 0;
100
109 virtual int validate(const SimulationContext& ctx) = 0;
110
118 virtual bool can_read(const std::string& path) const { return false; }
119
130 virtual int read_state(const std::string& path, SimulationContext& ctx) = 0;
131
141 virtual int write_state(const std::string& path, const SimulationContext& ctx) = 0;
142
148 virtual std::vector<std::string> warnings() const { return {}; }
149
158 virtual int finalize(const SimulationContext& ctx) = 0;
159
165 virtual const char* last_error_message() const noexcept { return ""; }
166};
167
168} /* namespace openswmm */
169
170#endif /* OPENSWMM_ISTATE_IO_PLUGIN_HPP */
Plugin lifecycle state enumerator.
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:201
Interface for state / hot-start IO plugins.
Definition IStateIOPlugin.hpp:71
virtual PluginState state() const noexcept=0
Read this implementation's current plugin lifecycle state.
virtual int read_state(const std::string &path, SimulationContext &ctx)=0
Decode supported persisted runtime state into an initialized compatible model.
virtual int write_state(const std::string &path, const SimulationContext &ctx)=0
Save supported runtime state at a caller-qualified accepted boundary.
virtual bool can_read(const std::string &path) const
Offer cheap format recognition for ordered state-reader dispatch.
Definition IStateIOPlugin.hpp:118
virtual ~IStateIOPlugin()=default
Destroy this polymorphic instance after its callbacks and resource lifecycle finish....
virtual int initialize(const std::vector< std::string > &init_args, const IPluginComponentInfo *info)=0
Parse instance configuration before model validation/preparation.
virtual int validate(const SimulationContext &ctx)=0
Qualify instance configuration against the loaded compatible model.
virtual int finalize(const SimulationContext &ctx)=0
Finish this instance after producer/update work has stopped.
virtual std::vector< std::string > warnings() const
Copy nonfatal diagnostics from the implementation's last state I/O operation.
Definition IStateIOPlugin.hpp:148
virtual const char * last_error_message() const noexcept
Borrow the latest implementation error text without clearing it.
Definition IStateIOPlugin.hpp:165
PluginState
Plugin lifecycle states.
Definition PluginState.hpp:86
Definition ExchangeLaw.hpp:60
Central, reentrant simulation context.
Definition SimulationContext.hpp:390