datatype/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  unsigned int precision,
32  bool isRequired,
33  std::string* defaultValue,
34  unsigned int id,
35  Property* parent)
36  : SimpleProperty(name, DATETIME_TYPE, isRequired, defaultValue, id, parent),
37  m_dSubType(dateType),
38  m_tempResolution(te::dt::TemporalResolution()),
39  m_strFormat(UNKNOWN_STRING_FORMAT),
40  m_ordinalType(USER_DEFINED),
41  m_ordinalStartTime(te::dt::TimeInstant()),
42  m_precision(precision)
43 {
44 }
45 
47  DateTimeType dateType,
48  TemporalResolution tmpRes,
49  unsigned int precision,
50  bool isRequired,
51  std::string* defaultValue,
52  unsigned int id,
53  Property* parent)
54  : SimpleProperty(name, DATETIME_TYPE, isRequired, defaultValue, id, parent),
55  m_dSubType(dateType),
56  m_tempResolution(tmpRes),
60  m_precision(precision)
61 {
62 }
63 
64 
66  TemporalResolution tmpRes,
67  DateTimeStringFormat strFormat,
68  unsigned int precision,
69  bool isRequired,
70  std::string* defaultValue,
71  unsigned int id,
72  Property* parent)
73  : SimpleProperty(name, STRING_TYPE, isRequired, defaultValue, id, parent),
75  m_tempResolution(tmpRes),
76  m_strFormat(strFormat),
79  m_precision(precision)
80 {
81 }
82 
84  TemporalResolution tmpRes,
85  DateTimeOrdinalType ordType,
86  TimeInstant startTime,
87  unsigned int precision,
88  bool isRequired,
89  std::string* defaultValue,
90  unsigned int id,
91  Property* parent)
92  : SimpleProperty(name, UINT64_TYPE, isRequired, defaultValue, id, parent),
94  m_tempResolution(tmpRes),
96  m_ordinalType(ordType),
97  m_ordinalStartTime(startTime),
98  m_precision(precision)
99 {
100 }
101 
103 
104  = default;
105 
107 {
108  if(this != &rhs)
109  {
111 
112  m_dSubType = rhs.m_dSubType;
114  m_strFormat = rhs.m_strFormat;
117  m_precision = rhs.m_precision;
118  }
119 
120  return *this;
121 }
122 
124 {
125  return new DateTimeProperty(*this);
126 }
127 
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.
An atomic property like an integer or double.
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.
DateTimeOrdinalType
The meaning of the ordial 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.
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.
A temporal resolution is composed of a unit of time and a value.
URI C++ Library.
Definition: Attributes.h:37
static te::dt::TimeDuration dt(20, 30, 50, 11)
SimpleProperty & operator=(const SimpleProperty &rhs)
Assignment operator.
bool isRequired() const
It returns true if the attribute is required, otherwise it returns false.
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.
TemporalResolution m_tempResolution
The temporal resolution.
DateTimeProperty & operator=(const DateTimeProperty &rhs)
Assignment operator.
DateTimeType m_dSubType
The sub-type of this date time property.