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 
34 namespace 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 isRequired It indicates if the the property is required (mandatory) or not.
57  \param defaultValue The default value to be used, 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 date time property will take the ownership of the defaultValue.
62 
63  \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
64  */
65  DateTimeProperty(const std::string& name,
66  DateTimeType dateType = DATE,
67  bool isRequired = false,
68  std::string* defaultValue = 0,
69  unsigned int id = 0,
70  Property* parent = 0);
71 
72  /*!
73  \brief It constructs a new date and time property.
74 
75  \param name The attribute name.
76  \param dateType The date and time subtype.
77  \param tmpRes The temporal resolution.
78  \param isRequired It indicates if the the property is required (mandatory) or not.
79  \param defaultValue The default value to be used, if none is informed.
80  \param id The property identifier.
81  \param parent A reference to the parent Property of the new object if it has one.
82 
83  \post The date time property will take the ownership of the defaultValue.
84 
85  \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
86  */
87  DateTimeProperty(const std::string& name,
88  DateTimeType dateType,
89  TemporalResolution tmpRes,
90  bool isRequired = false,
91  std::string* defaultValue = 0,
92  unsigned int id = 0,
93  Property* parent = 0);
94 
95  /*!
96  \brief It constructs a new date and time property that is represented by string
97 
98  \param name The attribute name.
99  \param tmpRes The temporal resolution.
100  \param strFormat The format of the string that represents a time information
101  \param isRequired It indicates if the the property is required (mandatory) or not.
102  \param defaultValue The default value to be used, if none is informed.
103  \param id The property identifier.
104  \param parent A reference to the parent Property of the new object if it has one.
105 
106  \post The date time property will take the ownership of the defaultValue.
107 
108  \note This constructor must be used when the data type is STRING_TIME
109 
110  \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
111  */
112  DateTimeProperty(const std::string& name,
113  TemporalResolution tmpRes,
114  DateTimeStringFormat strFormat,
115  bool isRequired = false,
116  std::string* defaultValue = 0,
117  unsigned int id = 0,
118  Property* parent = 0);
119 
120  /*!
121  \brief It constructs a new date and time property that is represented by ordinal numbers.
122 
123  \param name The attribute name.
124  \param tmpRes The temporal resolution.
125  \param ordType The type of the ordinal time
126  \param startTime The start time when the ordinal type is USER_DEFINED
127  \param isRequired It indicates if the the property is required (mandatory) or not.
128  \param defaultValue The default value to be used, if none is informed.
129  \param id The property identifier.
130  \param parent A reference to the parent Property of the new object if it has one.
131 
132  \post The date time property will take the ownership of the defaultValue.
133 
134  \note This constructor must be used when the data type is ORDINAL_TIME
135 
136  \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
137  */
138  DateTimeProperty(const std::string& name,
139  TemporalResolution tmpRes,
140  DateTimeOrdinalType ordType,
141  TimeInstant startTime,
142  bool isRequired = false,
143  std::string* defaultValue = 0,
144  unsigned int id = 0,
145  Property* parent = 0);
146 
147  /*!
148  \brief Copy constructor.
149 
150  \param rhs The right-hand-side copy used to copy from.
151  */
153 
154  /*! \brief Destructor. */
156 
157  /*!
158  \brief Assignment operator.
159 
160  \param rhs The right-hand-side copy used to copy from.
161 
162  \return A reference to this object.
163  */
164  DateTimeProperty& operator=(const DateTimeProperty& rhs);
165 
166  /*!
167  \brief It returns the date time property sub type.
168 
169  \return The string property sub type.
170  */
171  DateTimeType getSubType() const { return m_dSubType; }
172 
173  /*!
174  \brief It sets the date time property sub type.
175 
176  \param t The date time property sub type.
177  */
178  void setSubtype(DateTimeType t) { m_dSubType = t; }
179 
180  /*!
181  \brief It returns the temporal resolution.
182 
183  \return The temporal resolution.
184  */
185  TemporalResolution getResolution() const { return m_tempResolution; }
186 
187  /*!
188  \brief It sets the temporal resolution.
189 
190  \param r The temporal resolution.
191  */
192  void setResolution(TemporalResolution t) { m_tempResolution = t; }
193 
194  /*!
195  \brief It returns the string format
196 
197  \return The format of the string that represents the date and time
198  */
199  DateTimeStringFormat getStrFormat() const { return m_strFormat; }
200 
201  /*!
202  \brief It sets the string format
203 
204  \param f The format of the string that represents the date and time
205  */
206  void setStrFormat(DateTimeStringFormat f) { m_strFormat = f; }
207 
208  /*!
209  \brief It returns the ordinal type, when the date and time is represented by a ordinal number
210 
211  \return The ordinal type, when the date and time is represented by a ordinal number
212  */
213  DateTimeOrdinalType getOrdinalType() const { return m_ordinalType; }
214 
215  /*!
216  \brief It sets the ordinal type
217 
218  \param t The ordinal type, when the date and time is represented by a ordinal number
219  */
220  void setOrdinalType(DateTimeOrdinalType t) { m_ordinalType = t; }
221 
222  /*!
223  \brief It returns the start time associated to the user-defined ordinal date and time.
224 
225  \return The start time associated to the user-defined ordinal date and time.
226  */
227  TimeInstant getOrdinalStartTime() const { return m_ordinalStartTime; }
228 
229  /*!
230  \brief It sets the start time associated to the user-defined ordinal date and time.
231 
232  \param t The start time associated to the user-defined ordinal date and time.
233  */
234  void setOrdinalStartTime(TimeInstant t) { m_ordinalStartTime = t; }
235 
236  /*!
237  \brief It returns a clone of the object.
238 
239  The new property will NOT have associations to other properties.
240 
241  \return A clone of the object.
242  */
243  Property* clone() const;
244 
245  protected:
246 
247  DateTimeType m_dSubType; //!< The sub-type of this date time property.
248  TemporalResolution m_tempResolution; //!< The temporal resolution.
249  DateTimeStringFormat m_strFormat; //!< The string format when the data type is STRING_TIME
250  DateTimeOrdinalType m_ordinalType; //!< The ordinal type when the data type is ORDINAL_TIME.
251  TimeInstant m_ordinalStartTime; //!< The start time when the ordinal type is USER_DEFINED
252  };
253 
254  } // end namespace dt
255 } // end namespace te
256 
257 #endif // __TERRALIB_DATATYPE_INTERNAL_DATETIMEPROPERTY_H
258 
An atomic property like an integer or double.
void setResolution(TemporalResolution t)
It sets the temporal resolution.
DateTimeStringFormat getStrFormat() const
It returns the string format.
TimeInstant m_ordinalStartTime
The start time when the ordinal type is USER_DEFINED.
DateTimeOrdinalType
The meaning of the ordial time.
Definition: Enums.h:85
void setOrdinalStartTime(TimeInstant t)
It sets the start time associated to the user-defined ordinal date and time.
DateTimeOrdinalType m_ordinalType
The ordinal type when the data type is ORDINAL_TIME.
DateTimeStringFormat
The format of a string that represents a date and time.
Definition: Enums.h:69
It models a property definition.
Definition: Property.h:59
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
A class to represent time instant.
Definition: TimeInstant.h:55
DateTimeStringFormat m_strFormat
The string format when the data type is STRING_TIME.
TemporalResolution getResolution() const
It returns the temporal resolution.
A temporal resolution is composed of a unit of time and a value.
Definition: Enums.h:123
URI C++ Library.
A class to represent time instant.
void setStrFormat(DateTimeStringFormat f)
It sets the string format.
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.
void setOrdinalType(DateTimeOrdinalType t)
It sets the ordinal type.
DateTimeOrdinalType getOrdinalType() const
It returns the ordinal type, when the date and time is represented by a ordinal number.
An atomic property like an integer or double.
void setSubtype(DateTimeType t)
It sets the date time property sub type.
General enumerations for the data type module.
DateTimeType
The subtype of date and time type, based on ISO 8621.
Definition: Enums.h:45
DateTimeType getSubType() const
It returns the date time property sub type.
TimeInstant getOrdinalStartTime() const
It returns the start time associated to the user-defined ordinal date and time.
TemporalResolution m_tempResolution
The temporal resolution.
DateTimeType m_dSubType
The sub-type of this date time property.