geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
Public Member Functions | List of all members
geopm::PluginFactory< T > Class Template Reference

#include <PluginFactory.hpp>

Public Member Functions

 PluginFactory ()=default
 
virtual ~PluginFactory ()=default
 
 PluginFactory (const PluginFactory &other)=delete
 
PluginFactoryoperator= (const PluginFactory &other)=delete
 
void register_plugin (const std::string &plugin_name, std::function< std::unique_ptr< T >()> make_plugin, const std::map< std::string, std::string > &dictionary=m_empty_dictionary)
 Add a plugin to the factory. More...
 
std::unique_ptr< T > make_plugin (const std::string &plugin_name) const
 Create an object of the requested type. If the type was not registered, throws an exception. More...
 
std::vector< std::string > plugin_names (void) const
 Returns a list of all valid plugin names registered with the factory in the order they were registered. More...
 
const std::map< std::string, std::string > & dictionary (const std::string &plugin_name) const
 Returns the dictionary of static metadata about a registered type. If the type was not registered, throws an exception. More...
 

Constructor & Destructor Documentation

◆ PluginFactory() [1/2]

template<class T >
geopm::PluginFactory< T >::PluginFactory ( )
default

◆ ~PluginFactory()

template<class T >
virtual geopm::PluginFactory< T >::~PluginFactory ( )
virtualdefault

◆ PluginFactory() [2/2]

template<class T >
geopm::PluginFactory< T >::PluginFactory ( const PluginFactory< T > &  other)
delete

Member Function Documentation

◆ dictionary()

template<class T >
const std::map<std::string, std::string>& geopm::PluginFactory< T >::dictionary ( const std::string &  plugin_name) const
inline

Returns the dictionary of static metadata about a registered type. If the type was not registered, throws an exception.

Parameters
[in]plugin_nameName of the registered type.
Returns
Dictionary of metadata.

◆ make_plugin()

template<class T >
std::unique_ptr<T> geopm::PluginFactory< T >::make_plugin ( const std::string &  plugin_name) const
inline

Create an object of the requested type. If the type was not registered, throws an exception.

Parameters
[in]plugin_nameName used to look up the constructor function used to create the object.
Returns
A unique_ptr to the created object. The caller owns the created object.

◆ operator=()

template<class T >
PluginFactory& geopm::PluginFactory< T >::operator= ( const PluginFactory< T > &  other)
delete

◆ plugin_names()

template<class T >
std::vector<std::string> geopm::PluginFactory< T >::plugin_names ( void  ) const
inline

Returns a list of all valid plugin names registered with the factory in the order they were registered.

Returns
List of valid plugin names.

◆ register_plugin()

template<class T >
void geopm::PluginFactory< T >::register_plugin ( const std::string &  plugin_name,
std::function< std::unique_ptr< T >()>  make_plugin,
const std::map< std::string, std::string > &  dictionary = m_empty_dictionary 
)
inline

Add a plugin to the factory.

Parameters
[in]plugin_nameName used to request plugins of the registered type.
[in]make_pluginFunction that returns a new object of the registered type.
[in]dictionaryOptional dictionary of static information about the registered type.

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