OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
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:

Public Member Functions

 DefaultOutputPlugin (std::string out_path)
 Construct with the output file path.
 
 ~DefaultOutputPlugin () override=default
 
PluginState state () const noexcept override
 Query the current plugin state.
 
int initialize (const std::vector< std::string > &init_args, const IPluginComponentInfo *info) override
 
int validate (const SimulationContext &ctx) override
 Validate plugin configuration against the simulation model.
 
int prepare (const SimulationContext &ctx) override
 Open output file(s) and write headers.
 
int update (const SimulationSnapshot &snapshot) override
 Write one output snapshot. Called from the IO thread.
 
int finalize (const SimulationContext &ctx) override
 Flush and close output file(s). Called from main thread.
 
const char * last_error_message () const noexcept override
 Get the last error message from this plugin instance.
 
- Public Member Functions inherited from openswmm::IOutputPlugin
virtual ~IOutputPlugin ()=default
 
virtual int initialize (const std::vector< std::string > &init_args, const class IPluginComponentInfo *info)=0
 Initialize the plugin from command-line-style arguments.
 

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

Construct with the output file path.

Parameters
out_pathFile path for the binary .out file.

◆ ~DefaultOutputPlugin()

openswmm::DefaultOutputPlugin::~DefaultOutputPlugin ( )
overridedefault

Member Function Documentation

◆ finalize()

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

Flush and close output file(s). Called from main thread.

Called after the simulation loop ends and the IO thread has been joined. All update() calls have completed at this point. Flush any write buffers and close file handles.

Parameters
ctxRead-only simulation context (for final state / metadata).
Returns
0 on success; non-zero on error.
Postcondition
state() == PluginState::FINALIZED on success.

Implements openswmm::IOutputPlugin.

◆ initialize()

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

◆ last_error_message()

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

Get the last error message from this plugin instance.

Returns
Null-terminated error string, or empty string if no error.

Reimplemented from openswmm::IOutputPlugin.

◆ prepare()

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

Open output file(s) and write headers.

Called after validate() succeeds, just before the simulation loop begins. Open file handles, allocate write buffers, and write any file headers.

Parameters
ctxRead-only simulation context.
Returns
0 on success; non-zero on error.
Postcondition
state() == PluginState::PREPARED on success.

Implements openswmm::IOutputPlugin.

◆ state()

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

Query the current plugin state.

Returns
Current PluginState (thread-safe read).

Implements openswmm::IOutputPlugin.

◆ update()

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

Write one output snapshot. Called from the IO thread.

Called at each output time step with a read-only snapshot of the simulation state. This method runs on the IO thread — it must NOT access the live SimulationContext.

Parameters
snapshotRead-only simulation state at this output time step.
Returns
0 on success; non-zero on error (transitions to ERROR state).
Note
This may be called concurrently with the main simulation thread advancing the next timestep. Use only snapshot data.

Implements openswmm::IOutputPlugin.

◆ validate()

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

Validate plugin configuration against the simulation model.

Called after the input file is fully parsed and the model is loaded. Check that configured output paths are writable, that requested object IDs exist, etc.

Parameters
ctxRead-only view of the simulation context (for model metadata).
Returns
0 on success; non-zero on error.
Postcondition
state() == PluginState::VALIDATED on success.

Implements openswmm::IOutputPlugin.


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