Defined in <plugin/PluginRegister.hh>.
Registration is done by a file-scope object whose constructor adds an entry to the catalog and whose destructor removes it. Two class templates provide the behaviour; four families of macros generate the objects.
The class templates
template< class T, class Base > class PluginRegisterer;
template< class T, class Base, class Config > class PluginRegistererWithConfig;
| Inserts | Static factory helpers | |
|---|---|---|
PluginRegisterer<T, Base> | Creator<Base>( CreateDefault, copy ) | static Base* CreateDefault() → new T() |
PluginRegistererWithConfig<T, Base, Config> | Creator<Base>( CreateDefault, CreateFromConfig, copy ) | + static Base* CreateFromConfig(std::any const&) → new T( std::any_cast<Config const&>(cfg) ) |
Constructor signature (both):
explicit PluginRegisterer( PluginCatalog<Base>::key_type const& name, bool copy = false );
name is the catalog key. copy becomes the Creator's isAlias flag — true for the alias macros. Move construction and move assignment are = delete; the object is meant to live at file scope for the DSO's lifetime. The destructor calls Base::catalog().erase(key).
The macros
| Macro | Key | Config | Alias | Page |
|---|---|---|---|---|
REGISTER(Class, Base) | "Class" | — | no | REGISTER, REGISTERBYNAME |
REGISTERBYNAME(NAME, Class, Base) | "NAME" | — | no | REGISTER, REGISTERBYNAME |
REGISTER_WITH_CONFIG(Class, Base, Config) | "Class" | Config | no | REGISTERWITHCONFIG |
REGISTERBYNAME_WITH_CONFIG(NAME, Class, Base, Config) | "NAME" | Config | no | REGISTERWITHCONFIG |
REGISTERAS(NAME, Class, Base) | "NAME" | — | yes | REGISTERAS, REGISTERBYNICK |
REGISTERBYNICK(CNAME, Class, Base) | CNAME (expression) | — | yes | REGISTERAS, REGISTERBYNICK |
CREATECATALOG(Base) | — | — | — | CREATECATALOG, CATALOG |
What a macro expands to
#define REGISTER(CLASS, BASE) REGISTERBYNAME(CLASS, CLASS, BASE)
#define REGISTERBYNAME(NAME, CLASS, BASE) \
namespace { \
static const volatile plugin::PluginRegisterer< CLASS, BASE > \
PLUGIN_CONCAT( REGISTERER_##NAME##_, __LINE__ )( #NAME, false ); \
}
- anonymous namespace — internal linkage, no cross-TU collision.
static const volatile—volatilestops the optimiser removing an object it thinks is unused;constdocuments intent.__LINE__suffix — two registrations in one file get distinct names.
Put a registration in the plugin's .cpp, at file scope, once.

