LifeV
Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy > Class Template Reference

#include <Factory.hpp>

+ Inheritance diagram for Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy >:
+ Collaboration diagram for Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy >:

Private Attributes

productId_Type M_associations
 

Public Typedefs

typedef IdentifierType identifier_Type
 
typedef AbstractProduct product_Type
 
typedef ProductCreator creator_Type
 
typedef FactoryErrorPolicy< product_Typesuper
 

Constructor and destructor

 Factory ()
 
virtual ~Factory ()
 

Methods

bool registerProduct (const identifier_Type &id, creator_Type creator)
 Register a product. More...
 
bool unregisterProduct (const identifier_Type &id)
 Unregister a product. More...
 
product_TypecreateObject (const identifier_Type &id)
 Create an object from a product registered in the factory using identifier id. More...
 
template<typename map_Type >
product_TypecreateObject (const identifier_Type &id, const map_Type &map)
 Create an object from a product registered in the factory using identifier id (of type enum) and a map to catch the exception. More...
 

Private typedefs

typedef std::map< identifier_Type, creator_TypeproductId_Type
 

Detailed Description

template<class AbstractProduct, typename IdentifierType, typename ProductCreator = std::function<AbstractProduct*() >, template< class > class FactoryErrorPolicy = FactoryDefaultError>
class LifeV::Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy >

Definition at line 112 of file Factory.hpp.

Member Typedef Documentation

◆ identifier_Type

typedef IdentifierType identifier_Type

Definition at line 118 of file Factory.hpp.

◆ product_Type

typedef AbstractProduct product_Type

Definition at line 119 of file Factory.hpp.

◆ creator_Type

typedef ProductCreator creator_Type

Definition at line 120 of file Factory.hpp.

◆ super

Definition at line 121 of file Factory.hpp.

◆ productId_Type

typedef std::map<identifier_Type, creator_Type> productId_Type
private

Definition at line 231 of file Factory.hpp.

Constructor & Destructor Documentation

◆ Factory()

Factory ( )
inline

Definition at line 129 of file Factory.hpp.

◆ ~Factory()

virtual ~Factory ( )
inlinevirtual

Definition at line 131 of file Factory.hpp.

Member Function Documentation

◆ registerProduct()

bool registerProduct ( const identifier_Type id,
creator_Type  creator 
)
inline

Register a product.

A product is composed of an identifier (typically a std::string) and a functor that will create the associated object.

Parameters
ididentifier for the object to be registered
creatorthe functor that will create the registered object
Returns
true if registration went fine, false otherwise

Definition at line 152 of file Factory.hpp.

◆ unregisterProduct()

bool unregisterProduct ( const identifier_Type id)
inline

Unregister a product.

Parameters
id
See also
registerProduct
Returns
true if unregistration went fine, false otherwise

Definition at line 167 of file Factory.hpp.

◆ createObject() [1/2]

product_Type* createObject ( const identifier_Type id)
inline

Create an object from a product registered in the factory using identifier id.

Parameters
ididentifier of the product to instantiate
Returns
the object associate with id

Definition at line 183 of file Factory.hpp.

◆ createObject() [2/2]

product_Type* createObject ( const identifier_Type id,
const map_Type &  map 
)
inline

Create an object from a product registered in the factory using identifier id (of type enum) and a map to catch the exception.

Parameters
ididentifier of the product to instantiate
Returns
the object associate with id

Definition at line 208 of file Factory.hpp.

Field Documentation

◆ M_associations

productId_Type M_associations
private

Definition at line 235 of file Factory.hpp.


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