Stochastic Loading Module
Classes | Public Member Functions | Static Public Member Functions | List of all members
Factory< Tbaseclass, Targs > Class Template Reference

#include <factory.h>

Public Member Functions

template<typename Tderivedclass >
void register_factory (const std::string &key)
 
std::shared_ptr< Tbaseclass > create (const std::string &key, Targs &&...args)
 
bool check (const std::string &key) const
 
std::vector< std::string > list () const
 

Static Public Member Functions

static Factoryinstance ()
 

Detailed Description

template<typename Tbaseclass, typename... Targs>
class Factory< Tbaseclass, Targs >

Singleton factory implementation

Template Parameters
TbaseclassBase class
Targsvariadic template arguments

Definition at line 44 of file factory.h.

Member Function Documentation

template<typename Tbaseclass , typename... Targs>
bool Factory< Tbaseclass, Targs >::check ( const std::string &  key) const
inline

Check if an element is registered

Parameters
[in]keyKey to be checked in registry
Returns
status Return if key is in registry or not

Definition at line 82 of file factory.h.

template<typename Tbaseclass , typename... Targs>
std::shared_ptr<Tbaseclass> Factory< Tbaseclass, Targs >::create ( const std::string &  key,
Targs &&...  args 
)
inline

Create an instance of a registered class

Parameters
[in]keyKey to item in registry
[in]argsVariadic template arguments
Returns
shared_ptr<Tbaseclass> Shared pointer to a base class

Definition at line 70 of file factory.h.

template<typename Tbaseclass , typename... Targs>
static Factory* Factory< Tbaseclass, Targs >::instance ( )
inlinestatic

Get the single instance of the factory

Definition at line 49 of file factory.h.

template<typename Tbaseclass , typename... Targs>
std::vector<std::string> Factory< Tbaseclass, Targs >::list ( ) const
inline

List registered elements

Returns
factory_items Return list of items in the registry

Definition at line 93 of file factory.h.

template<typename Tbaseclass , typename... Targs>
template<typename Tderivedclass >
void Factory< Tbaseclass, Targs >::register_factory ( const std::string &  key)
inline

Register a factory function to create an instance of classname

Parameters
[in]keyRegister key
Template Parameters
TderivedclassDerived class

Definition at line 60 of file factory.h.


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