Manager for a loaded plugin shared library.
More...
#include <dfx-plugins/Plugin.hpp>
|
| | Plugin ()=default |
| | Default constructor for an uninitialized plugin.
|
| | Plugin (fs::path path) |
| | Constructs a plugin object associated with a specific file path.
|
| | ~Plugin () |
| | Destructor. Calls the plugin's deinit function (dfx_deinit_plugin) if it exists and unloads the shared library.
|
|
| DFX_DISABLE_COPY_AND_MOVE (Plugin) |
| void | loadAndInitPlugin (dfx_registration_api_t const ®, std::string const &pluginConfig, fs::path const &basePath, SharedLibrary::LoadFlags loadFlags=SharedLibrary::defaultLoadFlags) |
| | Loads the shared library into memory and initializes the plugin.
|
| dfx_env_api_t & | pluginEnv () noexcept |
| | Access the environment API structure provided to this plugin.
|
| dfx_env_api_t const & | pluginEnv () const noexcept |
| | Access the environment API structure provided to this plugin.
|
| fs::path const & | pluginPath () const noexcept |
| | Access the filesystem path to the plugin binary.
|
| SharedLibraryPtr const & | lib () const noexcept |
| | Access the pointer to the underlying shared library wrapper.
|
| nlohmann::json const & | metadata () const noexcept |
| | Access the metadata JSON extracted from the plugin's .dfx_metadata section.
|
| std::string | name () const |
| | Access the human-readable name of the plugin from metadata.
|
| std::string | version () const |
| | Access the version string of the plugin from metadata.
|
| std::vector< std::string > const & | registeredTransportScheme () const noexcept |
| | Access the list of transport schemes (e.g., "udp") registered by this plugin.
|
| std::vector< std::string > const & | registeredNodeType () const noexcept |
| | Access the list of node types (e.g., "camera_input") registered by this plugin.
|
|
| static nlohmann::json | readMetadataOfPluginAt (fs::path const &path) |
| | Static helper to read metadata from a binary without fully loading it.
|
|
| static nlohmann::json const | pluginMetadataSchema |
| | JSON schema used to validate plugin metadata blobs.
|
Manager for a loaded plugin shared library.
This class handles the low-level mechanics of loading a shared library (.so/.dll), extracting its metadata, and executing its dfx_init_plugin entry point.
It maintains the dfx_env_api_t provided to the plugin and tracks which node types and transport schemes the plugin has successfully registered.
- Note
- Copy/Move restricted: This class passes its this pointer to the C-ABI as context; therefore, it cannot be copied or moved to ensure pointer stability.
◆ Plugin() [1/2]
| dfx::Plugins::Plugin::Plugin |
( |
| ) |
|
|
explicitdefault |
Default constructor for an uninitialized plugin.
◆ Plugin() [2/2]
| dfx::Plugins::Plugin::Plugin |
( |
fs::path | path | ) |
|
|
explicit |
Constructs a plugin object associated with a specific file path.
The constructor doesn't load nor call any function from the file at the specified location. It only check and load its JSON metadata.
- Parameters
-
| path | Path to the shared library file. |
- See also
- loadAndInitPlugin
◆ ~Plugin()
| dfx::Plugins::Plugin::~Plugin |
( |
| ) |
|
Destructor. Calls the plugin's deinit function (dfx_deinit_plugin) if it exists and unloads the shared library.
◆ lib()
Access the pointer to the underlying shared library wrapper.
◆ loadAndInitPlugin()
Loads the shared library into memory and initializes the plugin.
Performs the following steps:
- Loads the binary using the specified
loadFlags.
- Locates the dfx_init_plugin symbol.
- Invokes the initialization function with the provided registration context.
- Parameters
-
| reg | The host-side registration API. |
| pluginConfig | Plugin specific configuration. |
| basePath | The path that will be used as the root dir when resolving relative path. |
| loadFlags | OS-specific flags for library loading (e.g., RTLD_NOW). |
◆ metadata()
| nlohmann::json const & dfx::Plugins::Plugin::metadata |
( |
| ) |
const |
|
inlinenoexcept |
Access the metadata JSON extracted from the plugin's .dfx_metadata section.
◆ name()
| std::string dfx::Plugins::Plugin::name |
( |
| ) |
const |
|
inline |
Access the human-readable name of the plugin from metadata.
◆ pluginEnv() [1/2]
Access the environment API structure provided to this plugin.
◆ pluginEnv() [2/2]
Access the environment API structure provided to this plugin.
◆ pluginPath()
| fs::path const & dfx::Plugins::Plugin::pluginPath |
( |
| ) |
const |
|
inlinenoexcept |
Access the filesystem path to the plugin binary.
◆ readMetadataOfPluginAt()
| nlohmann::json dfx::Plugins::Plugin::readMetadataOfPluginAt |
( |
fs::path const & | path | ) |
|
|
static |
Static helper to read metadata from a binary without fully loading it.
- Parameters
-
| path | Path to the shared library. |
- Returns
- The parsed JSON metadata.
◆ registeredNodeType()
| std::vector< std::string > const & dfx::Plugins::Plugin::registeredNodeType |
( |
| ) |
const |
|
inlinenoexcept |
Access the list of node types (e.g., "camera_input") registered by this plugin.
◆ registeredTransportScheme()
| std::vector< std::string > const & dfx::Plugins::Plugin::registeredTransportScheme |
( |
| ) |
const |
|
inlinenoexcept |
Access the list of transport schemes (e.g., "udp") registered by this plugin.
◆ version()
| std::string dfx::Plugins::Plugin::version |
( |
| ) |
const |
|
inline |
Access the version string of the plugin from metadata.
◆ pluginMetadataSchema
| nlohmann::json const dfx::Plugins::Plugin::pluginMetadataSchema |
|
static |
JSON schema used to validate plugin metadata blobs.
The documentation for this class was generated from the following file: