OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::gpkg::GeoPackageOutputPlugin Class Reference

Own configuration and output IO state for a GeoPackage adapter. More...

#include <GeoPackageOutputPlugin.hpp>

Inheritance diagram for openswmm::gpkg::GeoPackageOutputPlugin:
Collaboration diagram for openswmm::gpkg::GeoPackageOutputPlugin:

Public Member Functions

 GeoPackageOutputPlugin ()=default
 Create an unloaded output adapter with no open database.
 
PluginState state () const noexcept override
 Read the stored adapter lifecycle marker.
 
int initialize (const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
 Copy output adapter configuration without opening the database.
 
int validate (const SimulationContext &ctx) override
 Mark the adapter validated without inspecting the model.
 
int prepare (const SimulationContext &ctx) override
 Open/create the results database, write model metadata and prepare result insertion.
 
int update (const SimulationSnapshot &snapshot) override
 Copy a snapshot's report-selected values into buffered database rows.
 
int finalize (const SimulationContext &ctx) override
 Flush buffered rows, mark the run completed and release database resources.
 
const char * last_error_message () const noexcept override
 Borrow the most recently stored failure diagnostic.
 
- Public Member Functions inherited from openswmm::IOutputPlugin
virtual ~IOutputPlugin ()=default
 Destroy this polymorphic instance after its callbacks and resource lifecycle finish. Default base destructor performs no finalize, file flush, I/O-thread join or model cleanup. Host deletes instances while their library remains loaded; implementations release owned resources safely. Never delete shared component metadata here.
 
virtual int initialize (const std::vector< std::string > &init_args, const class IPluginComponentInfo *info)=0
 Parse instance configuration before model validation/preparation.
 

Detailed Description

Own configuration and output IO state for a GeoPackage adapter.

Caller follows initialize/validate/prepare/update/finalize ordering as applicable and serializes all calls. State markers are descriptive; most methods do not enforce ordering. SQLite handles are privately owned; borrowed contexts/snapshots must remain valid during synchronous calls.

Constructor & Destructor Documentation

◆ GeoPackageOutputPlugin()

openswmm::gpkg::GeoPackageOutputPlugin::GeoPackageOutputPlugin ( )
default

Create an unloaded output adapter with no open database.

Member Function Documentation

◆ finalize()

int openswmm::gpkg::GeoPackageOutputPlugin::finalize ( const SimulationContext & ctx)
overridevirtual

Flush buffered rows, mark the run completed and release database resources.

Requires a successfully prepared connection. Finalizes insert statement before closing DB and sets FINALIZED; handled failure sets ERROR and may leave resources/buffer for destruction. SQL step status for run completion is not checked.

Parameters
[in]ctxUnused borrowed context.
Returns
Zero after normal cleanup; -1 after caught std::exception.

Implements openswmm::IOutputPlugin.

Here is the call graph for this function:

◆ initialize()

int openswmm::gpkg::GeoPackageOutputPlugin::initialize ( const std::vector< std::string > & init_args,
const IPluginComponentInfo * info )
override

Copy output adapter configuration without opening the database.

Sets INITIALIZED on success. Does not clear prior diagnostic/cache/buffer state; use a fresh adapter per independently configured run. Allocation exceptions can propagate during argument copying.

Parameters
[in]init_argsBorrowed arguments: [0] required database path, [1] optional simulation ID (default run_1). Extra arguments are ignored.
[in]infoUnused borrowed metadata pointer; NULL is accepted.
Returns
Zero after configuration; -1 with diagnostic when no database-path argument exists.

◆ last_error_message()

const char * openswmm::gpkg::GeoPackageOutputPlugin::last_error_message ( ) const
inlineoverridevirtualnoexcept

Borrow the most recently stored failure diagnostic.

Success does not consistently clear an earlier diagnostic.

Returns
Adapter-owned NUL-terminated string; empty initially. Copy before a later diagnostic mutation or destruction.

Reimplemented from openswmm::IOutputPlugin.

◆ prepare()

int openswmm::gpkg::GeoPackageOutputPlugin::prepare ( const SimulationContext & ctx)
overridevirtual

Open/create the results database, write model metadata and prepare result insertion.

Creates schema, writes the selected model/run, populates variables/species metadata, caches variable IDs/report flags and prepares an insert statement. Sets PREPARED on success, ERROR on handled failure. Does not roll back all earlier model/run setup after a later refusal. Connection and statement remain adapter-owned until finalize/destruction.

Parameters
[in]ctxBorrowed aligned model context; retained scalar/vector metadata is copied where needed, not owned through this reference.
Returns
Zero for normal preparation, -1 for reported species-name collision or caught std::exception.

Implements openswmm::IOutputPlugin.

Here is the call graph for this function:

◆ state()

PluginState openswmm::gpkg::GeoPackageOutputPlugin::state ( ) const
inlineoverridevirtualnoexcept

Read the stored adapter lifecycle marker.

Returns
Last assigned PluginState; individual operations do not independently enforce ordering.

Implements openswmm::IOutputPlugin.

◆ update()

int openswmm::gpkg::GeoPackageOutputPlugin::update ( const SimulationSnapshot & snapshot)
overridevirtual

Copy a snapshot's report-selected values into buffered database rows.

Rows own copied object IDs/values; absent cached variables are skipped. Flushes at >=5000 buffered rows. No PREPARED guard, no rollback of rows buffered before a later exception, and no state-marker transition on update failure. SQLite bind/step statuses in the flush loop are discarded, so zero alone does not certify every row was inserted.

Parameters
[in]snapshotBorrowed snapshot with valid counts/parallel arrays and reported-species names. Values are already in display units, sim_time is elapsed seconds; no conversion here.
Returns
Zero after normal buffering/threshold flush; -1 after caught std::exception.

Implements openswmm::IOutputPlugin.

◆ validate()

int openswmm::gpkg::GeoPackageOutputPlugin::validate ( const SimulationContext & ctx)
overridevirtual

Mark the adapter validated without inspecting the model.

Parameters
[in]ctxUnused borrowed context; no model/schema/file validation is performed.
Returns
Always zero; sets VALIDATED.

Implements openswmm::IOutputPlugin.


The documentation for this class was generated from the following files: