template<class AbstractProduct, typename IdentifierType, typename ProductCreator = std::function<std::unique_ptr<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
template<class AbstractProduct , typename IdentifierType , typename ProductCreator = std::function<std::unique_ptr<AbstractProduct>()>, template< typename, class > class FactoryErrorPolicy = FactoryDefaultError>
| result_type Feel::Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy >::createObject |
( |
const identifier_type & |
id | ) |
|
Create an object from a product registered in the Factory using identifier id.
- Parameters
-
| id | identifier of the product to instantiate |
- Returns
- the object associate with
id
template<class AbstractProduct , typename IdentifierType , typename ProductCreator = std::function<std::unique_ptr<AbstractProduct>()>, template< typename, class > class FactoryErrorPolicy = FactoryDefaultError>
| bool Feel::Factory< AbstractProduct, IdentifierType, ProductCreator, FactoryErrorPolicy >::registerProduct |
( |
const identifier_type & |
id, |
|
|
creator_type |
creator |
|
) |
| |
Register a product.
A product is composed of an identifier (typically a std::string) and a functor that will create the associated object.
- Parameters
-
| id | identifier for the object to be registered |
| creator | the functor that will create the registered object |
- Returns
- true if registration went fine, false otherwise