MarkRendererManager.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/maptools/MarkRendererManager.h
22 
23  \brief This is a singleton for managing all mark renderers instances available in the system.
24 */
25 
26 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_MARKRENDERERMANAGER_H
27 #define __TERRALIB_MAPTOOLS_INTERNAL_MARKRENDERERMANAGER_H
28 
29 // TerraLib
30 #include "../color/RGBAColor.h"
31 #include "../common/Singleton.h"
32 #include "../common/ThreadingPolicies.h"
33 #include "Config.h"
34 
35 // STL
36 #include <map>
37 
38 namespace te
39 {
40 // Forward declaration
41  namespace se
42  {
43  class Mark;
44  }
45 
46  namespace map
47  {
48 // Forward declaration
49  class AbstractMarkRenderer;
50 
51  /*!
52  \class MarkRendererManager
53 
54  \brief This is a singleton for managing all mark renderers instances available in the system.
55 
56  If you want to render a mark, use commands like:
57  <code>
58  te::color::RBGA** image = te::map::MarkRendererManager::getInstance().render(mark, size);
59  </code>
60 
61  \sa AbstractMarkRenderer
62  */
64  ::boost::recursive_mutex,
65  ::boost::lock_guard< ::boost::recursive_mutex>,
66  ::boost::lock_guard< ::boost::recursive_mutex> >,
67  public te::common::Singleton<MarkRendererManager>
68  {
70 
71  public:
72 
73  /*!
74  \brief It generates the image pattern from the given Symbology Enconding Mark element.
75 
76  \param mark The Symbology Enconding Mark element that will be used as base to build the image pattern.
77  \param size The size of image pattern that will be generated.
78 
79  \return The RGBA image that represents the mark.
80 
81  \note This method will look the name of the mark and try extract the associated rendererKey.
82  The pattern used is "rendererKey://markName".
83  Case empty will be used the default mark renderer.
84 
85  \note The caller will take the ownership of the returned pointer.
86 
87  \exception Exception It will throws an exception if the image pattern can not be generated.
88  */
89  te::color::RGBAColor** render(const te::se::Mark* mark, std::size_t size);
90 
91  /*!
92  \brief It informs the set of all supported marks available in the system.
93 
94  \param marks A pre-created vector of string that will be filled with the supported marks names.
95 
96  \note All registered mark renderers will be consulted.
97  */
98  void getAllSupportedMarks(std::vector<std::string>& marks) const;
99 
100  /*!
101  \brief It adds a new mark renderer to the manager.
102 
103  \param key The key of the new renderer.
104  \param renderer The new mark renderer that will be added on the manager.
105 
106  \note The manager will take the owership of the given mark renderer.
107 
108  \exception Exception It will throws an exception if there is already a mark renderer registered with the given key.
109  */
110  void add(const std::string& key, AbstractMarkRenderer* renderer);
111 
112  /*!
113  \brief It clears the marks renderers of the manager.
114 
115  */
116  void clear();
117 
118  protected:
119 
120  /*! \brief It initializes the singleton instance of the mark renderer manager. */
122 
123  /*! \brief Singleton destructor. */
125 
126  private:
127 
128  std::map<std::string, AbstractMarkRenderer*> m_renderers; //!< The mark renderers in the manager.
129  };
130 
131  } // end namespace map
132 } // end namespace te
133 
134 #endif // __TERRALIB_MAPTOOLS_INTERNAL_MARKRENDERERMANAGER_H
This is a singleton for managing all mark renderers instances available in the system.
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:84
URI C++ Library.
#define TEMAPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
This policy assures a class-level locking scheme for a derived class.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
std::map< std::string, AbstractMarkRenderer * > m_renderers
The mark renderers in the manager.
An abstract class for conversion of Symbology Enconding Mark elements to an image pattern...
Template support for singleton pattern.
Definition: Singleton.h:100