namespace plugin {
template< class Base >
class Plugin;
}
Defined in <plugin/Plugin.hh>.
Plugin<Base> is the base every plugin hierarchy derives from, passing itself as Base (CRTP):
class Shape : public plugin::Plugin<Shape> { /* ... */ };
It contributes a small static interface bound to Base and nothing else — no data members, a defaulted copy/move, and a virtual destructor so derived objects delete correctly through a Base*.
Member type
| Type | Definition |
|---|---|
key_type | typename PluginCatalog<Base>::key_type — i.e. std::string |
Static member functions
| Function | Page |
|---|---|
create( key ) | Plugin::create |
create( key, config ) | Plugin::create |
load( sharedObjectName ) | Plugin::load, ::catalog |
catalog() | Plugin::load, ::catalog |
Special members
Plugin(), copy ctor, move ctor, copy assignment, move assignment are all = default. ~Plugin() is virtual and defaulted. There is no state to copy; the defaults exist so a derived class can = default its own.
The CATALOG macro
#define CATALOG( BASE ) plugin::Plugin< BASE >::catalog( )
A shorthand for reaching the catalog directly — e.g. CATALOG(Shape).size(). Equivalent to plugin::Plugin<Shape>::catalog() and to Shape::catalog() (inherited).
Example
// Shape.hh
#include <plugin/Plugin.hh>
class Shape : public plugin::Plugin<Shape>
{
public:
virtual void printOn( std::ostream& ) const = 0;
};
// somewhere in the host
Shape::load( "./libCircle.so" );
auto s = Shape::create( "Circle" );
Notes
Plugin<Base>declarescatalog()but does not define it. Exactly one translation unit must provide the definition withCREATECATALOG(Base), or the link fails with an undefined reference toPlugin<Base>::catalog().createandloadare ordinary static functions — call them asShape::create(...)orplugin::Plugin<Shape>::create(...).PLUGIN_EXPORTon the class controls symbol visibility; it expands to the platform's default-visibility attribute (<dso/DSOVisibility.hh>).

