ColorSchemeCatalogManager.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/color/ColorSchemeCatalogManager.h
22 
23  \brief The ColorSchemeCatalogManager is a singleton that can be used to manage all loaded color scheme catalogs.
24 */
25 
26 #ifndef __TERRALIB_COLOR_INTERNAL_COLORSCHEMECATALOGMANAGER_H
27 #define __TERRALIB_COLOR_INTERNAL_COLORSCHEMECATALOGMANAGER_H
28 
29 // TerraLib
30 #include "../common/Singleton.h"
31 #include "Config.h"
32 
33 // STL
34 #include <map>
35 #include <string>
36 #include <vector>
37 
38 namespace te
39 {
40  namespace color
41  {
42 // Forward declaration
43  class ColorSchemeCatalog;
44 
45  /*!
46  \class ColorSchemeCatalogManager
47 
48  \brief The ColorSchemeCatalogManager is a singleton that can be used to manage all loaded color scheme catalogs.
49 
50  Use this class to keep the loaded catalogs and to be a point of entry for plugins that
51  need to known what are the opened catalogs of your application. When the singleton finishes
52  its life time it automatically clears all loaded catalogs stored on it.
53  You can also use it only inside a given window, where a list of catalogs will be displayed
54  and then when the window gets closed, you clear the catalogs to save memory.
55 
56  \note You can save memory not loading all catalogs and keeping then opened during the entire life of your application.
57 
58  \ingroup color
59 
60  \sa Singleton, ColorScheme, ColorSchemeGroup, ColorSchemeCatalog
61 
62  \todo Em breve, seria melhor transformar as classes ColorScheme, ColorSchemeCatalog
63  em pImpl ou shared pointers, para que as pessoas nao tenham que se preocupar
64  com concorrencia em nivel de thread no que diz respeito a quem pegou o ponteiro,
65  quem apagou e assim por diante!
66 
67  \todo Criar uma classe chamada ApplicationPreferences que guarda qual o catalogo
68  default de um dado usuario. Depois cria um classe XML que salva as preferencias num arquivo XML.
69  Exemplo de pereferncias: tipo de fonte padrao, cor padrao, catalogo de cores padrao, numero de cores padrao, tipo de agrupament padrao, driver de fonte de dados padrao,
70  nome usuario e senha por driver, localizacao do mapa de layout (quickview ou coisa assim),
71  estilo de ponto padrao, estilo de linha padrao, estilo de poligono padrao,
72  local de salvar o projeto, local de exportar dados,
73  local de importar dados.... e varias outras preferencias do usuario
74  */
75  class TECOLOREXPORT ColorSchemeCatalogManager : public te::common::Singleton<ColorSchemeCatalogManager>
76  {
78 
79  public:
80 
81  /** @name ColorSchemeCatalogManager Accessor Method
82  * Method used to access the data stored on this manager.
83  */
84  //@{
85 
86  /*!
87  \brief It inserts a new catalog that will be managed by ColorSchemeCatalogManager.
88 
89  \param c The new catalog to be managed by this manager.
90 
91  \exception Exception If the catalog already exists it will raise an exception.
92 
93  \note Don't free the resources used by the catalog, the manager will take the ownership of it.
94  */
95  void insert(ColorSchemeCatalog* c);
96 
97  /*!
98  \brief It removes the internal reference to the catalog.
99 
100  \param c The catalog to be removed.
101 
102  \exception Exception If the catalog doesn't exist it will raise an exception.
103 
104  \note The caller of this method will take the ownership of the catalog.
105  */
106  void disconnect(ColorSchemeCatalog* c);
107 
108  /*!
109  \brief It removes the catalog from the manager and clears it resources.
110 
111  \param c The catalog to be removed.
112 
113  \exception Exception If the catalog doesn't exist it will raise an exception.
114 
115  \note The memory pointed by c will be deallocated. Don't reference it anymore.
116  */
117  void erase(ColorSchemeCatalog* c);
118 
119  /*!
120  \brief It returns the catalog identified by a given name or NULL if none is found.
121 
122  \param name The name of the catalog we are looking for.
123 
124  \return A pointer to a catalog (don't free the pointer) or NULL if none is found.
125  */
126  ColorSchemeCatalog* findByName(const std::string& name) const;
127 
128  /*!
129  \brief It returns a pair of iterators over the catalogs of this manager.
130 
131  \return A pair of iterators over the catalogs of this manager where pair.first will be
132  the beginning and pair.second will be the end iterator.
133  */
134  std::pair<std::vector<ColorSchemeCatalog*>::const_iterator,
135  std::vector<ColorSchemeCatalog*>::const_iterator> getIterator() const;
136 
137  /*!
138  \brief It returns the list of catalogs available in the system.
139 
140  \return The list of catalogs available in the system.
141  */
142  const std::vector<ColorSchemeCatalog*>& getCatalogs() const;
143 
144  /*!
145  \brief It returns true if the manager contains at least one catalog. If no catalog exists, it returns false.
146 
147  \return True if the manager contains at least one catalog. If no catalog exists, it returns false.
148  */
149  bool isEmpty() const;
150 
151  /*! \brief It unloads all catalogs managed by ColorSchemeCatalogManager. */
152  void clear();
153 
154  //@}
155 
156  /** @name Initializer Methods
157  * Methods related to instantiation and destruction.
158  */
159  //@{
160 
161  /*! \brief Destructor. */
163 
164  //@}
165 
166  protected:
167 
168  /** @name Initializer Methods
169  * Methods related to instantiation and destruction.
170  */
171  //@{
172 
173  /*! \brief It initializes the Singleton. */
175 
176  //@}
177 
178  private:
179 
180  /** @name Copy Constructor and Assignment Operator
181  * Copy constructor and assignment operator not allowed.
182  */
183  //@{
184 
185  /*!
186  \brief Copy constructor not allowed.
187 
188  \param rhs The right-hand-side copy that would be used to copy from.
189  */
191 
192  /*!
193  \brief Assignment operator not allowed.
194 
195  \param rhs The right-hand-side copy that would be used to copy from.
196 
197  \return A reference to this object.
198  */
200 
201  //@}
202 
203  private:
204 
205  std::vector<ColorSchemeCatalog*> m_catalogs; //!< This is the list of all system's loaded catalogs.
206  std::map<std::string, ColorSchemeCatalog*> m_catalogIdxByName; //!< An index from catalog's name to catalog's instance (note: we can not have duplicated names).
207  };
208 
209  } // end namespace color
210 } // end namespace te
211 
212 #endif // __TERRALIB_COLOR_INTERNAL_COLORSCHEMECATALOGMANAGER_H
213 
std::map< std::string, ColorSchemeCatalog * > m_catalogIdxByName
An index from catalog&#39;s name to catalog&#39;s instance (note: we can not have duplicated names)...
Configuration flags for the Color module of TerraLib.
The ColorSchemeCatalogManager is a singleton that can be used to manage all loaded color scheme catal...
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
TerraLib.
Singleton & operator=(const Singleton &other)
std::vector< ColorSchemeCatalog * > m_catalogs
This is the list of all system&#39;s loaded catalogs.
A catalog for color schemes.
#define TECOLOREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:73
Template support for singleton pattern.
Definition: Singleton.h:100