ExternalGraphicRendererManager.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/ExternalGraphicRendererManager.h
22 
23  \brief This is a singleton for managing all external graphic renderers instances available in the system.
24 */
25 
26 #ifndef __TERRALIB_MAPTOOLS_INTERNAL_EXTERNALGRAPHICRENDERERMANAGER_H
27 #define __TERRALIB_MAPTOOLS_INTERNAL_EXTERNALGRAPHICRENDERERMANAGER_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 <vector>
37 
38 namespace te
39 {
40 // Forward declaration
41  namespace se
42  {
43  class ExternalGraphic;
44  }
45 
46  namespace map
47  {
48 // Forward declaration
49  class AbstractExternalGraphicRenderer;
50 
51  /*!
52  \class ExternalGraphicRendererManager
53 
54  \brief This is a singleton for managing all external graphic renderers instances available in the system.
55 
56  If you want to render a external graphic, use commands like:
57  <code>
58  te::color::RBGA** image = te::map::ExternalGraphicRendererManager::getInstance().render(eg, size);
59  </code>
60 
61  \sa AbstractExternalGraphickRenderer
62  */
63  class TEMAPEXPORT ExternalGraphicRendererManager : public te::common::ClassLevelLockable<ExternalGraphicRendererManager,
64  ::boost::recursive_mutex,
65  ::boost::lock_guard< ::boost::recursive_mutex>,
66  ::boost::lock_guard< ::boost::recursive_mutex> >,
67  public te::common::Singleton<ExternalGraphicRendererManager>
68  {
70 
71  public:
72 
73  /*!
74  \brief It generates the image pattern from the given Symbology Enconding External Graphic element.
75 
76  \param eg The Symbology Enconding External Graphic element that will be used as base to build the image pattern.
77  \param height The height of image pattern that will be generated.
78  \param width An output parameter that will be filled with the width of generated image pattern.
79 
80  \return The RGBA image that represents the external graphic.
81 
82  \note This method will consult all registered external graphic renderers and the first that can process the given element will be used.
83 
84  \note The caller will take the ownership of the returned pointer.
85 
86  \exception Exception It will throws an exception if the image pattern can not be generated.
87  */
88  te::color::RGBAColor** render(const te::se::ExternalGraphic* eg, std::size_t height, std::size_t& width);
89 
90  /*!
91  \brief It adds a new external graphic renderer to the manager.
92 
93  \param renderer The new external graphic renderer that will be added on the manager.
94 
95  \note The manager will take the owership of the given external graphic renderer.
96  */
97  void add(AbstractExternalGraphicRenderer* renderer);
98 
99  protected:
100 
101  /*! \brief It initializes the singleton instance of the external graphic renderer manager. */
103 
104  /*! \brief Singleton destructor. */
106 
107  private:
108 
109  std::vector<AbstractExternalGraphicRenderer*> m_renderers; //!< The external graphic renderers in the manager.
110  };
111 
112  } // end namespace map
113 } // end namespace te
114 
115 #endif // __TERRALIB_MAPTOOLS_INTERNAL_EXTERNALGRAPHICRENDERERMANAGER_H
The ExternalGraphic allows a reference to be made to an external graphic file with a Web URL or to in...
This is a singleton for managing all external graphic renderers instances available in the system...
URI C++ Library.
std::vector< AbstractExternalGraphicRenderer * > m_renderers
The external graphic renderers in the manager.
#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
An abstract class for conversion of Symbology Enconding ExternalGraphic elements to an image pattern...
Template support for singleton pattern.
Definition: Singleton.h:100