OpenAssetIO
An abstract API for generalising interactions between a host application and an asset management system
|
Generic plugin system for C++ plugins. More...
#include <CppPluginSystem.hpp>
Public Types | |
using | Ptr = CppPluginSystemPtr |
using | ConstPtr = CppPluginSystemConstPtr |
using | PathAndPlugin = std::pair< std::filesystem::path, CppPluginSystemPluginPtr > |
Pair of absolute path to plugin and shared_ptr to plugin instance. More... | |
Public Member Functions | |
void | reset () |
Clear any previously loaded plugins. More... | |
void | scan (std::string_view paths) |
Searches the supplied paths for plugin modules. More... | |
openassetio::Identifiers | identifiers () const |
Returns the identifiers known to the plugin system. More... | |
const PathAndPlugin & | plugin (const openassetio::Identifier &identifier) const |
Retrieves the plugin that provides the given identifier. More... | |
Static Public Member Functions | |
static CppPluginSystemPtr | make (log::LoggerInterfacePtr logger) |
Constructs a new CppPluginSystem. More... | |
Generic plugin system for C++ plugins.
The API broadly mirrors the PythonPluginSystem.
using ConstPtr = CppPluginSystemConstPtr |
using PathAndPlugin = std::pair<std::filesystem::path, CppPluginSystemPluginPtr> |
Pair of absolute path to plugin and shared_ptr to plugin instance.
using Ptr = CppPluginSystemPtr |
openassetio::Identifiers identifiers | ( | ) | const |
Returns the identifiers known to the plugin system.
If scan has not been called, then this will be empty.
|
static |
Constructs a new CppPluginSystem.
logger | Logger used to log progress and warnings. Note that most logs are at debug severity. |
const PathAndPlugin& plugin | ( | const openassetio::Identifier & | identifier | ) | const |
Retrieves the plugin that provides the given identifier.
identifier | Identifier to look up. |
errors.InputValidationException | Raised if no plugin provides the specified identifier. |
void reset | ( | ) |
Clear any previously loaded plugins.
Note this does not unload/unlink any previously loaded binary shared libraries from the application.
void scan | ( | std::string_view | paths | ) |
Searches the supplied paths for plugin modules.
Paths are searched left-to-right, but only the first instance of any given plugin identifier will be used, and subsequent registrations ignored. This means entries to the left of the paths list take precedence over ones to the right.
Each given directory is scanned for shared libraries that expose an openassetioPlugin
entry point function (with C linkage), which is expected to return a PluginFactory function pointer, which when called returns an instantiated (subclass of) CppPluginSystemPlugin.
Discovered plugins are registered by their exposed identifier, and subsequent registrations with the same identifier will be skipped.
No attempt is made to catch exceptions during static initialisation or during the call to the provided PluginFactory, and any such exception will almost definitely terminate the process.
paths | A list of paths to search, delimited by operating system specific path separator (i.e. : for POSIX, ; for Windows). |
Copyright 2013-2023 The Foundry Visionmongers Ltd. OpenAssetIO is released under the Apache 2.0 License