plugin  2.1.3
Runtime plugin loader and Ed25519 DSO signing for C++ applications
plugin::Plugin< Base > Class Template Reference

Base class template for the plugin system. More...

#include <Plugin.hh>

Public Types

using key_type = typename PluginCatalog< Base >::key_type
 

Public Member Functions

 Plugin ()=default
 
 Plugin (Plugin< Base > const &)=default
 
 Plugin (Plugin< Base > &&)=default
 
Plugin< Base > & operator= (Plugin< Base > const &)=default
 
Plugin< Base > & operator= (Plugin< Base > &&)=default
 
virtual ~Plugin ()=default
 

Static Public Member Functions

static std::unique_ptr< Base > create (key_type const &key)
 Create a plugin instance using the default constructor. More...
 
template<typename Config >
static std::unique_ptr< Base > create (key_type const &key, Config const &config)
 Create a plugin instance with a config object. More...
 
static void load (std::string const &sharedObjectName)
 
static PluginCatalog< Base > & catalog ()
 

Detailed Description

template<class Base>
class plugin::Plugin< Base >

Base class template for the plugin system.

Provides two create() overloads:

  • create(key) — parameterless, backward compatible
  • create(key, config) — config-based, type-safe via std::any

Usage: auto shape = Shape::create("Circle"); // default ctor auto shape2 = Shape::create("Circle", Circle::Config{5}); // with config

Template Parameters
BaseThe concrete base class of the plugin hierarchy

Member Typedef Documentation

◆ key_type

template<class Base >
using plugin::Plugin< Base >::key_type = typename PluginCatalog< Base >::key_type

Constructor & Destructor Documentation

◆ Plugin() [1/3]

template<class Base >
plugin::Plugin< Base >::Plugin ( )
default

◆ Plugin() [2/3]

template<class Base >
plugin::Plugin< Base >::Plugin ( Plugin< Base > const &  )
default

◆ Plugin() [3/3]

template<class Base >
plugin::Plugin< Base >::Plugin ( Plugin< Base > &&  )
default

◆ ~Plugin()

template<class Base >
virtual plugin::Plugin< Base >::~Plugin ( )
virtualdefault

Member Function Documentation

◆ operator=() [1/2]

template<class Base >
Plugin< Base >& plugin::Plugin< Base >::operator= ( Plugin< Base > const &  )
default

◆ operator=() [2/2]

template<class Base >
Plugin< Base >& plugin::Plugin< Base >::operator= ( Plugin< Base > &&  )
default

◆ create() [1/2]

template<class Base >
static std::unique_ptr< Base > plugin::Plugin< Base >::create ( key_type const &  key)
inlinestatic

Create a plugin instance using the default constructor.

◆ create() [2/2]

template<class Base >
template<typename Config >
static std::unique_ptr< Base > plugin::Plugin< Base >::create ( key_type const &  key,
Config const &  config 
)
inlinestatic

Create a plugin instance with a config object.

The Config type is automatically wrapped in std::any. It must match the type registered via REGISTER_WITH_CONFIG.

Template Parameters
ConfigThe concrete config struct (deduced)
Parameters
keyRegistered plugin name
configConfig object forwarded to the plugin constructor
Exceptions
std::runtime_errorif the plugin has no config factory
std::bad_any_castif Config doesn't match registration

◆ load()

template<class Base >
static void plugin::Plugin< Base >::load ( std::string const &  sharedObjectName)
inlinestatic

References fedem::dso::DSOLoader::load().

+ Here is the call graph for this function:

◆ catalog()

template<class Base >
static PluginCatalog< Base >& plugin::Plugin< Base >::catalog ( )
static

The documentation for this class was generated from the following file: