All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Property.h
Go to the documentation of this file.
1 /* Copyright (C) 2014-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 Property.h
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 #ifndef __TERRALIB_LAYOUT_INTERNAL_PROPERTY_H
29 #define __TERRALIB_LAYOUT_INTERNAL_PROPERTY_H
30 
31 // TerraLib
32 #include "Variant.h"
33 
34 namespace te
35 {
36  namespace layout
37  {
38  class Property
39  {
40  public:
41 
42  Property();
43  virtual ~Property();
44 
45  std::string getName();
46  void setName(std::string name);
47 
49 
50  std::vector<te::layout::Property> getSubProperty();
51 
52  std::string getId();
53  void setId(std::string id);
54 
55  /*
56  To use this method, you need to declare a variable with
57  corresponding type and pass it as the method parameter.
58  */
59 
60  template <typename ValueType>
61  void setValue(typename ValueType value, LayoutPropertyDataType type);
62 
63  void setValue(Variant variant);
64 
65  Variant getValue();
66 
67  bool isEditable();
68  void setEditable(bool editable);
69 
70  /*Property Options*/
71 
72  void addOption(Variant variant);
73  void removeOption(Variant variant);
74  void setOptionChoice(Variant variant);
75  void setOptionChoice(int numberOption);
77  std::vector<Variant> getOptionChoices();
78 
79  //Ex.: For font information
80  void addSubProperty( Property property );
81  void removeSubProperty( Property property );
82 
83  bool isNull();
84 
85  void clear();
86 
87  virtual bool containsSubProperty(Property subProperty);
88 
89  virtual Property containsSubProperty(std::string name);
90 
91  bool operator ==(const Property& other);
92 
93  protected:
94 
95  std::string m_name;
97  std::string m_id;
101  std::vector<Variant> m_options;
102  std::vector<te::layout::Property> m_subProperty;
103  };
104 
105  template <typename ValueType>
106  inline void te::layout::Property::setValue(typename ValueType value, LayoutPropertyDataType type)
107  {
108  //Use the information type?
109  Variant v;
110  v.setValue(value, type);
111  m_value = v;
112  m_type = type;
113  }
114 
115  inline bool te::layout::Property::operator ==(const Property& other)
116  {
117  Property& otherProp = const_cast<Property&>(other);
118 
119  if(getName().compare(otherProp.getName()) == 0)
120  {
121  return true;
122  }
123 
124  return false;
125  }
126  }
127 }
128 
129 #endif
void removeSubProperty(Property property)
Definition: Property.cpp:131
std::string getName()
Definition: Property.cpp:49
Variant getValue()
Definition: Property.cpp:74
void addSubProperty(Property property)
Definition: Property.cpp:126
void addOption(Variant variant)
Definition: Property.cpp:79
std::vector< Variant > m_options
Definition: Property.h:101
Variant getOptionByCurrentChoice()
Definition: Property.cpp:106
LayoutPropertyDataType m_type
Definition: Property.h:96
void setValue(typename ValueType value, LayoutPropertyDataType type)
Definition: Variant.h:107
void setValue(typename ValueType value, LayoutPropertyDataType type)
Definition: Property.h:106
std::string m_name
Definition: Property.h:95
std::string m_id
Definition: Property.h:97
virtual bool containsSubProperty(Property subProperty)
Definition: Property.cpp:167
std::vector< Variant > getOptionChoices()
Definition: Property.cpp:111
void removeOption(Variant variant)
Definition: Property.cpp:89
Variant m_currentChoice
Definition: Property.h:99
LayoutPropertyDataType getType()
Definition: Property.cpp:59
void setEditable(bool editable)
Definition: Property.cpp:121
void setName(std::string name)
Definition: Property.cpp:54
std::string getId()
Definition: Property.cpp:64
LayoutPropertyDataType
Enum LayoutPropertyDataType.
Definition: AbstractType.h:131
void setId(std::string id)
Definition: Property.cpp:69
bool operator==(const Property &other)
Definition: Property.h:115
std::vector< te::layout::Property > getSubProperty()
Definition: Property.cpp:143
std::vector< te::layout::Property > m_subProperty
Definition: Property.h:102
void setOptionChoice(Variant variant)
Definition: Property.cpp:101
virtual ~Property()
Definition: Property.cpp:44