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

Default output plugin: writes SWMM 5.x compatible binary .out file. More...

#include <DefaultOutputPlugin.hpp>

Inheritance diagram for openswmm::DefaultOutputPlugin:
Collaboration diagram for openswmm::DefaultOutputPlugin:

Classes

struct  PreparedCheckpoint
 

Public Member Functions

 DefaultOutputPlugin (std::string out_path)
 Store a binary output destination and start in LOADED state.
 
 ~DefaultOutputPlugin () override=default
 Destroy member buffers without implicitly closing out_file_. Caller must finalize() before deletion or otherwise arrange owned stream cleanup; the defaulted destructor adds no FILE RAII or footer.
 
PluginState state () const noexcept override
 Read the last assigned lifecycle marker without synchronization.
 
int initialize (const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
 Reset write counters and mark INITIALIZED.
 
int validate (const SimulationContext &ctx) override
 Mark VALIDATED without checking path or model arrays.
 
int prepare (const SimulationContext &ctx) override
 Open/truncate the binary output and write its reporting layout/header.
 
int update (const SimulationSnapshot &snapshot) override
 Append and flush one complete report-period record, then increment counters.
 
int finalize (const SimulationContext &ctx) override
 Write a footer with current counters, close the output and mark FINALIZED.
 
const char * last_error_message () const noexcept override
 Borrow the stored diagnostic text without clearing it.
 
- 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.
 

Friends

class SWMMEngine
 

Detailed Description

Default output plugin: writes SWMM 5.x compatible binary .out file.

This plugin is injected automatically when the engine is opened with a non-empty out_path. It does NOT require a [PLUGINS] entry.

Constructor & Destructor Documentation

◆ DefaultOutputPlugin()

openswmm::DefaultOutputPlugin::DefaultOutputPlugin ( std::string out_path)
explicit

Store a binary output destination and start in LOADED state.

Parameters
out_pathUTF-8 filename moved into storage; no file is opened/validated yet.

◆ ~DefaultOutputPlugin()

openswmm::DefaultOutputPlugin::~DefaultOutputPlugin ( )
overridedefault

Destroy member buffers without implicitly closing out_file_. Caller must finalize() before deletion or otherwise arrange owned stream cleanup; the defaulted destructor adds no FILE RAII or footer.

Member Function Documentation

◆ finalize()

int openswmm::DefaultOutputPlugin::finalize ( const SimulationContext & ctx)
overridevirtual

Write a footer with current counters, close the output and mark FINALIZED.

Parameters
ctxIgnored; footer error code is always zero rather than context error.
Returns
Zero including when no stream exists. Native long offsets narrow to int without overflow checks; writer/file-size limits must remain valid. fwrite/close errors are ignored. Caller first drains all outstanding update calls.

Implements openswmm::IOutputPlugin.

◆ initialize()

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

Reset write counters and mark INITIALIZED.

Parameters
init_argsIgnored strings.
infoIgnored metadata pointer.
Returns
Zero. Does not close a preexisting stream or clear all metadata/diagnostics.

◆ last_error_message()

const char * openswmm::DefaultOutputPlugin::last_error_message ( ) const
inlineoverridevirtualnoexcept

Borrow the stored diagnostic text without clearing it.

Returns
NUL-terminated member bytes, possibly empty/stale; valid until the next error mutation or destruction. Never free; use the method return code for success.

Reimplemented from openswmm::IOutputPlugin.

◆ prepare()

int openswmm::DefaultOutputPlugin::prepare ( const SimulationContext & ctx)
overridevirtual

Open/truncate the binary output and write its reporting layout/header.

Parameters
ctxStable aligned model, reporting flags, species naming/units and options. Static node/link lengths are internal feet and converted here; subcatch areas are already acres/hectares. Managed sessions use exclusive checkpoint output creation and capture its fresh header. Call once with no prior owned open stream.
Returns
Zero after marking PREPARED/counters zero; -1 for open or managed prefix read failure, with last_error set. General header fwrite/setvbuf errors are not checked. Exceptions can leave a partial file/open stream; no rollback is added.

Implements openswmm::IOutputPlugin.

Here is the call graph for this function:

◆ state()

PluginState openswmm::DefaultOutputPlugin::state ( ) const
inlineoverridevirtualnoexcept

Read the last assigned lifecycle marker without synchronization.

Returns
Stored state; methods do not generally enforce an incoming-state transition. Serialize plugin lifecycle/IO with active worker calls.

Implements openswmm::IOutputPlugin.

◆ update()

int openswmm::DefaultOutputPlugin::update ( const SimulationSnapshot & snapshot)
overridevirtual

Append and flush one complete report-period record, then increment counters.

Parameters
snapshotStable immutable packet with the same object counts/report flags and species stride as prepare(). Values already use project display units, link directions are already applied, and sim_time is a SWMM serial day. Ordinary missing vector entries become zero; optional missing snow-process fields NaN. No finite-value/layout validation or unit conversion is applied to period data.
Returns
-1 if no output stream, otherwise zero after marking UPDATING, writing and flushing. fwrite/fflush errors are not tested, so counters can advance despite IO failure. Call serially, normally on IOThread, without lifecycle/checkpoint races.

Implements openswmm::IOutputPlugin.

◆ validate()

int openswmm::DefaultOutputPlugin::validate ( const SimulationContext & ctx)
overridevirtual

Mark VALIDATED without checking path or model arrays.

Parameters
ctxIgnored context.
Returns
Zero unconditionally; prepare/update caller invariants still apply.

Implements openswmm::IOutputPlugin.

Friends And Related Symbol Documentation

◆ SWMMEngine

friend class SWMMEngine
friend

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