All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ColorSchemeCatalog.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/color/ColorSchemeCatalog.cpp
22 
23  \brief Implementation of the color scheme catalog class.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "ColorScheme.h"
29 #include "ColorSchemeCatalog.h"
31 #include "ColorSchemeGroup.h"
32 
33 // STL
34 #include <algorithm>
35 #include <cassert>
36 
38  : m_name(name)
39 {
40 }
41 
43 {
44  te::common::FreeContents(m_colorSchemeGroups);
45 }
46 
47 const std::string& te::color::ColorSchemeCatalog::getName() const
48 {
49  return m_name;
50 }
51 
52 void te::color::ColorSchemeCatalog::setName(const std::string& newName)
53 {
54  assert(newName.empty() == false);
55 
56  if(ColorSchemeCatalogManager::getInstance().findByName(m_name)) // does it relate to any manager?
57  {
58  ColorSchemeCatalogManager::getInstance().disconnect(this);
59  m_name = newName;
61  }
62  else //it doesn't relate to any manager
63  m_name = newName;
64 }
65 
67 {
68  return m_description;
69 }
70 
72 {
73  m_description = d;
74 }
75 
76 const std::string& te::color::ColorSchemeCatalog::getAuthor() const
77 {
78  return m_author;
79 }
80 
81 void te::color::ColorSchemeCatalog::setAuthor(const std::string& author)
82 {
83  m_author = author;
84 }
85 
87 {
88  return m_copyright;
89 }
90 
92 {
93  m_copyright = c;
94 }
95 
97 {
98  return m_onlineResource;
99 }
100 
102 {
103  m_onlineResource = r;
104 }
105 
107 {
108  assert(group);
109 
110  m_colorSchemeGroups.push_back(group);
111  group->setParent(this);
112 }
113 
115 {
116  std::vector<ColorSchemeGroup*>::iterator it = std::find(m_colorSchemeGroups.begin(), m_colorSchemeGroups.end(), group);
117 
118  if(it != m_colorSchemeGroups.end())
119  m_colorSchemeGroups.erase(it);
120 }
121 
122 const std::vector<te::color::ColorSchemeGroup*>& te::color::ColorSchemeCatalog::getColorSchemeGroups() const
123 {
124  return m_colorSchemeGroups;
125 }
126 
127 
128 
const std::string & getDescription() const
It returns the catalog description.
const std::vector< ColorSchemeGroup * > & getColorSchemeGroups() const
It returns the list of color scheme groups in the catalog.
This class represents a group of color schemes.
void setCopyright(const std::string &c)
It sets the catalog copyright notice.
void setDescription(const std::string &d)
It sets the catalog description.
const std::string & getAuthor() const
It returns the catalog author name.
void setAuthor(const std::string &author)
It sets the catalog author name.
The ColorSchemeCatalogManager is a singleton that can be used to manage all loaded color scheme catal...
void push_back(ColorSchemeGroup *group)
It adds a new group to the catalog and sets its relationship.
static T & getInstance()
It returns a reference to the singleton instance.
Definition: Singleton.h:120
const std::string & getName() const
It returns the catalog name.
void setOnlineResource(const std::string &r)
It sets the link for more information about the catalog.
void disconnect(ColorSchemeGroup *group)
It removes the internal reference to the group.
ColorSchemeCatalog(const std::string &name)
It initializes a new ColorSchemeCatalog.
const std::string & getCopyright() const
It returns the catalog copyright notice.
The concept of color scheme.
This class represents a group of color schemes.
void setParent(ColorSchemeCatalog *parent)
It sets the parent color catalog for this group.
A catalog for color schemes groups.
void setName(const std::string &newName)
It changes the catalog name and adjusts its entry in the catalog manager if needed.
const std::string & getOnlineResource() const
It returns a link for more information about the catalog.
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