|
plugin
2.1.3
Runtime plugin loader and Ed25519 DSO signing for C++ applications
|
Factory class for plugins. More...
#include <PluginCreator.hh>
Public Types | |
| using | DefaultFactory = std::function< Base *() > |
| using | ConfigFactory = std::function< Base *(std::any const &) > |
Public Member Functions | |
| Creator () | |
| Creator (DefaultFactory defaultFn, bool isAlias=false) | |
| Constructor with default factory only (backward compatible). More... | |
| Creator (DefaultFactory defaultFn, ConfigFactory configFn, bool isAlias=false) | |
| Constructor with both default and config factories. More... | |
| Creator (Creator const &)=default | |
| Creator (Creator &&)=default | |
| Creator & | operator= (Creator const &)=default |
| Creator & | operator= (Creator &&)=default |
| ~Creator ()=default | |
| Base * | operator() () |
| Create an instance using the default (parameterless) factory. More... | |
| Base * | operator() (std::any const &config) |
| Create an instance using a type-erased config. The config's actual type must match what was registered; a mismatch will throw std::bad_any_cast. More... | |
| bool | hasConfigFactory () const |
| bool | isAlias () const |
Private Attributes | |
| DefaultFactory | defaultFactory_ |
| ConfigFactory | configFactory_ |
| bool | alias_ = true |
Factory class for plugins.
Stores two factory callables:
The config factory is optional. If not provided, attempting to create with a config argument will throw std::runtime_error.
| Base | The base class of the plugin hierarchy |
| using plugin::Creator< Base >::DefaultFactory = std::function< Base*( ) > |
| using plugin::Creator< Base >::ConfigFactory = std::function< Base*( std::any const& ) > |
|
inline |
|
inline |
Constructor with default factory only (backward compatible).
|
inline |
Constructor with both default and config factories.
|
default |
|
default |
|
default |
|
default |
|
default |
|
inline |
Create an instance using the default (parameterless) factory.
|
inline |
Create an instance using a type-erased config. The config's actual type must match what was registered; a mismatch will throw std::bad_any_cast.
| std::runtime_error | if no config factory was registered |
| std::bad_any_cast | if the config type doesn't match |
|
inline |
|
inline |
|
private |
|
private |
|
private |