te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE > Class Template Referenceabstract

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_typegetDictionary ()
 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...
 
ParameterizedAbstractFactoryoperator= (const ParameterizedAbstractFactory &rhs)
 Assignment operator not allowed. More...
 

Friends

class FactoryDictionary< ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >, TFACTORYKEY, TKEYCOMPARE >
 

Detailed Description

template<class TPRODUCT, class TFACTORYKEY, class TPARAM, class TKEYCOMPARE = std::less<TFACTORYKEY>>
class te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, 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.

See also
AbstractFactory, FactoryDictionary

Definition at line 65 of file ParameterizedAbstractFactory.h.

Member Typedef Documentation

template<class TPRODUCT, class TFACTORYKEY, class TPARAM, class TKEYCOMPARE = std::less<TFACTORYKEY>>
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.

Constructor & Destructor Documentation

template<class TPRODUCT , class TFACTORYKEY , class TPARAM , class TKEYCOMPARE >
te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::ParameterizedAbstractFactory ( const TFACTORYKEY &  factoryKey)
inlineprotected
template<class TPRODUCT , class TFACTORYKEY , class TPARAM , class TKEYCOMPARE >
te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::~ParameterizedAbstractFactory ( )
inlineprotectedvirtual

Virtual destructor.

Note
It will automatically unregister the factory from the dictionary.

Definition at line 187 of file ParameterizedAbstractFactory.h.

template<class TPRODUCT, class TFACTORYKEY, class TPARAM, class TKEYCOMPARE = std::less<TFACTORYKEY>>
te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::ParameterizedAbstractFactory ( const ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE > &  rhs)
private

Copy constructor not allowed.

Parameters
rhsThe right-hand-side copy that would be used to copy from.

Member Function Documentation

template<class TPRODUCT, class TFACTORYKEY, class TPARAM, class TKEYCOMPARE = std::less<TFACTORYKEY>>
virtual TPRODUCT* te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::build ( TPARAM  p)
protectedpure virtual

Concrete factories (derived from this one) must implement this method in order to create objects.

Parameters
pThe parameter to be passed to the object being created.
Returns
It returns an object created by the concrete factory.

Referenced by te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::make().

template<class TPRODUCT , class TFACTORYKEY , class TPARAM , class TKEYCOMPARE >
ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::dictionary_type & te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::getDictionary ( )
inlinestatic

It returns a reference to the internal dictionary.

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().

template<class TPRODUCT , class TFACTORYKEY , class TPARAM , class TKEYCOMPARE >
const TFACTORYKEY & te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::getKey ( ) const
inline

It returns the factory key associated to the concreate factory.

Returns
The factory key associated to the concreate factory.

Definition at line 155 of file ParameterizedAbstractFactory.h.

template<class TPRODUCT , class TFACTORYKEY , class TPARAM , class TKEYCOMPARE >
TPRODUCT * te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::make ( const TFACTORYKEY &  factoryKey,
TPARAM  p 
)
inlinestatic

It creates an object with the appropriated factory.

Parameters
factoryKeyA key that identifies the factory used to build the object.
pThe parameter to be passed to the object being created.
Returns
It returns a new object created by the given factory.
Exceptions
ExceptionIf the concrete factory is not specified or the object can not be built for any reason this methiod may throws an exception.
Note
The caller of this method must release the memory pointed by the returned pointer.

Definition at line 161 of file ParameterizedAbstractFactory.h.

References te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::build(), and TE_TR.

template<class TPRODUCT, class TFACTORYKEY, class TPARAM, class TKEYCOMPARE = std::less<TFACTORYKEY>>
ParameterizedAbstractFactory& te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::operator= ( const ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE > &  rhs)
private

Assignment operator not allowed.

Parameters
rhsThe right-hand-side copy that would be used to copy from.

Friends And Related Function Documentation

template<class TPRODUCT, class TFACTORYKEY, class TPARAM, class TKEYCOMPARE = std::less<TFACTORYKEY>>
friend class FactoryDictionary< ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >, TFACTORYKEY, TKEYCOMPARE >
friend

Definition at line 71 of file ParameterizedAbstractFactory.h.

Member Data Documentation

template<class TPRODUCT, class TFACTORYKEY, class TPARAM, class TKEYCOMPARE = std::less<TFACTORYKEY>>
TFACTORYKEY te::common::ParameterizedAbstractFactory< TPRODUCT, TFACTORYKEY, TPARAM, TKEYCOMPARE >::m_factoryKey
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.


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