OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
InputReader.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
54
55#ifndef OPENSWMM_ENGINE_INPUT_READER_HPP
56#define OPENSWMM_ENGINE_INPUT_READER_HPP
57
58#include "SectionRegistry.hpp"
60
61#include <string>
62#include <vector>
63#include <iosfwd>
64
65namespace openswmm::input {
66
73public:
79 explicit InputReader(SectionRegistry& registry);
80
95 bool read(const std::string& path, SimulationContext& ctx);
96
104 bool read_stream(std::istream& stream, SimulationContext& ctx);
105
109 int lines_read() const noexcept { return lines_read_; }
110
114 const std::vector<std::string>& skipped_sections() const noexcept {
115 return skipped_sections_;
116 }
117
118private:
119 SectionRegistry& registry_;
120 int lines_read_ = 0;
121 std::vector<std::string> skipped_sections_;
122
132 static std::string parse_section_header(std::string_view line);
133
137 void dispatch_section(
138 const std::string& tag,
139 const std::vector<std::string>& lines,
141 );
142
154 void replay_deferred_rows(SimulationContext& ctx);
155};
156
157} /* namespace openswmm::input */
158
159#endif /* OPENSWMM_ENGINE_INPUT_READER_HPP */
Registry that maps SWMM section tags to handler functions.
The central, reentrant simulation context for the new engine.
InputReader(SectionRegistry &registry)
Construct an InputReader with a pre-populated registry.
Definition InputReader.cpp:47
const std::vector< std::string > & skipped_sections() const noexcept
List of section tags that were skipped (no registered handler).
Definition InputReader.hpp:114
int lines_read() const noexcept
Number of lines successfully parsed in the last read() call.
Definition InputReader.hpp:109
bool read_stream(std::istream &stream, SimulationContext &ctx)
Parse from an already-open stream (for testing / stdin).
Definition InputReader.cpp:71
bool read(const std::string &path, SimulationContext &ctx)
Read and parse the specified .inp file.
Definition InputReader.cpp:55
Registry that maps section tags (e.g., "[JUNCTIONS]") to handlers.
Definition SectionRegistry.hpp:87
Definition CatchmentHandler.cpp:69
Central, reentrant simulation context.
Definition SimulationContext.hpp:353