Loading...
Searching...
No Matches
DateTimeProperty.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/DateTimeProperty.h
22
23 \brief The type for date and time types.
24*/
25
26#ifndef __TERRALIB_DATATYPE_INTERNAL_DATETIMEPROPERTY_H
27#define __TERRALIB_DATATYPE_INTERNAL_DATETIMEPROPERTY_H
28
29// TerraLib
30#include "Enums.h"
31#include "SimpleProperty.h"
32#include "TimeInstant.h"
33
34namespace te
35{
36 namespace dt
37 {
38 /*!
39 \class DateTimeProperty
40
41 \brief The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
42
43 \ingroup datatype
44
45 \sa SimpleProperty, Property, NumericProperty, ArrayProperty, StringProperty, CompositeProperty
46 */
48 {
49 public:
50
51 /*!
52 \brief It constructs a new date and time property.
53
54 \param name The attribute name.
55 \param dateType The date and time subtype.
56 \param precision The count of decimal digits in the fractional part, to the right of the decimal point.
57 \param isRequired It indicates if the the property is required (mandatory) or not.
58 \param defaultValue The default value to be used, if none is informed.
59 \param id The property identifier.
60 \param parent A reference to the parent Property of the new object if it has one.
61
62 \post The date time property will take the ownership of the defaultValue.
63
64 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
65 */
66 DateTimeProperty(const std::string& name,
67 DateTimeType dateType = DATE,
68 unsigned int precision = 0,
69 bool isRequired = false,
70 std::string* defaultValue = 0,
71 unsigned int id = 0,
72 Property* parent = 0);
73
74 /*!
75 \brief It constructs a new date and time property.
76
77 \param name The attribute name.
78 \param dateType The date and time subtype.
79 \param tmpRes The temporal resolution.
80 \param precision The count of decimal digits in the fractional part, to the right of the decimal point.
81 \param isRequired It indicates if the the property is required (mandatory) or not.
82 \param defaultValue The default value to be used, if none is informed.
83 \param id The property identifier.
84 \param parent A reference to the parent Property of the new object if it has one.
85
86 \post The date time property will take the ownership of the defaultValue.
87
88 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
89 */
90 DateTimeProperty(const std::string& name,
91 DateTimeType dateType,
92 TemporalResolution tmpRes,
93 unsigned int precision = 0,
94 bool isRequired = false,
95 std::string* defaultValue = 0,
96 unsigned int id = 0,
97 Property* parent = 0);
98
99 /*!
100 \brief It constructs a new date and time property that is represented by string
101
102 \param name The attribute name.
103 \param tmpRes The temporal resolution.
104 \param strFormat The format of the string that represents a time information
105 \param precision The count of decimal digits in the fractional part, to the right of the decimal point.
106 \param isRequired It indicates if the the property is required (mandatory) or not.
107 \param defaultValue The default value to be used, if none is informed.
108 \param id The property identifier.
109 \param parent A reference to the parent Property of the new object if it has one.
110
111 \post The date time property will take the ownership of the defaultValue.
112
113 \note This constructor must be used when the data type is STRING_TIME
114
115 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
116 */
117 DateTimeProperty(const std::string& name,
118 TemporalResolution tmpRes,
119 DateTimeStringFormat strFormat,
120 unsigned int precision = 0,
121 bool isRequired = false,
122 std::string* defaultValue = 0,
123 unsigned int id = 0,
124 Property* parent = 0);
125
126 /*!
127 \brief It constructs a new date and time property that is represented by ordinal numbers.
128
129 \param name The attribute name.
130 \param tmpRes The temporal resolution.
131 \param ordType The type of the ordinal time
132 \param startTime The start time when the ordinal type is USER_DEFINED
133 \param precision The count of decimal digits in the fractional part, to the right of the decimal point.
134 \param isRequired It indicates if the the property is required (mandatory) or not.
135 \param defaultValue The default value to be used, if none is informed.
136 \param id The property identifier.
137 \param parent A reference to the parent Property of the new object if it has one.
138
139 \post The date time property will take the ownership of the defaultValue.
140
141 \note This constructor must be used when the data type is ORDINAL_TIME
142
143 \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
144 */
145 DateTimeProperty(const std::string& name,
146 TemporalResolution tmpRes,
147 DateTimeOrdinalType ordType,
148 TimeInstant startTime,
149 unsigned int precision = 0,
150 bool isRequired = false,
151 std::string* defaultValue = 0,
152 unsigned int id = 0,
153 Property* parent = 0);
154
155 /*!
156 \brief Copy constructor.
157
158 \param rhs The right-hand-side copy used to copy from.
159 */
161
162 /*! \brief Destructor. */
164
165 /*!
166 \brief Assignment operator.
167
168 \param rhs The right-hand-side copy used to copy from.
169
170 \return A reference to this object.
171 */
173
174 /*!
175 \brief It returns the date time property sub type.
176
177 \return The string property sub type.
178 */
179 DateTimeType getSubType() const { return m_dSubType; }
180
181 /*!
182 \brief It sets the date time property sub type.
183
184 \param t The date time property sub type.
185 */
186 void setSubtype(DateTimeType t) { m_dSubType = t; }
187
188 /*!
189 \brief It returns the temporal resolution.
190
191 \return The temporal resolution.
192 */
193 TemporalResolution getResolution() const { return m_tempResolution; }
194
195 /*!
196 \brief It sets the temporal resolution.
197
198 \param r The temporal resolution.
199 */
200 void setResolution(TemporalResolution t) { m_tempResolution = t; }
201
202 /*!
203 \brief It returns the string format
204
205 \return The format of the string that represents the date and time
206 */
207 DateTimeStringFormat getStrFormat() const { return m_strFormat; }
208
209 /*!
210 \brief It sets the string format
211
212 \param f The format of the string that represents the date and time
213 */
214 void setStrFormat(DateTimeStringFormat f) { m_strFormat = f; }
215
216 /*!
217 \brief It returns the ordinal type, when the date and time is represented by a ordinal number
218
219 \return The ordinal type, when the date and time is represented by a ordinal number
220 */
221 DateTimeOrdinalType getOrdinalType() const { return m_ordinalType; }
222
223 /*!
224 \brief It sets the ordinal type
225
226 \param t The ordinal type, when the date and time is represented by a ordinal number
227 */
228 void setOrdinalType(DateTimeOrdinalType t) { m_ordinalType = t; }
229
230 /*!
231 \brief It returns the start time associated to the user-defined ordinal date and time.
232
233 \return The start time associated to the user-defined ordinal date and time.
234 */
235 TimeInstant getOrdinalStartTime() const { return m_ordinalStartTime; }
236
237 /*!
238 \brief It sets the start time associated to the user-defined ordinal date and time.
239
240 \param t The start time associated to the user-defined ordinal date and time.
241 */
242 void setOrdinalStartTime(TimeInstant t) { m_ordinalStartTime = t; }
243
244 /*!
245 \brief It returns the count of decimal digits in the fractional part, to the right of the decimal point.
246
247 \return The count of decimal digits in the fractional part, to the right of the decimal point.
248 */
249 unsigned int getPrecision() const { return m_precision; }
250
251 /*!
252 \brief Sets the count of decimal digits in the fractional part, to the right of the decimal point.
253 */
254 void setPrecision(unsigned int precision) { m_precision = precision; }
255
256 /*!
257 \brief It returns a clone of the object.
258
259 The new property will NOT have associations to other properties.
260
261 \return A clone of the object.
262 */
263 Property* clone() const;
264
265 protected:
266
267 DateTimeType m_dSubType; //!< The sub-type of this date time property.
268 TemporalResolution m_tempResolution; //!< The temporal resolution.
269 DateTimeStringFormat m_strFormat; //!< The string format when the data type is STRING_TIME
270 DateTimeOrdinalType m_ordinalType; //!< The ordinal type when the data type is ORDINAL_TIME.
271 TimeInstant m_ordinalStartTime; //!< The start time when the ordinal type is USER_DEFINED
272 unsigned int m_precision; //!< Number of digits for the right of the decimal point of a numeric value.
273 };
274
275 } // end namespace dt
276} // end namespace te
277
278#endif // __TERRALIB_DATATYPE_INTERNAL_DATETIMEPROPERTY_H
279
An atomic property like an integer or double.
A class to represent time instant.
The type for date and time types: date, date period, date duration, time duration,...
TimeInstant getOrdinalStartTime() const
It returns the start time associated to the user-defined ordinal date and time.
void setSubtype(DateTimeType t)
It sets the date time property sub type.
DateTimeProperty(const std::string &name, DateTimeType dateType=DATE, unsigned int precision=0, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new date and time property.
DateTimeType getSubType() const
It returns the date time property sub type.
void setStrFormat(DateTimeStringFormat f)
It sets the string format.
unsigned int getPrecision() const
It returns the count of decimal digits in the fractional part, to the right of the decimal point.
TemporalResolution getResolution() const
It returns the temporal resolution.
void setResolution(TemporalResolution t)
It sets the temporal resolution.
DateTimeProperty(const DateTimeProperty &rhs)
Copy constructor.
DateTimeStringFormat m_strFormat
The string format when the data type is STRING_TIME.
Property * clone() const
It returns a clone of the object.
DateTimeOrdinalType getOrdinalType() const
It returns the ordinal type, when the date and time is represented by a ordinal number.
DateTimeStringFormat getStrFormat() const
It returns the string format.
void setPrecision(unsigned int precision)
Sets the count of decimal digits in the fractional part, to the right of the decimal point.
DateTimeProperty(const std::string &name, TemporalResolution tmpRes, DateTimeOrdinalType ordType, TimeInstant startTime, unsigned int precision=0, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new date and time property that is represented by ordinal numbers.
void setOrdinalType(DateTimeOrdinalType t)
It sets the ordinal type.
DateTimeProperty(const std::string &name, DateTimeType dateType, TemporalResolution tmpRes, unsigned int precision=0, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new date and time property.
TemporalResolution m_tempResolution
The temporal resolution.
DateTimeProperty & operator=(const DateTimeProperty &rhs)
Assignment operator.
unsigned int m_precision
Number of digits for the right of the decimal point of a numeric value.
TimeInstant m_ordinalStartTime
The start time when the ordinal type is USER_DEFINED.
DateTimeType m_dSubType
The sub-type of this date time property.
DateTimeOrdinalType m_ordinalType
The ordinal type when the data type is ORDINAL_TIME.
void setOrdinalStartTime(TimeInstant t)
It sets the start time associated to the user-defined ordinal date and time.
DateTimeProperty(const std::string &name, TemporalResolution tmpRes, DateTimeStringFormat strFormat, unsigned int precision=0, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new date and time property that is represented by string.
It models a property definition.
Definition: Property.h:60
An atomic property like an integer or double.
A class to represent time instant.
Definition: TimeInstant.h:56
DateTimeStringFormat
The format of a string that represents a date and time.
Definition: Enums.h:70
DateTimeOrdinalType
The meaning of the ordial time.
Definition: Enums.h:86
DateTimeType
The subtype of date and time type, based on ISO 8621.
Definition: Enums.h:46
TerraLib.
A temporal resolution is composed of a unit of time and a value.
Definition: Enums.h:124
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
Enumerations of XML module.