Generic Factory implementation. More...
#include <factory.hh>
Public Member Functions | |
| bool | add (id_param id, creator_param creator) |
| Add a new production method. | |
| bool | add (id_param id, creator_param creator) |
| Add a new production method. | |
| bool | check_entry (id_param id) const |
| Check for entry. | |
| bool | check_entry (id_param id) const |
| Check for entry. | |
| Result | create (id_param id) |
| Creation method. | |
| Result | create (id_param id) |
| Creation method. | |
| ProductCreator const & | get_creator (id_param id) const |
| Creation method access. | |
| ProductCreator const & | get_creator (id_param id) const |
| Creation method access. | |
| bool | make_alias (id_param from, id_param to) |
| Alias creation. | |
| bool | make_alias (id_param from, id_param to) |
| Alias creation. | |
| bool | remove (id_param id) |
| Remove a production method. | |
| bool | remove (id_param id) |
| Remove a production method. | |
Private Types | |
| typedef arg_traits < ProductCreator >::type | creator_param |
| typedef arg_traits < ProductCreator >::type | creator_param |
| typedef std::map < IdentifierType, ProductCreator, OrderId > | factory_db |
| typedef std::map < IdentifierType, ProductCreator, OrderId > | factory_db |
| typedef arg_traits < IdentifierType >::type | id_param |
| typedef arg_traits < IdentifierType >::type | id_param |
Private Member Functions | |
| factory () | |
| factory () | |
| ~factory () | |
| ~factory () | |
Private Attributes | |
| factory_db | associations |
Friends | |
| class | singleton::wrapper |
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.
| AbstractProduct | Base type for the produced instances. | |
| IdentifierType | Type of the production method identifiers. | |
| Result | Type of the result (AbstractProduct*). | |
| ProductCreator | Type of the creation methods (Result(*)()). | |
| FactoryErrorPolicy | Error management policy (utilmm::factory_toolbox::error) | |
| OrderId | An order between IdentifierType (std::less<IdentifierType>) |
Definition at line 45 of file install/include/utilmm/types/factory.hh.
typedef arg_traits<ProductCreator>::type utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::creator_param [private] |
Definition at line 51 of file utilmm/types/factory.hh.
typedef arg_traits<ProductCreator>::type utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::creator_param [private] |
Definition at line 18 of file install/include/utilmm/types/factory.hh.
typedef std::map<IdentifierType, ProductCreator, OrderId> utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::factory_db [private] |
Definition at line 53 of file utilmm/types/factory.hh.
typedef std::map<IdentifierType, ProductCreator, OrderId> utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::factory_db [private] |
Definition at line 20 of file install/include/utilmm/types/factory.hh.
typedef arg_traits<IdentifierType>::type utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::id_param [private] |
Definition at line 50 of file utilmm/types/factory.hh.
typedef arg_traits<IdentifierType>::type utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::id_param [private] |
Definition at line 17 of file install/include/utilmm/types/factory.hh.
| utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::factory | ( | ) | [inline, private] |
Definition at line 125 of file install/include/utilmm/types/factory.hh.
| utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::~factory | ( | ) | [inline, private] |
Definition at line 126 of file install/include/utilmm/types/factory.hh.
| utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::factory | ( | ) | [inline, private] |
Definition at line 158 of file utilmm/types/factory.hh.
| utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::~factory | ( | ) | [inline, private] |
Definition at line 159 of file utilmm/types/factory.hh.
| 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.
| id | Identifier for the production method | |
| creator | Production method. |
| true | if the new creation method was added | |
| false | if 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 utilmm/types/factory.hh.
| 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.
| id | Identifier for the production method | |
| creator | Production method. |
| true | if the new creation method was added | |
| false | if there was already a creation method with id |
After this operation client can request for product having id as identifeir
Definition at line 37 of file install/include/utilmm/types/factory.hh.
| bool utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::check_entry | ( | id_param | id | ) | const [inline] |
Check for entry.
| id | an identifer |
This function test if there's a creation method attched to id
| true | If thered's a creation method attched to id | |
| false | else |
Definition at line 133 of file utilmm/types/factory.hh.
| bool utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::check_entry | ( | id_param | id | ) | const [inline] |
Check for entry.
| id | an identifer |
This function test if there's a creation method attched to id
| true | If thered's a creation method attched to id | |
| false | else |
Definition at line 100 of file install/include/utilmm/types/factory.hh.
| Result utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::create | ( | id_param | id | ) | [inline] |
Creation method.
| id | an identifer |
Create a new product using the cration method attched to id
FactoryErrorPolicy::on_unknown_id Definition at line 116 of file utilmm/types/factory.hh.
| Result utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::create | ( | id_param | id | ) | [inline] |
Creation method.
| id | an identifer |
Create a new product using the cration method attched to id
FactoryErrorPolicy::on_unknown_id Definition at line 83 of file install/include/utilmm/types/factory.hh.
| ProductCreator const& utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::get_creator | ( | id_param | id | ) | const [inline] |
Creation method access.
| id | An identifier |
This function get the creation mathod attched to id
FactoryErrorPolicy::on_unknown_type Definition at line 148 of file utilmm/types/factory.hh.
| ProductCreator const& utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::get_creator | ( | id_param | id | ) | const [inline] |
Creation method access.
| id | An identifier |
This function get the creation mathod attched to id
FactoryErrorPolicy::on_unknown_type Definition at line 115 of file install/include/utilmm/types/factory.hh.
| 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
| from | The alias identifier | |
| to | an identifer |
This method will try to create an alias to cration method named to
| true | if the alias was created | |
| false | else |
Definition at line 100 of file utilmm/types/factory.hh.
| 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
| from | The alias identifier | |
| to | an identifer |
This method will try to create an alias to cration method named to
| true | if the alias was created | |
| false | else |
Definition at line 67 of file install/include/utilmm/types/factory.hh.
| 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
| id | The identifier of the creation method to remove |
| true | if the creation method was removed. | |
| false | if there was no creation method attached to id |
Definition at line 84 of file utilmm/types/factory.hh.
| 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
| id | The identifier of the creation method to remove |
| true | if the creation method was removed. | |
| false | if there was no creation method attached to id |
Definition at line 51 of file install/include/utilmm/types/factory.hh.
singleton::wrapper [friend] |
Definition at line 129 of file install/include/utilmm/types/factory.hh.
factory_db utilmm::factory< AbstractProduct, IdentifierType, Result, ProductCreator, FactoryErrorPolicy, OrderId >::associations [private] |
Definition at line 22 of file install/include/utilmm/types/factory.hh.