Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Feel::Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy > Class Template Reference

#include <factory.hpp>

Detailed Description

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

Implements a generic object Factory.

See Also
FactoryDefaultError, FactoryClone, TypeInfo
Author
Christophe Prud'homme

Inherits FactoryErrorPolicy< IdentifierType, AbstractProduct >.

Public Types

Typedefs
typedef IdentifierType identifier_type
 
typedef AbstractProduct product_type
 
typedef ProductCreator creator_type
 
typedef FactoryErrorPolicy
< identifier_type,
product_type > 
super
 

Public Member Functions

Methods
bool registerProduct (const identifier_type &id, creator_type creator)
 
bool unregisterProduct (const identifier_type &id)
 
product_type * createObject (const identifier_type &id)
 

Member Function Documentation

template<class AbstractProduct , typename IdentifierType , typename ProductCreator = boost::function<AbstractProduct*()>, template< typename, class > class FactoryErrorPolicy = FactoryDefaultError>
product_type* Feel::Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy >::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
template<class AbstractProduct , typename IdentifierType , typename ProductCreator = boost::function<AbstractProduct*()>, template< typename, class > class FactoryErrorPolicy = FactoryDefaultError>
bool Feel::Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy >::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
template<class AbstractProduct , typename IdentifierType , typename ProductCreator = boost::function<AbstractProduct*()>, template< typename, class > class FactoryErrorPolicy = FactoryDefaultError>
bool Feel::Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy >::unregisterProduct ( const identifier_type &  id)
inline

Unregister a product

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

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

Generated on Fri Oct 25 2013 14:24:29 for Feel++ by doxygen 1.8.4