Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId > Class Template Reference

Generic Factory implementation. More...

#include <factory.hh>

List of all members.

Public Member Functions

bool add (id_param id, creator_param creator)
 Add a new production method.
bool check_entry (id_param id) const
 Check for entry.
Result create (id_param id)
 Creation method.
ProductCreator const & get_creator (id_param id) const
 Creation method access.
bool make_alias (id_param from, id_param to)
 Alias creation.
bool remove (id_param id)
 Remove a production method.

Private Types

typedef arg_traits
< ProductCreator >::type 
creator_param
typedef std::map
< IdentifierType,
ProductCreator, OrderId > 
factory_db
typedef arg_traits
< IdentifierType >::type 
id_param

Private Member Functions

 factory ()
 ~factory ()

Private Attributes

factory_db associations

Friends

class singleton::wrapper

Detailed Description

template<class AbstractProduct, typename IdentifierType, typename Result, typename ProductCreator, template< typename, class, typename > class FactoryErrorPolicy, class OrderId>
class utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >

Generic Factory implementation.

This class offers a generic implementation of thze factory design pattern.

A factory is a producer of classes of a special base type. The production will depend on the request.

Parameters:
AbstractProductBase type for the produced instances.
IdentifierTypeType of the production method identifiers.
ResultType of the result (AbstractProduct*).
ProductCreatorType of the creation methods (Result(*)()).
FactoryErrorPolicyError management policy (utilmm::factory_toolbox::error)
OrderIdAn order between IdentifierType (std::less<IdentifierType>)
Note:
this class is a singleton
See also:
utilmm::singleton::use
Author:
Frédéric Py <fpy@laas.fr>

Definition at line 46 of file factory.hh.


Member Typedef Documentation

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
typedef arg_traits<ProductCreator>::type utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::creator_param [private]

Definition at line 51 of file factory.hh.

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
typedef std::map<IdentifierType, ProductCreator, OrderId> utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::factory_db [private]

Definition at line 53 of file factory.hh.

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
typedef arg_traits<IdentifierType>::type utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::id_param [private]

Definition at line 50 of file factory.hh.


Constructor & Destructor Documentation

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::factory ( ) [inline, private]

Definition at line 158 of file factory.hh.

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::~factory ( ) [inline, private]

Definition at line 159 of file factory.hh.


Member Function Documentation

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
bool utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::add ( id_param  id,
creator_param  creator 
) [inline]

Add a new production method.

This method add a new production method to the factory.

Parameters:
idIdentifier for the production method
creatorProduction method.
Return values:
trueif the new creation method was added
falseif there was already a creation method with id

After this operation client can request for product having id as identifeir

Definition at line 70 of file factory.hh.

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
bool utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::check_entry ( id_param  id) const [inline]

Check for entry.

Parameters:
idan identifer

This function test if there's a creation method attched to id

Return values:
trueIf thered's a creation method attched to id
falseelse

Definition at line 133 of file factory.hh.

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
Result utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::create ( id_param  id) [inline]

Creation method.

Parameters:
idan identifer

Create a new product using the cration method attched to id

Returns:
The created product
Note:
If there's no creation method attched to id this function will call FactoryErrorPolicy::on_unknown_id

Definition at line 116 of file factory.hh.

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
ProductCreator const& utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::get_creator ( id_param  id) const [inline]

Creation method access.

Parameters:
idAn identifier

This function get the creation mathod attched to id

Returns:
A creation method
Note:
In case there's no crezation method attached to id this function will call FactoryErrorPolicy::on_unknown_type

Definition at line 148 of file factory.hh.

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
bool utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::make_alias ( id_param  from,
id_param  to 
) [inline]

Alias creation.

Make an alias identifer for a creation method

Parameters:
fromThe alias identifier
toan identifer

This method will try to create an alias to cration method named to

Return values:
trueif the alias was created
falseelse

Definition at line 100 of file factory.hh.

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
bool utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::remove ( id_param  id) [inline]

Remove a production method.

This method allow user to remove a creation method from the factory

Parameters:
idThe identifier of the creation method to remove
Return values:
trueif the creation method was removed.
falseif there was no creation method attached to id

Definition at line 84 of file factory.hh.


Friends And Related Function Documentation

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
friend class singleton::wrapper [friend]

Definition at line 162 of file factory.hh.


Member Data Documentation

template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
factory_db utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::associations [private]

Definition at line 55 of file factory.hh.


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


utilmm
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Thu Jan 2 2014 11:38:31