Alsvinn  0.5.3
The fast FVM simulator with UQ support
Public Types | Public Member Functions | Static Public Member Functions | List of all members
alsutils::base::impl::FactoryRegistry< T, Args > Class Template Reference

#include <alsutils/base/impl/FactoryRegistry.hpp>

Public Types

typedef std::shared_ptr< T > PointerType
 
typedef std::function< PointerType(Args...)> CreatorType
 

Public Member Functions

bool registerClass (const std::string &name, CreatorType creator)
 
template<class C >
bool registerClassWithOnlyConstructor (const std::string &name)
 
PointerType createInstance (const std::string &name, Args... args)
 Creates a new instance of the class with the given name and arguments. More...
 

Static Public Member Functions

static FactoryRegistrygetInstance ()
 Gets the singleton instance of this class. More...
 

Detailed Description

template<class T, class ... Args>
class alsutils::base::impl::FactoryRegistry< T, Args >

T is any class that has the method

static std::string getClassName() {
// should return the class name
}
Note
this class is a singleton.

Member Typedef Documentation

◆ CreatorType

template<class T, class ... Args>
typedef std::function<PointerType(Args...)> alsutils::base::impl::FactoryRegistry< T, Args >::CreatorType

◆ PointerType

template<class T, class ... Args>
typedef std::shared_ptr<T> alsutils::base::impl::FactoryRegistry< T, Args >::PointerType

Member Function Documentation

◆ createInstance()

template<class T, class ... Args>
PointerType alsutils::base::impl::FactoryRegistry< T, Args >::createInstance ( const std::string &  name,
Args...  args 
)
inline

Creates a new instance of the class with the given name and arguments.

◆ getInstance()

template<class T, class ... Args>
static FactoryRegistry& alsutils::base::impl::FactoryRegistry< T, Args >::getInstance ( )
inlinestatic

Gets the singleton instance of this class.

◆ registerClass()

template<class T, class ... Args>
bool alsutils::base::impl::FactoryRegistry< T, Args >::registerClass ( const std::string &  name,
CreatorType  creator 
)
inline

Registers a new class to the registry.

Parameters
namethe name of the class
creatorthe creator/constructor

◆ registerClassWithOnlyConstructor()

template<class T, class ... Args>
template<class C >
bool alsutils::base::impl::FactoryRegistry< T, Args >::registerClassWithOnlyConstructor ( const std::string &  name)
inline

Registers a new class to the registry, in this case, we assume the class has a constructor that takes all the default arguments

Parameters
namethe name of the class

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