Loading...
Searching...
No Matches
SimpleProperty.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 terralib/datatype/SimpleProperty.h
22
23 \brief An atomic property like an integer or double.
24*/
25
26#ifndef __TERRALIB_DATATYPE_INTERNAL_SIMPLEPROPERTY_H
27#define __TERRALIB_DATATYPE_INTERNAL_SIMPLEPROPERTY_H
28
29// TerraLib
30#include "Property.h"
31
32namespace te
33{
34 namespace dt
35 {
36 /*!
37 \class SimpleProperty
38
39 \brief An atomic property like an integer or double.
40
41 \sa Property, CompositeProperty, NumericProperty, StringProperty, ArrayProperty, DateTimeProperty
42
43 \ingroup datatype
44
45 \todo The default value must be changed to an AbstractData.
46 */
48 {
49 public:
50
51 /*!
52 \brief It constructs a new simple property.
53
54 \param name The simple property name.
55 \param datatype The property data type.
56 \param isRequired Tells if the the property is required (mandatory) or not.
57 \param defaultValue The default value to be used or NULL if none is informed.
58 \param id The property identifier.
59 \param parent A reference to the parent Property of the new object if it has one.
60
61 \post The simple property will take the ownership of the default value.
62
63 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
64 \warning By default, a simple property is not an autonumber (or serial).
65 */
66 SimpleProperty(const std::string& name,
67 int datatype,
68 bool isRequired = false,
69 std::string* defaultValue = 0,
70 unsigned int id = 0,
71 Property* parent = 0);
72
73 /*!
74 \brief Copy constructor.
75
76 \param rhs The right-hand-side copy used to copy from.
77 */
79
80 /*! \brief Destructor. */
81 virtual ~SimpleProperty();
82
83 /*!
84 \brief Assignment operator.
85
86 \param rhs The right-hand-side copy used to copy from.
87
88 \return A reference to this object.
89 */
91
92 /*!
93 \brief It returns true if the attribute is required, otherwise it returns false.
94
95 \return True if the attribute is required, otherwise it returns false.
96 */
97 bool isRequired() const { return m_isRequired; }
98
99 /*!
100 \brief It tells if the property is required or not.
101
102 \param r If true the property is marked as required, otherwise it is not required.
103 */
104 void setRequired(bool r) { m_isRequired = r; }
105
106 /*!
107 \brief It returns true if the attribute is an autonumber, otherwise it returns false.
108
109 \return True if the attribute is an autonumber, otherwise it returns false.
110 */
111 bool isAutoNumber() const { return m_isAutoNumber; }
112
113 /*!
114 \brief It tells if the property is an autonumber or not.
115
116 \param a If true the property is marked as an autonumber (serial), otherwise it is not.
117 */
118 void setAutoNumber(bool a) { m_isAutoNumber = a; }
119
120 /*!
121 \brief It returns the default value associated to the property, or NULL if none is associated.
122
123 \return The default value associated to the property, or NULL if none is associated.
124
125 \note The caller of this method will not take the ownership of the given string.
126 */
127 std::string* getDefaultValue() const { return m_defaultValue; }
128
129 /*!
130 \brief It sets the default value associated to the property, or NULL if none is associated.
131
132 \param d The default value associated to the property, or NULL if none is associated.
133
134 \note The SimpleProperty qill take the ownership of the given string.
135 */
136 void setDefaultValue(std::string* d);
137
138 /*!
139 \brief It checks if the Property "p" is associated to this property or any other parent.
140
141 This method can be used to ask if a given Property belongs
142 to a more complex type (like: CompositeProperty or DataSetType).
143
144 \param p The Property we are checking.
145
146 \return True if the given Property "p" is associated to to this Property, otherwise, returns false.
147 */
148 bool has(Property* p) const;
149
150 /*!
151 \brief It returns a clone of the object.
152
153 For a simple type, this method will not preserve
154 the parent Property pointer.
155
156 \return A clone of the object.
157 */
158 virtual Property* clone() const;
159
160 protected:
161
162 bool m_isRequired; //!< This flag indicates if the attribute is required or not.
163 bool m_isAutoNumber; //!< A flag that indicates if this is an autonumber or serial type.
164 std::string* m_defaultValue; //!< Default value.
165 };
166
167 } // end namespace dt
168} // end namespace te
169
170#endif // __TERRALIB_DATATYPE_INTERNAL_SIMPLEPROPERTY_H
171
It models a property definition.
It models a property definition.
Definition: Property.h:60
An atomic property like an integer or double.
virtual Property * clone() const
It returns a clone of the object.
std::string * getDefaultValue() const
It returns the default value associated to the property, or NULL if none is associated.
SimpleProperty(const std::string &name, int datatype, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new simple property.
void setRequired(bool r)
It tells if the property is required or not.
bool m_isRequired
This flag indicates if the attribute is required or not.
virtual ~SimpleProperty()
Destructor.
bool isRequired() const
It returns true if the attribute is required, otherwise it returns false.
SimpleProperty(const SimpleProperty &rhs)
Copy constructor.
SimpleProperty & operator=(const SimpleProperty &rhs)
Assignment operator.
void setDefaultValue(std::string *d)
It sets the default value associated to the property, or NULL if none is associated.
bool has(Property *p) const
It checks if the Property "p" is associated to this property or any other parent.
std::string * m_defaultValue
Default value.
bool m_isAutoNumber
A flag that indicates if this is an autonumber or serial type.
bool isAutoNumber() const
It returns true if the attribute is an autonumber, otherwise it returns false.
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
TerraLib.
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61