OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
DefaultInputPlugin.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
31
32#ifndef OPENSWMM_ENGINE_DEFAULT_INPUT_PLUGIN_HPP
33#define OPENSWMM_ENGINE_DEFAULT_INPUT_PLUGIN_HPP
34
37
38#include <string>
39#include <vector>
40
41namespace openswmm {
42
53public:
58
59 PluginState state() const noexcept override { return state_; }
60
61 int initialize(const std::vector<std::string>& init_args,
62 const IPluginComponentInfo* info) override;
63
64 int validate(const SimulationContext& ctx) override;
65
66 int read(const std::string& path, SimulationContext& ctx) override;
67
68 int write(const std::string& path, const SimulationContext& ctx) override;
69
70 int finalize(const SimulationContext& ctx) override;
71
72 const char* last_error_message() const noexcept override {
73 return last_error_.c_str();
74 }
75
76 std::vector<std::string> skipped_sections() const override {
77 return skipped_sections_;
78 }
79
81 input::SectionRegistry& registry() noexcept { return registry_; }
82
83private:
85 void register_builtin_handlers();
86
87 input::SectionRegistry registry_;
89 std::string last_error_;
90 std::vector<std::string> skipped_sections_;
91};
92
93} /* namespace openswmm */
94
95#endif /* OPENSWMM_ENGINE_DEFAULT_INPUT_PLUGIN_HPP */
Interface for input file reader/writer plugins.
Registry that maps SWMM section tags to handler functions.
DefaultInputPlugin()
Construct and register all built-in section handlers.
Definition DefaultInputPlugin.cpp:62
std::vector< std::string > skipped_sections() const override
Sections or elements that were skipped during the last read().
Definition DefaultInputPlugin.hpp:76
int finalize(const SimulationContext &ctx) override
Finalize and release resources.
Definition DefaultInputPlugin.cpp:231
const char * last_error_message() const noexcept override
Get the last error message.
Definition DefaultInputPlugin.hpp:72
PluginState state() const noexcept override
Query the current plugin state.
Definition DefaultInputPlugin.hpp:59
int read(const std::string &path, SimulationContext &ctx) override
Read model data from a file into the simulation context.
Definition DefaultInputPlugin.cpp:190
int initialize(const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
Initialize from [PLUGINS] arguments.
Definition DefaultInputPlugin.cpp:177
int write(const std::string &path, const SimulationContext &ctx) override
Write model data from the simulation context to a file.
Definition DefaultInputPlugin.cpp:203
input::SectionRegistry & registry() noexcept
Access the section registry (for custom section registration).
Definition DefaultInputPlugin.hpp:81
int validate(const SimulationContext &ctx) override
Validate configuration against the loaded model.
Definition DefaultInputPlugin.cpp:185
Interface for input file reader/writer plugins.
Definition IInputPlugin.hpp:59
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:195
Registry that maps section tags (e.g., "[JUNCTIONS]") to handlers.
Definition SectionRegistry.hpp:87
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