25 #ifndef __TERRALIB_COMMON_INTERNAL_FACTORYDICTIONARY_H 
   26 #define __TERRALIB_COMMON_INTERNAL_FACTORYDICTIONARY_H 
   30 #include "../core/translator/Translator.h" 
   66     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE = std::less<TFACTORYKEY> >
 
   71         typedef typename std::map<TFACTORYKEY, TFACTORY*, TKEYCOMPARE>::const_iterator 
const_iterator;
 
   95         void insert(
const TFACTORYKEY& factoryKey, TFACTORY* factory);
 
  106         void remove(
const TFACTORYKEY& factoryKey);
 
  117         TFACTORY* 
find(
const TFACTORYKEY& factoryKey) 
const;
 
  126         typename std::map<TFACTORYKEY, TFACTORY*, TKEYCOMPARE>::const_iterator 
begin() 
const;
 
  133         typename std::map<TFACTORYKEY, TFACTORY*, TKEYCOMPARE>::const_iterator 
end() 
const;
 
  140         std::size_t 
size() 
const;
 
  172     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE> 
inline 
  177     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE> 
inline 
  189       m_factoryMap.clear();
 
  192     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE> 
inline 
  197         throw Exception(
TE_TR(
"Could not insert the given factory into the dictionary. The factory is a NULL object!"));
 
  199       typename std::map<TFACTORYKEY, TFACTORY*, TKEYCOMPARE>::const_iterator it = m_factoryMap.find(factoryKey);
 
  201       if(it != m_factoryMap.end())
 
  202         throw Exception(
TE_TR(
"Could not insert the given factory into the dictionary. There is a factory already registered with the given key."));
 
  204       m_factoryMap[factoryKey] = factory;
 
  207     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE> 
inline 
  210       typename std::map<TFACTORYKEY, TFACTORY*, TKEYCOMPARE>::iterator it = m_factoryMap.find(factoryKey);
 
  212       if(it != m_factoryMap.end())
 
  213         m_factoryMap.erase(it);
 
  215         throw Exception(
TE_TR(
"Could not unregister the informed factory. Object factory not found!"));
 
  218     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE> 
inline 
  221       typename std::map<TFACTORYKEY, TFACTORY*, TKEYCOMPARE>::const_iterator it = m_factoryMap.find(factoryKey);
 
  223       if(it == m_factoryMap.end())
 
  229     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE> 
inline 
  232       return m_factoryMap.begin();
 
  235     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE> 
inline 
  238       return m_factoryMap.end();
 
  241     template<
class TFACTORY, 
class TFACTORYKEY, 
class TKEYCOMPARE> 
inline 
  244       return m_factoryMap.size();
 
  250 #endif  // __TERRALIB_COMMON_INTERNAL_FACTORYDICTIONARY_H 
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE > m_factoryMap
The internal dictionary map: key => factory. 
void insert(const TFACTORYKEY &factoryKey, TFACTORY *factory)
It inserts a pointer to a factory and makes it associated to the factory key. 
FactoryDictionary()
It creates a new factory dictionary. 
#define TE_TR(message)
It marks a string in order to get translated. 
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator const_iterator
TFACTORY * find(const TFACTORYKEY &factoryKey) const 
It looks for a given factory identified by a key. 
FactoryDictionary & operator=(const FactoryDictionary &rhs)
Assignment operator not allowed. 
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator end() const 
It returns an iterator to the end of the container. 
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator begin() const 
It returns an iterator to the first stored factory. 
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
~FactoryDictionary()
Destructor. 
void remove(const TFACTORYKEY &factoryKey)
It removes the factory from the dictionary. 
std::size_t size() const 
It returns the number of registered factories in the dictionary. 
This class represents a dictionary of factories.