All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DateTimeProperty.cpp
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.cpp
22 
23  \brief The type for date and time types: TIME_STAMP, TIME_STAMP_TZ, DATE, DATETIME, TIME or TIME_TZ.
24 */
25 
26 // TerraLib
27 #include "DateTimeProperty.h"
28 
30  DateTimeType dateType,
31  bool isRequired,
32  std::string* defaultValue,
33  unsigned int id,
34  Property* parent)
35  : SimpleProperty(name, DATETIME_TYPE, isRequired, defaultValue, id, parent),
36  m_dSubType(dateType),
37  m_tempResolution(te::dt::TemporalResolution()),
38  m_strFormat(UNKNOWN_STRING_FORMAT),
39  m_ordinalType(USER_DEFINED),
40  m_ordinalStartTime(te::dt::TimeInstant())
41 {
42 }
43 
45  DateTimeType dateType,
46  TemporalResolution tmpRes,
47  bool isRequired,
48  std::string* defaultValue,
49  unsigned int id,
50  Property* parent)
51  : SimpleProperty(name, DATETIME_TYPE, isRequired, defaultValue, id, parent),
52  m_dSubType(dateType),
53  m_tempResolution(tmpRes),
54  m_strFormat(UNKNOWN_STRING_FORMAT),
55  m_ordinalType(USER_DEFINED),
56  m_ordinalStartTime(te::dt::TimeInstant())
57 {
58 }
59 
60 
62  TemporalResolution tmpRes,
63  DateTimeStringFormat strFormat,
64  bool isRequired,
65  std::string* defaultValue,
66  unsigned int id,
67  Property* parent)
68  : SimpleProperty(name, STRING_TYPE, isRequired, defaultValue, id, parent),
69  m_dSubType(STRING_TIME),
70  m_tempResolution(tmpRes),
71  m_strFormat(strFormat),
72  m_ordinalType(USER_DEFINED),
73  m_ordinalStartTime(te::dt::TimeInstant())
74 {
75 }
76 
78  TemporalResolution tmpRes,
79  DateTimeOrdinalType ordType,
80  TimeInstant startTime,
81  bool isRequired,
82  std::string* defaultValue,
83  unsigned int id,
84  Property* parent)
85  : SimpleProperty(name, UINT64_TYPE, isRequired, defaultValue, id, parent),
86  m_dSubType(ORDINAL_TIME_INSTANT),
87  m_tempResolution(tmpRes),
88  m_strFormat(UNKNOWN_STRING_FORMAT),
89  m_ordinalType(ordType),
90  m_ordinalStartTime(startTime)
91 {
92 }
93 
95  : SimpleProperty(rhs),
96  m_dSubType(rhs.m_dSubType),
97  m_tempResolution(rhs.m_tempResolution),
98  m_strFormat(rhs.m_strFormat),
99  m_ordinalType(rhs.m_ordinalType),
100  m_ordinalStartTime(rhs.m_ordinalStartTime)
101 {
102 }
103 
105 {
106  if(this != &rhs)
107  {
109 
110  m_dSubType = rhs.m_dSubType;
111  m_tempResolution = rhs.m_tempResolution;
112  m_strFormat = rhs.m_strFormat;
113  m_ordinalType = rhs.m_ordinalType;
114  m_ordinalStartTime = rhs.m_ordinalStartTime;
115  }
116 
117  return *this;
118 }
119 
121 {
122  return new DateTimeProperty(*this);
123 }
124 
An atomic property like an integer or double.
TimeInstant m_ordinalStartTime
The start time when the ordinal type is USER_DEFINED.
DateTimeOrdinalType
The meaning of the ordial time.
Definition: Enums.h:85
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
A class to represent time instant.
Definition: TimeInstant.h:55
DateTimeStringFormat m_strFormat
The string format when the data type is STRING_TIME.
DateTimeProperty(const std::string &name, DateTimeType dateType=DATE, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new date and time property.
A temporal resolution is composed of a unit of time and a value.
Definition: Enums.h:123
SimpleProperty & operator=(const SimpleProperty &rhs)
Assignment operator.
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.
The type for date and time types.
Property * clone() const
It returns a clone of the object.
DateTimeType
The subtype of date and time type, based on ISO 8621.
Definition: Enums.h:45
TemporalResolution m_tempResolution
The temporal resolution.
DateTimeProperty & operator=(const DateTimeProperty &rhs)
Assignment operator.
DateTimeType m_dSubType
The sub-type of this date time property.