This class defines the basic interface of an abstract factory that makes use of parameters to construct the objects. More...
#include <ParameterizedAbstractFactory.h>
Public Types | |
typedef FactoryDictionary< ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >, TFACTORYKEY, TKEYCOMPARE > | dictionary_type |
Public Member Functions | |
const TFACTORYKEY & | getKey () const |
It returns the factory key associated to the concreate factory. More... | |
Static Public Member Functions | |
static dictionary_type & | getDictionary () |
It returns a reference to the internal dictionary. More... | |
static TPRODUCT * | make (const TFACTORYKEY &factoryKey, TPARAM p) |
It creates an object with the appropriated factory. More... | |
Protected Member Functions | |
virtual TPRODUCT * | build (TPARAM p)=0 |
Concrete factories (derived from this one) must implement this method in order to create objects. More... | |
ParameterizedAbstractFactory (const TFACTORYKEY &factoryKey) | |
It creates the factory. More... | |
virtual | ~ParameterizedAbstractFactory () |
Virtual destructor. More... | |
Protected Attributes | |
TFACTORYKEY | m_factoryKey |
The key that identifies the concrete factory: it will be used for unregistering the factory during destruction. More... | |
Private Member Functions | |
Copy Constructor and Assignment Operator | |
Copy constructor and assignment operator not allowed. | |
ParameterizedAbstractFactory (const ParameterizedAbstractFactory &rhs) | |
Copy constructor not allowed. More... | |
ParameterizedAbstractFactory & | operator= (const ParameterizedAbstractFactory &rhs) |
Assignment operator not allowed. More... | |
Friends | |
class | FactoryDictionary< ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >, TFACTORYKEY, TKEYCOMPARE > |
This class defines the basic interface of an abstract factory that makes use of parameters to construct the objects.
The parameterized abstract factory keeps an internal dictionary for accessing its concrete factories. A concrete factory is identified by a key of type TFACTORYKEY. This type must be copy constructible.
It will create objects of type TPRODUCT and will pass parameters of type TPARAM to their constructors.
Note that TPRODUCT is the object type that the factory knows how to create. The TPARAM type is the type of parameters accepted by the objects being constructed. In order to create your abstract factory, the concrete classes will have to extend the build method. When an object from a concrete factory is created, it is automatically registered in the abstract factory.
If you do not need to initialize the objects created by the factories, try to use a derived class from AbstractFactory instead.
Definition at line 65 of file ParameterizedAbstractFactory.h.
typedef FactoryDictionary<ParameterizedAbstractFactory<TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE>, TFACTORYKEY, TKEYCOMPARE> te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::dictionary_type |
Definition at line 69 of file ParameterizedAbstractFactory.h.
|
inlineprotected |
It creates the factory.
factoryKey | The key that identifies the factory. |
Definition at line 180 of file ParameterizedAbstractFactory.h.
References te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::getDictionary(), and te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::insert().
|
inlineprotectedvirtual |
Virtual destructor.
Definition at line 187 of file ParameterizedAbstractFactory.h.
|
private |
Copy constructor not allowed.
rhs | The right-hand-side copy that would be used to copy from. |
|
protectedpure virtual |
Concrete factories (derived from this one) must implement this method in order to create objects.
p | The parameter to be passed to the object being created. |
Referenced by te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::make().
|
inlinestatic |
It returns a reference to the internal dictionary.
Definition at line 173 of file ParameterizedAbstractFactory.h.
Referenced by te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::ParameterizedAbstractFactory().
|
inline |
It returns the factory key associated to the concreate factory.
Definition at line 155 of file ParameterizedAbstractFactory.h.
|
inlinestatic |
It creates an object with the appropriated factory.
factoryKey | A key that identifies the factory used to build the object. |
p | The parameter to be passed to the object being created. |
Exception | If the concrete factory is not specified or the object can not be built for any reason this methiod may throws an exception. |
Definition at line 161 of file ParameterizedAbstractFactory.h.
References te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::build(), and TE_TR.
|
private |
Assignment operator not allowed.
rhs | The right-hand-side copy that would be used to copy from. |
|
friend |
Definition at line 71 of file ParameterizedAbstractFactory.h.
|
protected |
The key that identifies the concrete factory: it will be used for unregistering the factory during destruction.
Definition at line 151 of file ParameterizedAbstractFactory.h.