OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
ResultHistoryAppend.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2#pragma once
3
5#include <utility>
6
7namespace openswmm::twoD {
8// Appenders only grow existing numeric columns. Keep their prior extents and
9// checkpoint anchor until validation succeeds; rollback never allocates.
11public:
12 ResultHistoryAppend(std::map<std::string, SourceResultTable>& tables,
13 std::string& boundary) : boundary_(boundary) {
14 std::size_t count = 0;
15 for (const auto& [name, table] : tables)
16 count += table.columns.size();
17 columns_.reserve(count);
18 for (auto& [name, table] : tables)
19 for (auto& column : table.columns)
20 columns_.emplace_back(&column, column.size());
21 }
25 if (!committed_) {
26 for (auto [column, size] : columns_)
27 column->resize(size);
28 if (replaced_)
29 boundary_.swap(previous_boundary_);
30 }
31 }
32 void replaceBoundary(std::string& next) noexcept {
33 previous_boundary_.swap(boundary_);
34 boundary_.swap(next);
35 replaced_ = true;
36 }
37 void commit() noexcept { committed_ = true; }
38
39private:
40 std::vector<std::pair<std::vector<double>*, std::size_t>> columns_;
41 std::string& boundary_;
42 std::string previous_boundary_;
43 bool replaced_ = false, committed_ = false;
44};
45}
Columnar source diagnostics and saved identifier tables.
ResultHistoryAppend & operator=(const ResultHistoryAppend &)=delete
void replaceBoundary(std::string &next) noexcept
Definition ResultHistoryAppend.hpp:32
ResultHistoryAppend(std::map< std::string, SourceResultTable > &tables, std::string &boundary)
Definition ResultHistoryAppend.hpp:12
ResultHistoryAppend(const ResultHistoryAppend &)=delete
void commit() noexcept
Definition ResultHistoryAppend.hpp:37
~ResultHistoryAppend()
Definition ResultHistoryAppend.hpp:24
Definition ExchangeLaw.hpp:60