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) 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 Property.h
22 
23  \brief A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object.
24  Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
25 
26  \ingroup layout
27 */
28 
29 #ifndef __TERRALIB_LAYOUT_INTERNAL_PROPERTY_H
30 #define __TERRALIB_LAYOUT_INTERNAL_PROPERTY_H
31 
32 // TerraLib
33 #include "Variant.h"
34 #include "../enum/EnumType.h"
35 #include "../Config.h"
36 
37 namespace te
38 {
39  namespace layout
40  {
41  /*!
42  \brief A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object.
43  Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
44 
45  \ingroup layout
46  */
48  {
49  public:
50 
51  /*!
52  \brief Constructor
53  */
54  Property(int parentItemHashCode = 0);
55 
56  /*!
57  \brief Destructor
58  */
59  virtual ~Property();
60 
61  /*!
62  \brief Method that returns the name of this property.
63 
64  \return name of this property
65  */
66  std::string getName();
67 
68  /*!
69  \brief Sets the name of this property.
70 
71  \param name of this property
72  */
73  void setName(std::string name);
74 
75  /*!
76  \brief Returns the type of this property
77 
78  \return type of this property
79  */
80  EnumType* getType();
81 
82  std::vector<te::layout::Property> getSubProperty();
83 
84  /*
85  To use this method, you need to declare a variable with
86  corresponding type and pass it as the method parameter.
87  */
88 
89  /*!
90  \brief Stores a copy of value.
91 
92  \param value copies the value to be stored
93  \param type data type
94  */
95  template <typename ValueType>
96  void setValue(ValueType value, EnumType* type);
97 
98  /*!
99  \brief Stores a copy of value.
100 
101  \param te::layout::Variant object
102  */
103  void setValue(Variant variant);
104 
105  /*!
106  \brief Returns stored value
107 
108  \return te::layout::Variant object
109  */
110  Variant getValue();
111 
112  /*!
113  \brief Returns true if property is editable, false otherwise.
114 
115  \return true if property is editable, false otherwise
116  */
117  bool isEditable();
118 
119  /*!
120  \brief Sets true if property is editable, false otherwise
121 
122  \param true if property is editable, false otherwise
123  */
124  void setEditable(bool editable);
125 
126  /*Property Options*/
127 
128  void addOption(Variant variant);
129 
130  void removeOption(Variant variant);
131 
132  void setOptionChoice(Variant variant);
133 
134  void setOptionChoice(int numberOption);
135 
136  Variant getOptionByCurrentChoice();
137 
138  std::vector<Variant> getOptionChoices();
139 
140  //Ex.: For font information
141  void addSubProperty( Property property );
142 
143  void removeSubProperty( Property property );
144 
145  /*!
146  \brief Returns true if no value has been set, false otherwise.
147 
148  \return true if no value has been set, false otherwise
149  */
150  bool isNull();
151 
152  /*!
153  \brief Reset state of this object. Null state.
154  */
155  void clear();
156 
157  /*!
158  \brief Sets the label of this property.
159 
160  \param label of this property
161  */
162  virtual void setLabel(std::string label);
163 
164  /*!
165  \brief Returns the label of this property.
166 
167  \return label of this property
168  */
169  virtual std::string getLabel();
170 
171  virtual bool containsSubProperty(Property subProperty);
172 
173  virtual Property containsSubProperty(std::string name);
174 
175  /*!
176  \brief Sets true if property will be used in a menu, false otherwise.
177 
178  \param true if property will be used in a menu, false otherwise
179  */
180  virtual void setMenu(bool menu);
181 
182  /*!
183  \brief Returns true if property will be used in a menu, false otherwise.
184 
185  \return true if property will be used in a menu, false otherwise
186  */
187  virtual bool isMenu();
188 
189  virtual void setIcon(std::string icon);
190 
191  virtual std::string getIcon();
192 
193  /*!
194  \brief Return true if value is not of common C++ data type, false otherwise.
195 
196  \return true if value is not of common C++ data type, false otherwise
197  */
198  virtual bool isComplex();
199 
200  /*!
201  \brief Sets the visibility of this property.
202 
203  \param visibility of this property
204  */
205  virtual void setVisible(bool visible);
206 
207  /*!
208  \brief Return true if visible, false otherwise.
209 
210  \return true if visible, false otherwise
211  */
212  virtual bool isVisible();
213 
214  /*!
215  \brief Returns true if property is required, false otherwise.
216 
217  \return true if property is required, false otherwise
218  */
219  bool isRequired();
220 
221  /*!
222  \brief Sets true if property is required, false otherwise
223 
224  \param true if property is required, false otherwise
225  */
226  void setRequired(bool required);
227 
228  /*!
229  \brief Sets the hashcode of the object that owns this property.
230 
231  \param hashcode
232  */
233  void setParentItemHashCode(int hashCode);
234 
235  /*!
236  \brief Returns the hashcode of the object that owns this property.
237 
238  \return hashcode
239  */
240  int getParentItemHashCode();
241 
242  /*!
243  \brief Returns true if property compose a widget, false otherwise.
244  If true, and the object that owns this property has a parent, it will not appear in a property browser or a menu, it will be used within a widget.
245 
246  \return true if property compose a widget, false otherwise
247  */
248  bool isComposeWidget();
249 
250  /*!
251  \brief Sets true if property compose a widget, false otherwise
252  If true, and the object that owns this property has a parent, it will not appear in a property browser or a menu, it will be used within a widget.
253 
254  \param true if property compose a widget, false otherwise
255  */
256  void setComposeWidget(bool compose);
257 
258  /*!
259  \brief Returns true if property is public, false otherwise.
260  If the component, father of this property, is a child of another component,
261  then this property can be used by the parent component to display the value or call windows. It can not be edited.
262 
263  \return true if property compose a widget, false otherwise
264  */
265  bool isPublic();
266 
267  /*!
268  \brief Sets true if property is public, false otherwise
269  If the component, father of this property, is a child of another component,
270  then this property can be used by the parent component to display the value or call windows. It can not be edited.
271 
272  \param true if property compose a widget, false otherwise
273  */
274  void setPublic(bool publicProperty);
275 
276  bool operator ==(const Property& other);
277 
278  protected:
279 
280  int m_parentItemHashCode; //!< hashcode of the object that owns this property
281  std::string m_name; //!< name of this property
282  EnumType* m_type; //!< data type of this property
285  bool m_editable; //!<
286  std::vector<Variant> m_options; //!<
287  std::vector<te::layout::Property> m_subProperty; //!<
288  std::string m_label; //!<
289  bool m_menu; //!< the property will be used in a menu.
290  std::string m_icon; //!<
291  bool m_visible; //!< visibility
292  bool m_required; //!< required
293  bool m_composeWidget; //!< compose widget
294  bool m_public; //!< public property, used by another component
295  };
296 
297  template <typename ValueType>
298  inline void te::layout::Property::setValue(ValueType value, EnumType* type)
299  {
300  //Use the information type?
301  Variant v;
302  v.setValue(value, type);
303  m_value = v;
304  m_type = type;
305  }
306 
307  inline bool te::layout::Property::operator ==(const Property& other)
308  {
309  Property& otherProp = const_cast<Property&>(other);
310 
311  if(getName().compare(otherProp.getName()) == 0)
312  {
313  return true;
314  }
315 
316  return false;
317  }
318  }
319 }
320 
321 #endif
std::string getName()
Method that returns the name of this property.
Definition: Property.cpp:57
bool m_composeWidget
compose widget
Definition: Property.h:293
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
std::vector< Variant > m_options
Definition: Property.h:286
te::da::Expression * operator==(const te::da::Expression &e1, const te::da::Expression &e2)
Definition: Expression.cpp:38
int m_parentItemHashCode
hashcode of the object that owns this property
Definition: Property.h:280
std::string m_label
Definition: Property.h:288
Class acts like a union for some C++/TerraLib5 data types. Responsible for storing the value...
std::string m_name
name of this property
Definition: Property.h:281
bool m_required
required
Definition: Property.h:292
Class acts like a union for some C++/TerraLib5 data types. Responsible for storing the value...
Definition: Variant.h:80
EnumType * m_type
data type of this property
Definition: Property.h:282
bool m_visible
visibility
Definition: Property.h:291
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
Definition: Property.h:298
Variant m_currentChoice
Definition: Property.h:284
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
std::string m_icon
Definition: Property.h:290
bool m_menu
the property will be used in a menu.
Definition: Property.h:289
bool m_public
public property, used by another component
Definition: Property.h:294
bool operator==(const Property &other)
Definition: Property.h:307
std::vector< te::layout::Property > m_subProperty
Definition: Property.h:287
A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object. Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
Definition: Property.h:47
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
Definition: Variant.h:288