Manages plugin discovery, loading, and lifecycle for one engine instance.
More...
#include <PluginFactory.hpp>
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.
◆ 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.
◆ ~PluginFactory()
| openswmm::PluginFactory::~PluginFactory |
( |
| ) |
|
◆ PluginFactory() [2/3]
◆ PluginFactory() [3/3]
◆ 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_cb | Optional callback for per-library load warnings. |
◆ discovered_components()
◆ empty()
| bool openswmm::PluginFactory::empty |
( |
| ) |
const |
|
inlinenoexcept |
◆ finalize_all()
◆ 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:
- If the string looks like a file path (contains '/' or '\', or ends in .so/.dylib/.dll), load it directly.
- 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_path | File path or "id" or "id:version" string. |
| warn_cb | Optional warning callback. |
- Returns
- Pointer to IPluginComponentInfo, or nullptr if not found.
◆ initialize_all()
◆ 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
-
| path | Path to the shared library. |
| warn_cb | Optional warning callback. |
- Returns
- Pointer to the IPluginComponentInfo, or nullptr on failure.
◆ 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
-
| specs | Plugin specs (path + init_args). |
| warn_cb | Optional warning callback. |
- Returns
- Number of successfully loaded plugins.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ output_plugins()
| const std::vector< IOutputPlugin * > & openswmm::PluginFactory::output_plugins |
( |
| ) |
const |
|
inlinenoexcept |
◆ plugin_count()
| int openswmm::PluginFactory::plugin_count |
( |
| ) |
const |
|
inlinenoexcept |
◆ prepare_all()
◆ 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 |
( |
| ) |
|
◆ update_all()
◆ validate_all()
◆ write_summary_all()
The documentation for this class was generated from the following files:
- /home/runner/work/openswmm.engine/openswmm.engine/src/engine/plugins/PluginFactory.hpp
- /home/runner/work/openswmm.engine/openswmm.engine/src/engine/plugins/PluginFactory.cpp