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

Default report plugin: writes SWMM 5.x compatible .rpt report file. More...

#include <DefaultReportPlugin.hpp>

Inheritance diagram for openswmm::DefaultReportPlugin:
Collaboration diagram for openswmm::DefaultReportPlugin:

Public Member Functions

 DefaultReportPlugin (std::string rpt_path)
 Store a report destination and start in LOADED state.
 
 ~DefaultReportPlugin () override
 Write an interruption marker, flush and close a report still open at destruction. No summary is generated; fprintf/flush/close errors are ignored. Caller first serializes all active report use and releases borrowed diagnostic pointers.
 
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
 Mark INITIALIZED without opening the report.
 
int validate (const SimulationContext &ctx) override
 Mark VALIDATED without checking path or model data.
 
int prepare (const SimulationContext &ctx) override
 Open a progressive report, write its preamble and mark PREPARED.
 
int update (const SimulationSnapshot &snapshot) override
 Mark UPDATING without writing per-step report content.
 
int finalize (const SimulationContext &ctx) override
 Append outstanding errors/warnings, flush and mark FINALIZED.
 
int write_summary (const SimulationContext &ctx) override
 Write result/snow/timing sections and close the report stream.
 
void requireFreshOutput () noexcept
 Require exclusive file creation for managed-session report paths. Sets a retained flag only; existing streams are not reopened and no IO occurs.
 
const char * last_error_message () const noexcept override
 Borrow the stored diagnostic text without clearing it.
 
- Public Member Functions inherited from openswmm::IReportPlugin
virtual ~IReportPlugin ()=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

Default report plugin: writes SWMM 5.x compatible .rpt report file.

Constructor & Destructor Documentation

◆ DefaultReportPlugin()

openswmm::DefaultReportPlugin::DefaultReportPlugin ( std::string rpt_path)
explicit

Store a report destination and start in LOADED state.

Parameters
rpt_pathUTF-8 filename moved into storage; empty disables actual report IO. No file is opened and no path is validated until prepare()/write_summary().

◆ ~DefaultReportPlugin()

openswmm::DefaultReportPlugin::~DefaultReportPlugin ( )
override

Write an interruption marker, flush and close a report still open at destruction. No summary is generated; fprintf/flush/close errors are ignored. Caller first serializes all active report use and releases borrowed diagnostic pointers.

Member Function Documentation

◆ finalize()

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

Append outstanding errors/warnings, flush and mark FINALIZED.

Parameters
ctxStable model diagnostics; errors are capped at one hundred plus a maximum-count notice, warnings are not capped.
Returns
Zero even with no open file or unchecked fprintf/flush failure. Stream remains open for write_summary(); this is not the final file-close operation.

Implements openswmm::IReportPlugin.

◆ initialize()

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

Mark INITIALIZED without opening the report.

Parameters
init_argsIgnored strings.
infoIgnored metadata pointer.
Returns
Zero, retaining previous diagnostics/counters.

◆ last_error_message()

const char * openswmm::DefaultReportPlugin::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::IReportPlugin.

◆ prepare()

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

Open a progressive report, write its preamble and mark PREPARED.

Parameters
ctxStable compatible model/options; rpt_disabled skips opening. A nonempty enabled destination uses truncate mode normally, exclusive creation after requireFreshOutput(). Call only once before final close; no guard closes an already open stream on repeated prepare.
Returns
-1 plus ERROR/last_error only for failed exclusive managed creation; ordinary open failure still returns zero and marks PREPARED with no file. Preamble/flush errors are not checked; exceptions propagate.

Implements openswmm::IReportPlugin.

Here is the call graph for this function:

◆ requireFreshOutput()

void openswmm::DefaultReportPlugin::requireFreshOutput ( )
inlinenoexcept

Require exclusive file creation for managed-session report paths. Sets a retained flag only; existing streams are not reopened and no IO occurs.

◆ state()

PluginState openswmm::DefaultReportPlugin::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::IReportPlugin.

◆ update()

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

Mark UPDATING without writing per-step report content.

Parameters
snapshotIgnored immutable packet.
Returns
Zero; report summaries use SimulationContext later.

Reimplemented from openswmm::IReportPlugin.

◆ validate()

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

Mark VALIDATED without checking path or model data.

Parameters
ctxIgnored context.
Returns
Zero unconditionally.

Implements openswmm::IReportPlugin.

◆ write_summary()

int openswmm::DefaultReportPlugin::write_summary ( const SimulationContext & ctx)
overridevirtual

Write result/snow/timing sections and close the report stream.

Parameters
ctxStable aligned model/statistics/options. Uses progressive preamble when prepared; otherwise opens/truncates (or creates exclusively) and writes the whole report including diagnostics. Run finalize() first to flush new diagnostics into an already open progressive stream.
Returns
Zero for empty/disabled report or after writing/closing, -1 for fallback open failure. Does not detect later write/close errors, set last_error for that fallback failure, or change lifecycle state. Repeated calls after close can rewrite the report (or fail exclusive creation). Exceptions propagate.

Implements openswmm::IReportPlugin.

Here is the call graph for this function:

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