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
60
61#ifndef OPENSWMM_ENGINE_INPUT_READER_HPP
62#define OPENSWMM_ENGINE_INPUT_READER_HPP
63
64#include "SectionRegistry.hpp"
66
67#include <string>
68#include <vector>
69#include <iosfwd>
70
71namespace openswmm::input {
72
79public:
89 explicit InputReader(SectionRegistry& registry);
90
104 bool read(const std::string& path, SimulationContext& ctx);
105
121 bool read_stream(std::istream& stream, SimulationContext& ctx);
122
128 int lines_read() const noexcept { return lines_read_; }
129
136 const std::vector<std::string>& skipped_sections() const noexcept { return skipped_sections_; }
137
138private:
139 SectionRegistry& registry_;
140 int lines_read_ = 0;
141 std::vector<std::string> skipped_sections_;
142
152 static std::string parse_section_header(std::string_view line);
153
166 void dispatch_section(const std::string& tag, const std::vector<std::string>& lines,
167 SimulationContext& ctx);
168
179 void replay_deferred_rows(SimulationContext& ctx);
180};
181
182} /* namespace openswmm::input */
183
184#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)
Borrow a pre-populated handler registry.
Definition InputReader.cpp:78
const std::vector< std::string > & skipped_sections() const noexcept
Borrow unrecognized, unhandled section tags from the last stream parse.
Definition InputReader.hpp:136
int lines_read() const noexcept
Read the physical-line counter from the most recent stream parse.
Definition InputReader.hpp:128
bool read_stream(std::istream &stream, SimulationContext &ctx)
Read section batches and replay deferred rows once.
Definition InputReader.cpp:100
bool read(const std::string &path, SimulationContext &ctx)
Open a UTF-8 input path and parse its section stream.
Definition InputReader.cpp:84
Registry that maps section tags (e.g., "[JUNCTIONS]") to handlers.
Definition SectionRegistry.hpp:86
Definition CatchmentHandler.cpp:70
Central, reentrant simulation context.
Definition SimulationContext.hpp:390