All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Properties.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2014 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 Properties.h
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 #ifndef __TERRALIB_LAYOUT_INTERNAL_PROPERTIES_H
29 #define __TERRALIB_LAYOUT_INTERNAL_PROPERTIES_H
30 
31 //Terralib
32 #include "Property.h"
33 #include "AbstractType.h"
34 
35 //STL
36 #include <vector>
37 #include <algorithm>
38 
39 namespace te
40 {
41  namespace layout
42  {
43  class Properties
44  {
45  public:
46  Properties(std:: string objectName, LayoutAbstractObjectType type = TPObjectUnknown);
47  virtual ~Properties(void);
48 
49  virtual bool addProperty(Property property);
50  virtual bool removeProperty(std::string name);
51  virtual bool clear();
52  virtual std::vector<Property> getProperties();
53 
54  virtual std::string getObjectName();
55 
56  virtual void setObjectName(std::string name);
57 
59 
60  virtual void setTypeObj(LayoutAbstractObjectType type);
61 
62  virtual void setHasGridWindows(bool windows);
63 
64  virtual bool hasGridWindows();
65 
66  virtual bool contains(Property property);
67 
68  virtual Property contains(std::string name);
69 
70  protected:
71  std::vector<Property> m_properties;
72  std::string m_objName;
75 
76  };
77 
78  inline Properties::Properties(std:: string objectName, LayoutAbstractObjectType type) :
79  m_objName(objectName),
80  m_typeObj(type),
81  m_hasGridWindows(false)
82  {
83  }
84 
85  inline Properties::~Properties( void )
86  {
87  }
88 
89  inline bool Properties::addProperty(Property property)
90  {
91  unsigned int total = m_properties.size();
92  m_properties.push_back(property);
93 
94  if(m_properties.size() > total)
95  return true;
96  return false;
97  }
98 
99 
100  inline bool Properties::removeProperty(std::string name)
101  {
102  bool result = false;
103 
104  for(std::vector<Property>::iterator it = m_properties.begin(); it != m_properties.end(); it++)
105  {
106  if((*it).getName().compare(name) == 0)
107  {
108  m_properties.erase(it);
109  result = true;
110  break;
111  }
112  }
113  return result;
114  }
115 
116  inline std::vector<Property> Properties::getProperties()
117  {
118  return m_properties;
119  }
120 
121  inline bool Properties::clear()
122  {
123  m_properties.clear();
124  return m_properties.empty();
125  }
126 
127  inline std::string Properties::getObjectName()
128  {
129  return m_objName;
130  }
131 
132  inline void Properties::setObjectName( std::string name )
133  {
134  m_objName = name;
135  }
136 
138  {
139  return m_typeObj;
140  }
141 
143  {
144  m_typeObj = type;
145  }
146 
147  inline bool Properties::contains( Property property )
148  {
149  bool is_present = false;
150 
151  if(std::find(m_properties.begin(), m_properties.end(), property) != m_properties.end())
152  {
153  is_present = true;
154  }
155 
156  return is_present;
157  }
158 
159  inline te::layout::Property Properties::contains( std::string name )
160  {
161  Property property;
162  property.setName(name);
163 
164  if(std::find(m_properties.begin(), m_properties.end(), property) != m_properties.end())
165  {
166  std::vector<Property>::iterator it = std::find(m_properties.begin(), m_properties.end(), property);
167 
168  property = (*it);
169  }
170  else
171  property.setName("");
172 
173  return property;
174  }
175 
176  inline void te::layout::Properties::setHasGridWindows( bool windows )
177  {
178  m_hasGridWindows = windows;
179  }
180 
182  {
183  return m_hasGridWindows;
184  }
185  }
186 }
187 
188 #endif
Properties(std::string objectName, LayoutAbstractObjectType type=TPObjectUnknown)
Definition: Properties.h:78
virtual bool addProperty(Property property)
Definition: Properties.h:89
LayoutAbstractObjectType m_typeObj
Definition: Properties.h:73
virtual ~Properties(void)
Definition: Properties.h:85
std::string m_objName
Definition: Properties.h:72
virtual bool removeProperty(std::string name)
Definition: Properties.h:100
virtual std::vector< Property > getProperties()
Definition: Properties.h:116
virtual void setObjectName(std::string name)
Definition: Properties.h:132
std::vector< Property > m_properties
Definition: Properties.h:71
virtual bool hasGridWindows()
Definition: Properties.h:181
virtual void setHasGridWindows(bool windows)
Definition: Properties.h:176
virtual std::string getObjectName()
Definition: Properties.h:127
virtual LayoutAbstractObjectType getTypeObj()
Definition: Properties.h:137
LayoutAbstractObjectType
Enum TdkAbstractComponentType. This is the enumeration of the components types.
Definition: AbstractType.h:38
virtual bool clear()
Definition: Properties.h:121
void setName(std::string name)
Definition: Property.cpp:54
virtual void setTypeObj(LayoutAbstractObjectType type)
Definition: Properties.h:142
virtual bool contains(Property property)
Definition: Properties.h:147