OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
IOutputPlugin.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
55
56#ifndef OPENSWMM_IOUTPUT_PLUGIN_HPP
57#define OPENSWMM_IOUTPUT_PLUGIN_HPP
58
59#include <string>
60#include <vector>
61#include "PluginState.hpp"
63
64/* Forward declaration — avoid pulling in the full SimulationContext */
65namespace openswmm { struct SimulationContext; }
66
67namespace openswmm {
68
74public:
75 virtual ~IOutputPlugin() = default;
76
77 // -----------------------------------------------------------------------
78 // State query
79 // -----------------------------------------------------------------------
80
85 virtual PluginState state() const noexcept = 0;
86
87 // -----------------------------------------------------------------------
88 // Lifecycle methods (main thread)
89 // -----------------------------------------------------------------------
90
107 virtual int initialize(
108 const std::vector<std::string>& init_args,
109 const class IPluginComponentInfo* info
110 ) = 0;
111
124 virtual int validate(const SimulationContext& ctx) = 0;
125
138 virtual int prepare(const SimulationContext& ctx) = 0;
139
153 virtual int update(const SimulationSnapshot& snapshot) = 0;
154
167 virtual int finalize(const SimulationContext& ctx) = 0;
168
169 // -----------------------------------------------------------------------
170 // Optional: error message
171 // -----------------------------------------------------------------------
172
177 virtual const char* last_error_message() const noexcept { return ""; }
178};
179
180} /* namespace openswmm */
181
182#endif /* OPENSWMM_IOUTPUT_PLUGIN_HPP */
Plugin lifecycle state enumerator.
Read-only snapshot of simulation state passed to plugins.
Interface for output-writing plugins.
Definition IOutputPlugin.hpp:73
virtual ~IOutputPlugin()=default
virtual int update(const SimulationSnapshot &snapshot)=0
Write one output snapshot. Called from the IO thread.
virtual const char * last_error_message() const noexcept
Get the last error message from this plugin instance.
Definition IOutputPlugin.hpp:177
virtual int validate(const SimulationContext &ctx)=0
Validate plugin configuration against the simulation model.
virtual int initialize(const std::vector< std::string > &init_args, const class IPluginComponentInfo *info)=0
Initialize the plugin from command-line-style arguments.
virtual int finalize(const SimulationContext &ctx)=0
Flush and close output file(s). Called from main thread.
virtual int prepare(const SimulationContext &ctx)=0
Open output file(s) and write headers.
virtual PluginState state() const noexcept=0
Query the current plugin state.
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:195
PluginState
Plugin lifecycle states.
Definition PluginState.hpp:83
Definition NodeCoupling.cpp:16
Central, reentrant simulation context.
Definition SimulationContext.hpp:353
Complete simulation state snapshot at one output time step.
Definition SimulationSnapshot.hpp:117