Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ExternalGraphicRendererManager.cpp
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.cpp
22
23
\brief This is a singleton for managing all external graphic renderers instances available in the system.
24
*/
25
26
// TerraLib
27
#include "../common/STLUtils.h"
28
#include "../common/Translator.h"
29
#include "
AbstractExternalGraphicRenderer.h
"
30
#include "
Exception.h
"
31
#include "
ExternalGraphicRendererManager.h
"
32
33
// STL
34
#include <cassert>
35
#include <vector>
36
37
te::map::ExternalGraphicRendererManager::ExternalGraphicRendererManager
()
38
{
39
}
40
41
te::map::ExternalGraphicRendererManager::~ExternalGraphicRendererManager
()
42
{
43
te::common::FreeContents
(m_renderers);
44
}
45
46
te::color::RGBAColor
**
te::map::ExternalGraphicRendererManager::render
(
const
te::se::ExternalGraphic
* eg, std::size_t height, std::size_t& width)
47
{
48
LockWrite
l;
49
50
if
(height == 0)
51
throw
Exception(
TE_TR
(
"Requested size is invalid!"
));
52
53
if
(eg == 0)
54
throw
Exception(
TE_TR
(
"The given external graphic is invalid!"
));
55
56
if
(m_renderers.empty())
57
throw
Exception(
TE_TR
(
"There are not external graphic renderers registered!"
));
58
59
for
(std::size_t i = 0; i < m_renderers.size(); ++i)
60
{
61
te::color::RGBAColor
** image = m_renderers[i]->render(eg, height, width);
62
if
(image != 0)
63
return
image;
64
}
65
66
throw
Exception(
TE_TR
(
"The given external graphic cannot be processed by any registered external graphic renderer!"
));
67
}
68
69
void
te::map::ExternalGraphicRendererManager::add
(
AbstractExternalGraphicRenderer
* renderer)
70
{
71
m_renderers.push_back(renderer);
72
}
te::map::ExternalGraphicRendererManager::ExternalGraphicRendererManager
ExternalGraphicRendererManager()
It initializes the singleton instance of the external graphic renderer manager.
Definition:
ExternalGraphicRendererManager.cpp:37
ExternalGraphicRendererManager.h
This is a singleton for managing all external graphic renderers instances available in the system...
AbstractExternalGraphicRenderer.h
An abstract class for conversion of Symbology Enconding ExternalGraphic elements to an image pattern...
te::common::ClassLevelLockable< ExternalGraphicRendererManager,::boost::recursive_mutex,::boost::lock_guard< ::boost::recursive_mutex >,::boost::lock_guard< ::boost::recursive_mutex > >::LockWrite
ClassLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockWrite
Definition:
ThreadingPolicies.h:303
TE_TR
#define TE_TR(message)
It marks a string in order to get translated.
Definition:
Translator.h:347
te::map::ExternalGraphicRendererManager::~ExternalGraphicRendererManager
~ExternalGraphicRendererManager()
Singleton destructor.
Definition:
ExternalGraphicRendererManager.cpp:41
Exception.h
An exception class for the MapTools module.
te::se::ExternalGraphic
The ExternalGraphic allows a reference to be made to an external graphic file with a Web URL or to in...
Definition:
ExternalGraphic.h:86
te::color::RGBAColor
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition:
RGBAColor.h:57
te::common::FreeContents
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition:
BoostUtils.h:55
te::map::ExternalGraphicRendererManager::add
void add(AbstractExternalGraphicRenderer *renderer)
It adds a new external graphic renderer to the manager.
Definition:
ExternalGraphicRendererManager.cpp:69
te::map::AbstractExternalGraphicRenderer
An abstract class for conversion of Symbology Enconding ExternalGraphic elements to an image pattern...
Definition:
AbstractExternalGraphicRenderer.h:48
te::map::ExternalGraphicRendererManager::render
te::color::RGBAColor ** render(const te::se::ExternalGraphic *eg, std::size_t height, std::size_t &width)
It generates the image pattern from the given Symbology Enconding External Graphic element...
Definition:
ExternalGraphicRendererManager.cpp:46
TL5_2015_release
terralib5
src
terralib
maptools
ExternalGraphicRendererManager.cpp
Generated on Wed Jun 3 2015 10:23:09 for TerraLib by
1.8.7