All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AbstractEnum.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 AbstractEnum.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "AbstractEnum.h"
30 
31 
33 {
34 
35 }
36 
38 {
39 
40 }
41 
43 {
44  EnumType* enumTp = 0;
45 
46  for(std::vector<EnumType*>::const_iterator it = m_enums.begin(); it != m_enums.end(); it++)
47  {
48  if((*it)->getId() == enumId)
49  {
50  enumTp = (*it);
51  break;
52  }
53  }
54 
55  return enumTp;
56 }
57 
59 {
60  EnumType* enumTp = 0;
61 
62  for(std::vector<EnumType*>::const_iterator it = m_enums.begin(); it != m_enums.end(); it++)
63  {
64  if((*it)->getName().compare(name) == 0)
65  {
66  enumTp = (*it);
67  break;
68  }
69  }
70 
71  return enumTp;
72 }
73 
75 {
76  EnumType* enumTp = 0;
77 
78  for(std::vector<EnumType*>::const_iterator it = m_enums.begin(); it != m_enums.end(); it++)
79  {
80  if((*it)->getLabel().compare(label) == 0)
81  {
82  enumTp = (*it);
83  break;
84  }
85  }
86 
87  return enumTp;
88 }
89 
91 {
92  int max = -1;
93 
94  if(m_enums.empty())
95  return max;
96 
97  for(std::vector<EnumType*>::const_iterator it = m_enums.begin(); it != m_enums.end(); it++)
98  {
99  if((*it)->getId() > max)
100  {
101  max = (*it)->getId();
102  }
103  }
104 
105  return max;
106 }
107 
109 {
110  int min = -1;
111 
112  if(m_enums.empty())
113  return min;
114 
115  min = m_enums[0]->getId();
116 
117  for(std::vector<EnumType*>::const_iterator it = m_enums.begin(); it != m_enums.end(); it++)
118  {
119  if((*it)->getId() < min)
120  {
121  min = (*it)->getId();
122  }
123  }
124 
125  return min;
126 }
127 
129 {
130  return m_enums.size();
131 }
132 
virtual EnumType * getEnum(int enumId) const
Searching for a value of the enumeration by id.
virtual ~AbstractEnum()
Destructor.
virtual int maxId()
Searching for a max value of the id.
virtual int minId()
Searching for a min value of the id.
virtual EnumType * searchLabel(std::string label) const
Searching for an enumeration value by name.
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
AbstractEnum()
Constructor.
Abstract class to represent an enumeration.