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

Manages all dynamically loaded plugins for one engine instance. More...

#include <PluginFactory.hpp>

Collaboration diagram for openswmm::PluginFactory:

Public Member Functions

 PluginFactory ()=default
 
 ~PluginFactory ()
 
 PluginFactory (const PluginFactory &)=delete
 
PluginFactoryoperator= (const PluginFactory &)=delete
 
 PluginFactory (PluginFactory &&) noexcept=default
 
PluginFactoryoperator= (PluginFactory &&) noexcept=default
 
int load_plugins (const std::vector< PluginSpec > &specs, std::function< void(const std::string &)> warn_cb={})
 Load all plugins listed in the given specs.
 
int initialize_all (SimulationContext &ctx)
 Call initialize() on all output and report plugins.
 
int validate_all (SimulationContext &ctx)
 Call validate() on all plugins.
 
int prepare_all (SimulationContext &ctx)
 Call prepare() on all plugins (open output files, write headers).
 
int update_all (const SimulationSnapshot &snapshot)
 Deliver a snapshot to all output AND report plugins.
 
int finalize_all (SimulationContext &ctx)
 Call finalize() on all plugins.
 
int write_summary_all (SimulationContext &ctx)
 Call write_summary() on all report plugins.
 
const std::vector< IOutputPlugin * > & output_plugins () const noexcept
 All loaded output plugin instances.
 
const std::vector< IReportPlugin * > & report_plugins () const noexcept
 All loaded report plugin instances.
 
int plugin_count () const noexcept
 Total number of loaded plugins (output + report).
 
bool empty () const noexcept
 True if no plugins have been loaded.
 
void unload_all ()
 Unload all plugins and close library handles.
 
void add_output_plugin (IOutputPlugin *plugin, std::vector< std::string > args={})
 Inject a pre-created output plugin instance (takes ownership).
 
void add_report_plugin (IReportPlugin *plugin)
 Inject a pre-created report plugin instance (takes ownership).
 

Detailed Description

Manages all dynamically loaded plugins for one engine instance.

One PluginFactory per SWMMEngine instance (NOT a singleton). This allows multiple concurrent engine instances (e.g. Monte Carlo runs) to each have their own independent plugin set.

Constructor & Destructor Documentation

◆ PluginFactory() [1/3]

openswmm::PluginFactory::PluginFactory ( )
default

◆ ~PluginFactory()

openswmm::PluginFactory::~PluginFactory ( )
Here is the call graph for this function:

◆ PluginFactory() [2/3]

openswmm::PluginFactory::PluginFactory ( const PluginFactory )
delete

◆ PluginFactory() [3/3]

openswmm::PluginFactory::PluginFactory ( PluginFactory &&  )
defaultnoexcept

Member Function Documentation

◆ add_output_plugin()

void openswmm::PluginFactory::add_output_plugin ( IOutputPlugin plugin,
std::vector< std::string >  args = {} 
)

Inject a pre-created output plugin instance (takes ownership).

Used by SWMMEngine to register the DefaultOutputPlugin without going through the [PLUGINS] / dlopen path.

Parameters
pluginHeap-allocated instance; PluginFactory will delete it.
argsInit args (empty for built-in plugins).

◆ add_report_plugin()

void openswmm::PluginFactory::add_report_plugin ( IReportPlugin plugin)

Inject a pre-created report plugin instance (takes ownership).

◆ empty()

bool openswmm::PluginFactory::empty ( ) const
inlinenoexcept

True if no plugins have been loaded.

Here is the call graph for this function:

◆ finalize_all()

int openswmm::PluginFactory::finalize_all ( SimulationContext ctx)

Call finalize() on all plugins.

Called from the main thread after the IO thread has been joined.

◆ initialize_all()

int openswmm::PluginFactory::initialize_all ( SimulationContext ctx)

Call initialize() on all output and report plugins.

Parameters
ctxSimulation context (for metadata).
Returns
0 on success; last non-zero error code if any plugin failed.
Here is the call graph for this function:

◆ load_plugins()

int openswmm::PluginFactory::load_plugins ( const std::vector< PluginSpec > &  specs,
std::function< void(const std::string &)>  warn_cb = {} 
)

Load all plugins listed in the given specs.

For each spec: dlopen(spec.path), resolve openswmm_plugin_info, call create_output_plugin() / create_report_plugin(). Specs with load errors are skipped with a warning; they do not abort the whole load.

Parameters
specsPlugin specs parsed from [PLUGINS].
warn_cbOptional callback to report per-plugin load errors. Signature: void(const std::string& message).
Returns
Number of successfully loaded plugins.
Here is the call graph for this function:

◆ operator=() [1/2]

PluginFactory & openswmm::PluginFactory::operator= ( const PluginFactory )
delete

◆ operator=() [2/2]

PluginFactory & openswmm::PluginFactory::operator= ( PluginFactory &&  )
defaultnoexcept

◆ output_plugins()

const std::vector< IOutputPlugin * > & openswmm::PluginFactory::output_plugins ( ) const
inlinenoexcept

All loaded output plugin instances.

◆ plugin_count()

int openswmm::PluginFactory::plugin_count ( ) const
inlinenoexcept

Total number of loaded plugins (output + report).

Here is the caller graph for this function:

◆ prepare_all()

int openswmm::PluginFactory::prepare_all ( SimulationContext ctx)

Call prepare() on all plugins (open output files, write headers).

◆ report_plugins()

const std::vector< IReportPlugin * > & openswmm::PluginFactory::report_plugins ( ) const
inlinenoexcept

All loaded report plugin instances.

◆ unload_all()

void openswmm::PluginFactory::unload_all ( )

Unload all plugins and close library handles.

Here is the caller graph for this function:

◆ update_all()

int openswmm::PluginFactory::update_all ( const SimulationSnapshot snapshot)

Deliver a snapshot to all output AND report plugins.

Called from the IO thread at each output boundary. Only plugins in PREPARED or UPDATING state receive the update.

Parameters
snapshotRead-only simulation state snapshot.
Returns
0 on success; last non-zero error code if any plugin failed.

◆ validate_all()

int openswmm::PluginFactory::validate_all ( SimulationContext ctx)

Call validate() on all plugins.

◆ write_summary_all()

int openswmm::PluginFactory::write_summary_all ( SimulationContext ctx)

Call write_summary() on all report plugins.

Called after finalize_all(), during SWMMEngine::report().


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