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
52
53#ifndef OPENSWMM_ISTATE_IO_PLUGIN_HPP
54#define OPENSWMM_ISTATE_IO_PLUGIN_HPP
55
56#include <string>
57#include <vector>
58#include "PluginState.hpp"
59
60namespace openswmm {
61
64
70public:
71 virtual ~IStateIOPlugin() = default;
72
74 virtual PluginState state() const noexcept = 0;
75
83 virtual int initialize(
84 const std::vector<std::string>& init_args,
85 const IPluginComponentInfo* info
86 ) = 0;
87
94 virtual int validate(const SimulationContext& ctx) = 0;
95
108 virtual bool can_read(const std::string& path) const { return false; }
109
126 virtual int read_state(const std::string& path, SimulationContext& ctx) = 0;
127
140 virtual int write_state(const std::string& path, const SimulationContext& ctx) = 0;
141
151 virtual std::vector<std::string> warnings() const { return {}; }
152
159 virtual int finalize(const SimulationContext& ctx) = 0;
160
162 virtual const char* last_error_message() const noexcept { return ""; }
163};
164
165} /* namespace openswmm */
166
167#endif /* OPENSWMM_ISTATE_IO_PLUGIN_HPP */
Plugin lifecycle state enumerator.
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:195
Interface for state / hot-start IO plugins.
Definition IStateIOPlugin.hpp:69
virtual PluginState state() const noexcept=0
Query the current plugin state.
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 bool can_read(const std::string &path) const
Cheap format sniff used to dispatch a path to the right plugin.
Definition IStateIOPlugin.hpp:108
virtual ~IStateIOPlugin()=default
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 int finalize(const SimulationContext &ctx)=0
Finalize and release resources.
virtual std::vector< std::string > warnings() const
Non-fatal warnings accumulated during the last call.
Definition IStateIOPlugin.hpp:151
virtual const char * last_error_message() const noexcept
Get the last error message.
Definition IStateIOPlugin.hpp:162
PluginState
Plugin lifecycle states.
Definition PluginState.hpp:83
Definition NodeCoupling.cpp:16
Central, reentrant simulation context.
Definition SimulationContext.hpp:353