te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE > Class Template Reference

This class represents a dictionary of factories. More...

#include <FactoryDictionary.h>

Public Types

typedef std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator const_iterator
 

Public Member Functions

std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator begin () const
 It returns an iterator to the first stored factory. More...
 
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator end () const
 It returns an iterator to the end of the container. More...
 
 FactoryDictionary ()
 It creates a new factory dictionary. More...
 
TFACTORY * find (const TFACTORYKEY &factoryKey) const
 It looks for a given factory identified by a key. More...
 
void insert (const TFACTORYKEY &factoryKey, TFACTORY *factory)
 It inserts a pointer to a factory and makes it associated to the factory key. More...
 
void remove (const TFACTORYKEY &factoryKey)
 It removes the factory from the dictionary. More...
 
std::size_t size () const
 It returns the number of registered factories in the dictionary. More...
 
 ~FactoryDictionary ()
 Destructor. More...
 

Private Member Functions

Copy Constructor and Assignment Operator

Copy constructor and assignment operator not allowed.

 FactoryDictionary (const FactoryDictionary &rhs)
 Copy constructor not allowed. More...
 
FactoryDictionaryoperator= (const FactoryDictionary &rhs)
 Assignment operator not allowed. More...
 

Private Attributes

std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE > m_factoryMap
 The internal dictionary map: key => factory. More...
 

Detailed Description

template<class TFACTORY, class TFACTORYKEY, class TKEYCOMPARE = std::less<TFACTORYKEY>>
class te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >

This class represents a dictionary of factories.

An abstract factory will keep an internal dictionary for its concrete factories. A factory is identified by a key of type TFACTORYKEY that must have the less-than operator. The type TFACTORYKEY must also be copy constructible.

The abstract factory to which the dictionary will belong to has the type TFACTORY.

Note that TFACTORY is the factory type and TFACTORYKEY is the type used to identify the factory.

At destruction time, it will release the memory pointed by the registered factories.

If you are creating a plugin that registers a factory, see the Abstract and Parameterized abstract factory notes about memory management.

You should not use this class in your code. It is for internal use only.

See also
AbstractFactory, ParameterizedAbstractFactory

Definition at line 67 of file FactoryDictionary.h.

Member Typedef Documentation

template<class TFACTORY, class TFACTORYKEY, class TKEYCOMPARE = std::less<TFACTORYKEY>>
typedef std::map<TFACTORYKEY, TFACTORY*, TKEYCOMPARE>::const_iterator te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::const_iterator

Definition at line 71 of file FactoryDictionary.h.

Constructor & Destructor Documentation

template<class TFACTORY , class TFACTORYKEY , class TKEYCOMPARE >
te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::FactoryDictionary ( )
inline

It creates a new factory dictionary.

Definition at line 173 of file FactoryDictionary.h.

template<class TFACTORY , class TFACTORYKEY , class TKEYCOMPARE >
te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::~FactoryDictionary ( )
inline

Destructor.

It will release all factories registered in it. If you need to release the memory before, call remove method, it will just de-register the given factory.

Definition at line 178 of file FactoryDictionary.h.

template<class TFACTORY, class TFACTORYKEY, class TKEYCOMPARE = std::less<TFACTORYKEY>>
te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::FactoryDictionary ( const FactoryDictionary< TFACTORY, TFACTORYKEY, 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 TFACTORY , class TFACTORYKEY , class TKEYCOMPARE >
FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::const_iterator te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::begin ( ) const
inline

It returns an iterator to the first stored factory.

Returns
An iterator to the first stored factory.
Note
Don't free the pointers!

Definition at line 230 of file FactoryDictionary.h.

template<class TFACTORY , class TFACTORYKEY , class TKEYCOMPARE >
FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::const_iterator te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::end ( ) const
inline

It returns an iterator to the end of the container.

Returns
An iterator to the end of the container.

Definition at line 236 of file FactoryDictionary.h.

template<class TFACTORY , class TFACTORYKEY , class TKEYCOMPARE >
TFACTORY * te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::find ( const TFACTORYKEY &  factoryKey) const
inline

It looks for a given factory identified by a key.

Parameters
factoryKeyThe key identifying the searched factory.
Returns
It returns a pointer to the searched factory or NULL otherwise.
Note
You must not release the memory pointed by factory while it is being used.

Definition at line 219 of file FactoryDictionary.h.

Referenced by te::qt::af::SettingsWidgetsFactory::make().

template<class TFACTORY , class TFACTORYKEY , class TKEYCOMPARE >
void te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::insert ( const TFACTORYKEY &  factoryKey,
TFACTORY *  factory 
)
inline

It inserts a pointer to a factory and makes it associated to the factory key.

Parameters
factoryKeyThe key that will be used to access the given factory.
factoryA valid pointer to a factory.
Exceptions
ExceptionIt throws an exception if it can not insert the factory.
Note
You must not release the memory pointed by factory while it is being used.

Definition at line 193 of file FactoryDictionary.h.

References TE_TR.

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

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

Assignment operator not allowed.

Parameters
rhsThe right-hand-side copy that would be used to copy from.
Returns
A reference to this object.
template<class TFACTORY , class TFACTORYKEY , class TKEYCOMPARE >
void te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::remove ( const TFACTORYKEY &  factoryKey)
inline

It removes the factory from the dictionary.

It doesn't release the memory, the caller must do this when appropriated.

Exceptions
ExceptionIt throws an exception if it can not unregister the factory.
Parameters
factoryKeyThe key identifying the factory.

Definition at line 208 of file FactoryDictionary.h.

References TE_TR.

template<class TFACTORY , class TFACTORYKEY , class TKEYCOMPARE >
std::size_t te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::size ( ) const
inline

It returns the number of registered factories in the dictionary.

Returns
The number of registered factories in the dictionary.

Definition at line 242 of file FactoryDictionary.h.

Member Data Documentation

template<class TFACTORY, class TFACTORYKEY, class TKEYCOMPARE = std::less<TFACTORYKEY>>
std::map<TFACTORYKEY, TFACTORY*, TKEYCOMPARE> te::common::FactoryDictionary< TFACTORY, TFACTORYKEY, TKEYCOMPARE >::m_factoryMap
private

The internal dictionary map: key => factory.

Definition at line 169 of file FactoryDictionary.h.


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