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:
57
61 PluginState state() const noexcept override { return state_; }
62
67 int initialize(const std::vector<std::string>& init_args,
68 const IPluginComponentInfo* info) override;
69
73 int validate(const SimulationContext& ctx) override;
74
83 int read(const std::string& path, SimulationContext& ctx) override;
84
85 // Parse native container input using the same handlers as ordinary INP files.
86 int readText(const std::string& text, SimulationContext& ctx);
88
96 int write(const std::string& path, const SimulationContext& ctx) override;
97
101 int finalize(const SimulationContext& ctx) override;
102
106 const char* last_error_message() const noexcept override { return last_error_.c_str(); }
107
110 std::vector<std::string> skipped_sections() const override { return skipped_sections_; }
111
115 input::SectionRegistry& registry() noexcept { return registry_; }
116
117private:
122 void register_builtin_handlers();
123
124 input::SectionRegistry registry_;
126 std::string last_error_;
127 std::vector<std::string> skipped_sections_;
128};
129
130} /* namespace openswmm */
131
132#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 an UNLOADED plugin and register builtin input/annotation handlers. No file is read; allocat...
Definition DefaultInputPlugin.cpp:128
int readText(const std::string &text, SimulationContext &ctx)
Definition DefaultInputPlugin.cpp:115
void registerContextSections(SimulationContext &ctx)
Definition DefaultInputPlugin.cpp:72
std::vector< std::string > skipped_sections() const override
Copy the last completed InputReader skipped-section list.
Definition DefaultInputPlugin.hpp:110
int finalize(const SimulationContext &ctx) override
Mark the plugin FINALIZED without IO or validation.
Definition DefaultInputPlugin.cpp:324
const char * last_error_message() const noexcept override
Borrow the stored diagnostic text without clearing it.
Definition DefaultInputPlugin.hpp:106
PluginState state() const noexcept override
Read the last assigned lifecycle marker without synchronization.
Definition DefaultInputPlugin.hpp:61
int read(const std::string &path, SimulationContext &ctx) override
Read an input file through the owned section registry.
Definition DefaultInputPlugin.cpp:282
int initialize(const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
Mark this plugin INITIALIZED without interpreting arguments.
Definition DefaultInputPlugin.cpp:271
int write(const std::string &path, const SimulationContext &ctx) override
Serialize current engine state through InpWriter and its sidecar rules.
Definition DefaultInputPlugin.cpp:295
input::SectionRegistry & registry() noexcept
Borrow the owned mutable handler registry for caller-managed extensions.
Definition DefaultInputPlugin.hpp:115
int validate(const SimulationContext &ctx) override
Mark this plugin VALIDATED without validating a model.
Definition DefaultInputPlugin.cpp:277
Interface for input file reader/writer plugins.
Definition IInputPlugin.hpp:61
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:201
Registry that maps section tags (e.g., "[JUNCTIONS]") to handlers.
Definition SectionRegistry.hpp:86
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