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 plugin discovery, loading, and lifecycle for one engine instance. More...

#include <PluginFactory.hpp>

Collaboration diagram for openswmm::PluginFactory:

Classes

struct  ComponentEntry
 List all discovered component info entries. More...
 

Public Member Functions

 PluginFactory ()
 Construct and auto-discover plugins in standard directories.
 
 ~PluginFactory ()
 
 PluginFactory (const PluginFactory &)=delete
 
PluginFactoryoperator= (const PluginFactory &)=delete
 
 PluginFactory (PluginFactory &&) noexcept=default
 
PluginFactoryoperator= (PluginFactory &&) noexcept=default
 
void discover (std::function< void(const std::string &)> warn_cb={})
 Scan standard directories for compatible plugin libraries.
 
IPluginComponentInfoload_library (const std::string &path, std::function< void(const std::string &)> warn_cb={})
 Load a single shared library and register it in the component registry.
 
IPluginComponentInfofind_component (const std::string &id_or_path, std::function< void(const std::string &)> warn_cb={})
 Resolve a plugin identifier to its component info.
 
std::vector< ComponentEntrydiscovered_components () const
 
int load_plugins (const std::vector< PluginSpec > &specs, std::function< void(const std::string &)> warn_cb={})
 Load plugins from a list of specs (from [PLUGINS] section).
 
int initialize_all (SimulationContext &ctx)
 
int validate_all (SimulationContext &ctx)
 
int prepare_all (SimulationContext &ctx)
 
int update_all (const SimulationSnapshot &snapshot)
 
int finalize_all (SimulationContext &ctx)
 
int write_summary_all (SimulationContext &ctx)
 
const std::vector< IInputPlugin * > & input_plugins () const noexcept
 
const std::vector< IOutputPlugin * > & output_plugins () const noexcept
 
const std::vector< IReportPlugin * > & report_plugins () const noexcept
 
const std::vector< IStateIOPlugin * > & state_io_plugins () const noexcept
 
int plugin_count () const noexcept
 
bool empty () const noexcept
 
void unload_all ()
 
void add_output_plugin (IOutputPlugin *plugin, std::vector< std::string > args={})
 
void add_report_plugin (IReportPlugin *plugin)
 
void add_input_plugin (IInputPlugin *plugin)
 
void add_state_io_plugin (IStateIOPlugin *plugin)
 

Detailed Description

Manages plugin discovery, loading, and lifecycle for one engine instance.

One PluginFactory per SWMMEngine instance (NOT a singleton). On construction, auto-discovers compatible plugin libraries in standard search directories.

Constructor & Destructor Documentation

◆ PluginFactory() [1/3]

openswmm::PluginFactory::PluginFactory ( )

Construct and auto-discover plugins in standard directories.

Scans the engine library directory and subdirectories (plugins/, components/) for shared libraries that export openswmm_plugin_info. Discovered libraries are registered in the component registry but plugin instances are NOT created.

Here is the call graph for this function:

◆ ~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_input_plugin()

void openswmm::PluginFactory::add_input_plugin ( IInputPlugin plugin)

◆ add_output_plugin()

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

◆ add_report_plugin()

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

◆ add_state_io_plugin()

void openswmm::PluginFactory::add_state_io_plugin ( IStateIOPlugin plugin)

◆ discover()

void openswmm::PluginFactory::discover ( std::function< void(const std::string &)>  warn_cb = {})

Scan standard directories for compatible plugin libraries.

Called automatically by the constructor. Can be called again to re-scan (e.g., after plugins are installed at runtime). Scans: engine library dir, <dir>/plugins/, <dir>/components/.

Parameters
warn_cbOptional callback for per-library load warnings.
Here is the caller graph for this function:

◆ discovered_components()

std::vector< PluginFactory::ComponentEntry > openswmm::PluginFactory::discovered_components ( ) const
Here is the caller graph for this function:

◆ empty()

bool openswmm::PluginFactory::empty ( ) const
inlinenoexcept
Here is the call graph for this function:

◆ finalize_all()

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

◆ find_component()

IPluginComponentInfo * openswmm::PluginFactory::find_component ( const std::string &  id_or_path,
std::function< void(const std::string &)>  warn_cb = {} 
)

Resolve a plugin identifier to its component info.

Resolution logic:

  1. If the string looks like a file path (contains '/' or '\', or ends in .so/.dylib/.dll), load it directly.
  2. Otherwise, parse as "id:version" or "id" and look up in the component registry. If no version is specified, returns the first match found.
Parameters
id_or_pathFile path or "id" or "id:version" string.
warn_cbOptional warning callback.
Returns
Pointer to IPluginComponentInfo, or nullptr if not found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize_all()

int openswmm::PluginFactory::initialize_all ( SimulationContext ctx)
Here is the call graph for this function:

◆ input_plugins()

const std::vector< IInputPlugin * > & openswmm::PluginFactory::input_plugins ( ) const
inlinenoexcept

◆ load_library()

IPluginComponentInfo * openswmm::PluginFactory::load_library ( const std::string &  path,
std::function< void(const std::string &)>  warn_cb = {} 
)

Load a single shared library and register it in the component registry.

Parameters
pathPath to the shared library.
warn_cbOptional warning callback.
Returns
Pointer to the IPluginComponentInfo, or nullptr on failure.
Here is the call graph for this function:
Here is the caller 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 plugins from a list of specs (from [PLUGINS] section).

For each spec, resolves spec.path via find_component(), then creates plugin instances based on plugin_type.

Parameters
specsPlugin specs (path + init_args).
warn_cbOptional warning callback.
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

◆ plugin_count()

int openswmm::PluginFactory::plugin_count ( ) const
inlinenoexcept
Here is the caller graph for this function:

◆ prepare_all()

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

◆ report_plugins()

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

◆ state_io_plugins()

const std::vector< IStateIOPlugin * > & openswmm::PluginFactory::state_io_plugins ( ) const
inlinenoexcept

◆ unload_all()

void openswmm::PluginFactory::unload_all ( )
Here is the caller graph for this function:

◆ update_all()

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

◆ validate_all()

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

◆ write_summary_all()

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

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