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

Thread-safe catalog of plugins derived from the same base class. More...

#include <PluginCatalog.hh>

+ Collaboration diagram for plugin::PluginCatalog< Base >:

Public Types

using key_type = std::string
 
using mapped_type = Creator< Base >
 
using container_type = std::map< key_type, mapped_type, std::less< key_type > >
 

Public Member Functions

 PluginCatalog ()=default
 
 PluginCatalog (PluginCatalog const &other)
 
 PluginCatalog (PluginCatalog &&other) noexcept
 
 ~PluginCatalog ()=default
 
PluginCatalogoperator= (PluginCatalog const &other)
 
PluginCatalogoperator= (PluginCatalog &&other) noexcept
 
void insert (key_type const &key, mapped_type const &creator)
 
void erase (key_type const &key)
 
std::unique_ptr< Base > create (key_type const &key)
 Create a plugin with the default (parameterless) constructor. More...
 
std::unique_ptr< Base > create (key_type const &key, std::any const &config)
 Create a plugin with a type-erased config argument. More...
 
bool contains (key_type const &key) const
 
bool empty () const
 
std::size_t size () const
 
std::vector< std::string > names (bool includeAliases=false) const
 

Private Attributes

container_type entries_
 
std::shared_mutex mutex_
 

Detailed Description

template<class Base>
class plugin::PluginCatalog< Base >

Thread-safe catalog of plugins derived from the same base class.

Supports both parameterless and config-based plugin creation.

Template Parameters
BaseThe base class of the plugin hierarchy

Member Typedef Documentation

◆ key_type

template<class Base >
using plugin::PluginCatalog< Base >::key_type = std::string

◆ mapped_type

template<class Base >
using plugin::PluginCatalog< Base >::mapped_type = Creator< Base >

◆ container_type

template<class Base >
using plugin::PluginCatalog< Base >::container_type = std::map< key_type, mapped_type, std::less< key_type > >

Constructor & Destructor Documentation

◆ PluginCatalog() [1/3]

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

◆ PluginCatalog() [2/3]

template<class Base >
plugin::PluginCatalog< Base >::PluginCatalog ( PluginCatalog< Base > const &  other)
inline

◆ PluginCatalog() [3/3]

template<class Base >
plugin::PluginCatalog< Base >::PluginCatalog ( PluginCatalog< Base > &&  other)
inlinenoexcept

◆ ~PluginCatalog()

template<class Base >
plugin::PluginCatalog< Base >::~PluginCatalog ( )
default

Member Function Documentation

◆ operator=() [1/2]

template<class Base >
PluginCatalog& plugin::PluginCatalog< Base >::operator= ( PluginCatalog< Base > const &  other)
inline

◆ operator=() [2/2]

template<class Base >
PluginCatalog& plugin::PluginCatalog< Base >::operator= ( PluginCatalog< Base > &&  other)
inlinenoexcept

◆ insert()

template<class Base >
void plugin::PluginCatalog< Base >::insert ( key_type const &  key,
mapped_type const &  creator 
)
inline

◆ erase()

template<class Base >
void plugin::PluginCatalog< Base >::erase ( key_type const &  key)
inline

◆ create() [1/2]

template<class Base >
std::unique_ptr< Base > plugin::PluginCatalog< Base >::create ( key_type const &  key)
inline

Create a plugin with the default (parameterless) constructor.

◆ create() [2/2]

template<class Base >
std::unique_ptr< Base > plugin::PluginCatalog< Base >::create ( key_type const &  key,
std::any const &  config 
)
inline

Create a plugin with a type-erased config argument.

Exceptions
std::runtime_errorif the plugin has no config factory
std::bad_any_castif Config type doesn't match registration

◆ contains()

template<class Base >
bool plugin::PluginCatalog< Base >::contains ( key_type const &  key) const
inline

◆ empty()

template<class Base >
bool plugin::PluginCatalog< Base >::empty ( ) const
inline

◆ size()

template<class Base >
std::size_t plugin::PluginCatalog< Base >::size ( ) const
inline

◆ names()

template<class Base >
std::vector< std::string > plugin::PluginCatalog< Base >::names ( bool  includeAliases = false) const
inline

Member Data Documentation

◆ entries_

◆ mutex_

template<class Base >
std::shared_mutex plugin::PluginCatalog< Base >::mutex_
mutableprivate

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