Corrade/PluginManager/AbstractManager.h file

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

Contents

Namespaces

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

Classes

class Corrade::PluginManager::AbstractManager
Non-templated base for plugin managers.

Defines

#define CORRADE_PLUGIN_IMPORT(name)
Import 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 static plugin.

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

If static plugins are compiled into dynamic library or directly into the executable, they should be automatically loaded at startup thanks to CORRADE_AUTOMATIC_INITIALIZER() and CORRADE_AUTOMATIC_FINALIZER() macros.

If static plugins are compiled into static library, they are not automatically loaded at startup, so you need to load them explicitly by calling CORRADE_PLUGIN_IMPORT() at the beginning of main() function. You can also wrap these macro calls into another function (which will then be compiled into dynamic library or main executable) and use CORRADE_AUTOMATIC_INITIALIZER() macro for automatic call:

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

#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 with CORRADE_PLUGIN_INTERFACE() in plugin base 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.