Generic Factory implementation.
More...
#include <utilmm/types/factory.hh>
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
-
| 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>) |
- Note
- this class is a singleton
- See also
- utilmm::singleton::use
- Author
- Frédéric Py fpy@l.nosp@m.aas..nosp@m.fr
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 |
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
-
This function test if there's a creation method attched to id
- Return values
-
| true | If thered's a creation method attched to id |
| false | else |
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
-
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
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
-
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
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 |
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
-
| id | The identifier of the creation method to remove |
- Return values
-
| true | if the creation method was removed. |
| false | if there was no creation method attached to id |
template<class AbstractProduct , typename IdentifierType , typename Result , typename ProductCreator , template< typename, class, typename > class FactoryErrorPolicy, class OrderId >
template<class Ty >
The documentation for this class was generated from the following file: