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 PathAndPluginplugin (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...
 

Detailed Description

Generic plugin system for C++ plugins.

The API broadly mirrors the PythonPluginSystem.

See also
scan
PluginFactory
CppPluginSystemPlugin

Member Typedef Documentation

using PathAndPlugin = std::pair<std::filesystem::path, CppPluginSystemPluginPtr>

Pair of absolute path to plugin and shared_ptr to plugin instance.

Member Function Documentation

openassetio::Identifiers identifiers ( ) const

Returns the identifiers known to the plugin system.

If scan has not been called, then this will be empty.

static CppPluginSystemPtr make ( log::LoggerInterfacePtr  logger)
static

Constructs a new CppPluginSystem.

Parameters
loggerLogger used to log progress and warnings. Note that most logs are at debug severity.
Returns
Newly constructed CppPluginSystem wrapped in a shared_ptr.
const PathAndPlugin& plugin ( const openassetio::Identifier &  identifier) const

Retrieves the plugin that provides the given identifier.

Parameters
identifierIdentifier to look up.
Returns
A pair of plugin path and instance.
Exceptions
errors.InputValidationExceptionRaised 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.

Note
Precedence order is undefined for plugins sharing the same identifier within the same directory.

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.

Parameters
pathsA list of paths to search, delimited by operating system specific path separator (i.e. : for POSIX, ; for Windows).

The documentation for this class was generated from the following file:
  • /src/src/openassetio-core/include/openassetio/pluginSystem/CppPluginSystem.hpp