Corrade/PluginManager/AbstractManager.h file

Class Corrade::PluginManager::AbstractManager, macro CORRADE_PLUGIN_VERSION, CORRADE_PLUGIN_REGISTER()

Namespaces

namespace Corrade
Root namespace.
namespace Corrade::PluginManager
Plugin management.

Classes

class Corrade::PluginManager::AbstractManager
Base for plugin managers.

Enums

enum class LoadState: unsigned short { NotFound = 1 << 0, WrongPluginVersion = 1 << 1, WrongInterfaceVersion = 1 << 2, WrongMetadataFile = 1 << 3, UnresolvedDependency = 1 << 4, LoadFailed = 1 << 5, Static = 1 << 6, Loaded = (1 << 7) | LoadState::Static, NotLoaded = 1 << 8, UnloadFailed = 1 << 9, Required = 1 << 10, Used = 1 << 11 }
Plugin load state.

Typedefs

using LoadStates = Containers::EnumSet<LoadState>
Plugin load states.

Functions

auto operator<<(Utility::Debug& debug, PluginManager::LoadState value) -> Utility::Debug&
Debug output operator.
auto operator<<(Utility::Debug& debug, PluginManager::LoadStates value) -> Utility::Debug&
Debug output operator.

Defines

#define CORRADE_PLUGIN_IMPORT(name)
Import a static plugin.
#define CORRADE_PLUGIN_EJECT(name)
Eject a previously imported static plugin.
#define CORRADE_PLUGIN_VERSION
Plugin version.
#define CORRADE_PLUGIN_REGISTER(name, className, interface)
Register static or dynamic lugin.

Define documentation

#define CORRADE_PLUGIN_IMPORT(name)

Import a static plugin.

Parameters
name Static plugin name (the same as defined with CORRADE_PLUGIN_REGISTER())

If you link static plugins to your executable, they can't automatically register themselves at startup to be known to PluginManager::Manager, and you need to load them explicitly by calling CORRADE_PLUGIN_IMPORT() at the beginning of the main() function. You can also wrap these macro calls in another function (which will then be compiled into a dynamic library or the main executable) and use the CORRADE_AUTOMATIC_INITIALIZER() macro for an automatic call:

static int corradeZipFilesystemStaticImport() {
    CORRADE_PLUGIN_IMPORT(ZipFilesystem)
    return 1;
} CORRADE_AUTOMATIC_INITIALIZER(corradeZipFilesystemStaticImport)

Functions called by this macro don't do any dynamic allocation or other operations that could fail, so it's safe to call it even in restricted phases of application exection. It's also safe to call this macro more than once.

#define CORRADE_PLUGIN_EJECT(name)

Eject a previously imported static plugin.

Parameters
name Static plugin name (the same as defined with CORRADE_PLUGIN_REGISTER())

Deregisters a plugin previously registered using CORRADE_PLUGIN_IMPORT().

Functions called by this macro don't do any dynamic allocation or other operations that could fail, so it's safe to call it even in restricted phases of application exection. It's also safe to call this macro more than once.

#define CORRADE_PLUGIN_REGISTER(name, className, interface)

Register static or dynamic lugin.

Parameters
name Name of static plugin (equivalent of dynamic plugin filename)
className Plugin class name
interface Interface name (the same as is defined by the pluginInterface() member of given plugin class)

If the plugin is built as static (using CMake command corrade_add_static_plugin()), registers it, so it will be loaded automatically when PluginManager instance with corresponding interface is created. When building as static plugin, CORRADE_STATIC_PLUGIN preprocessor directive is defined.

If the plugin is built as dynamic (using CMake command corrade_add_plugin()), registers it, so it can be dynamically loaded via Corrade::PluginManager::Manager by supplying a name of the plugin. When building as dynamic plugin, CORRADE_DYNAMIC_PLUGIN preprocessor directive is defined.

If the plugin is built as dynamic or static library or executable (not as plugin, using e.g. CMake command add_library() / add_executable()), this macro won't do anything to prevent linker issues when linking more plugins together. No plugin-related preprocessor directive is defined.

See Plugin management for more information about plugin compilation.