OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
GeoPackageReportPlugin.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
26
27#ifndef OPENSWMM_GEOPACKAGE_REPORT_PLUGIN_HPP
28#define OPENSWMM_GEOPACKAGE_REPORT_PLUGIN_HPP
29
30#include "GpkgUtils.hpp"
32#include <string>
33#include <unordered_map>
34
35namespace openswmm::gpkg {
36
45public:
50
55 PluginState state() const noexcept override { return state_; }
56
69 int initialize(const std::vector<std::string>& init_args,
70 const IPluginComponentInfo* info) override;
71
78 int validate(const SimulationContext& ctx) override;
89 int prepare(const SimulationContext& ctx) override;
96 int update(const SimulationSnapshot& snapshot) override;
110 int write_summary(const SimulationContext& ctx) override;
117 int finalize(const SimulationContext& ctx) override;
118
126 const char* last_error_message() const noexcept override { return error_msg_.c_str(); }
127
128private:
130 std::string error_msg_;
131 std::string db_path_;
132 std::string simulation_id_;
133 DbPtr db_;
134
135 std::unordered_map<std::string, int> variable_ids_;
143 int lookup_variable(const std::string& name, const std::string& obj_type);
144};
145
146} // namespace openswmm::gpkg
147
148#endif // OPENSWMM_GEOPACKAGE_REPORT_PLUGIN_HPP
RAII wrappers and utilities for SQLite operations in GeoPackage I/O.
Interface for report-writing plugins.
Describes a plugin component: metadata, capabilities, and factory methods.
Definition IPluginComponentInfo.hpp:201
Interface for report-writing plugins.
Definition IReportPlugin.hpp:63
GeoPackageReportPlugin()=default
Create an unloaded report adapter with no open database.
const char * last_error_message() const noexcept override
Borrow the most recently stored failure diagnostic.
Definition GeoPackageReportPlugin.hpp:126
int write_summary(const SimulationContext &ctx) override
Write selected object statistics and run continuity summaries.
Definition GeoPackageReportPlugin.cpp:83
PluginState state() const noexcept override
Read the stored adapter lifecycle marker.
Definition GeoPackageReportPlugin.hpp:55
int validate(const SimulationContext &ctx) override
Mark the adapter validated without inspecting the model.
Definition GeoPackageReportPlugin.cpp:35
int prepare(const SimulationContext &ctx) override
Open/create the database and cache existing variable identifiers.
Definition GeoPackageReportPlugin.cpp:40
int update(const SimulationSnapshot &snapshot) override
Accept a snapshot without per-step work.
Definition GeoPackageReportPlugin.cpp:79
int initialize(const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
Copy report adapter configuration without opening the database.
Definition GeoPackageReportPlugin.cpp:23
int finalize(const SimulationContext &ctx) override
Close the owned report database and mark finalized.
Definition GeoPackageReportPlugin.cpp:168
PluginState
Plugin lifecycle states.
Definition PluginState.hpp:86
@ UNLOADED
Library not yet loaded (or was closed).
Definition PluginState.hpp:87
Definition ExternalContentReader.cpp:50
std::unique_ptr< sqlite3, DbDeleter > DbPtr
Definition GpkgUtils.hpp:87
Complete simulation state snapshot at one output time step.
Definition SimulationSnapshot.hpp:123
Central, reentrant simulation context.
Definition SimulationContext.hpp:390