DateTime.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/DateTime.h
22 
23  \brief An abstract class for date and time types.
24 */
25 
26 #ifndef __TERRALIB_DATATYPE_INTERNAL_DATETIME_H
27 #define __TERRALIB_DATATYPE_INTERNAL_DATETIME_H
28 
29 // TerraLib
30 #include "AbstractData.h"
31 #include "Enums.h"
32 
33 // Boost
34 #include <boost/shared_ptr.hpp>
35 
36 namespace te
37 {
38  namespace dt
39  {
40  /*!
41  \class DataTime
42 
43  \brief An abstract class for date and time types.
44 
45  It is a base class for different kinds of date and time representations,
46  such as, date and date period, time instant and period,
47  time with and without time zone, etc.
48 
49  For more information see ISO 8601:2004 and ISO 19108:2002.
50 
51  \note The DateTime classes can throw exceptions derived from std::out_of_range.
52 
53  \sa AbstractData, DateTimeInstant, DateDuration, TimeDuration
54  */
56  {
57  public:
58 
59  /*! \brief Default constructor. */
60  DateTime() {}
61 
62  /*!
63  \brief Operator ==
64 
65  \param rhs The date and time to be compared.
66 
67  \return It returns true if the two date and time are equal. Otherwise, it returns false.
68  */
69  virtual bool operator==(const DateTime&) const = 0;
70 
71  /*!
72  \brief Operator !=
73 
74  \param rhs The date and time to be compared.
75 
76  \return It returns true if the two date and time are not equal. Otherwise, it returns false.
77  */
78  virtual bool operator!=(const DateTime&) const = 0;
79 
80  /*!
81  \brief Operator <
82 
83  \param rhs The date and time to be compared.
84 
85  \return It returns true if the right-hand-side time is greater than the lefth side one. Otherwise, it returns false.
86  */
87  virtual bool operator<(const DateTime&) const = 0;
88 
89  /*!
90  \brief Operator >
91 
92  \param rhs The right-hand-side time duration to be compared.
93 
94  \return It returns true if the right-hand-side time duration is less than the lefth side one. Otherwise, it returns false.
95  */
96  virtual bool operator>(const DateTime&) const = 0;
97 
98  /*!
99  \brief It returns the data type code associated to date and time values: DATETIME_TYPE.
100 
101  \return The data type code associated to the date and time values: DATETIME_TYPE.
102  */
103  int getTypeCode() const { return DATETIME_TYPE; }
104 
105  /*!
106  \brief It returns the subtype of the date and time type.
107 
108  \return The subtype of the date and time type.
109  */
110  virtual DateTimeType getDateTimeType() const = 0;
111 
112  /*! \brief Virtual destructor. */
113  virtual ~DateTime() { }
114  };
115 
116  /*! \brief An auxiliary struct to compare two datetime pointers */
118  {
119  bool operator()(const te::dt::DateTime* t1, const te::dt::DateTime* t2) const
120  {
121  return t1->operator<(*t2);
122  }
123  };
124 
125  //Typedef
126  typedef boost::shared_ptr<DateTime> DateTimeShrPtr;
127 
128  } // end namespace dt
129 } // end namespace te
130 
131 #endif // __TERRALIB_DATATYPE_INTERNAL_DATETIME_H
132 
TEDATAACCESSEXPORT te::da::Expression * operator<(const te::da::Expression &e1, const te::da::Expression &e2)
virtual ~DateTime()
Virtual destructor.
Definition: DateTime.h:113
A base class for objects that can be retrieved from the data access module.
An auxiliary struct to compare two datetime pointers.
Definition: DateTime.h:117
TEDATAACCESSEXPORT te::da::Expression * operator==(const te::da::Expression &e1, const te::da::Expression &e2)
TEDATAACCESSEXPORT te::da::Expression * operator!=(const te::da::Expression &e1, const te::da::Expression &e2)
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
boost::shared_ptr< DateTime > DateTimeShrPtr
Definition: DateTime.h:126
URI C++ Library.
TEDATAACCESSEXPORT te::da::Expression * operator>(const te::da::Expression &e1, const te::da::Expression &e2)
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
DateTime()
Default constructor.
Definition: DateTime.h:60
int getTypeCode() const
It returns the data type code associated to date and time values: DATETIME_TYPE.
Definition: DateTime.h:103
General enumerations for the data type module.
DateTimeType
The subtype of date and time type, based on ISO 8621.
Definition: Enums.h:45
bool operator()(const te::dt::DateTime *t1, const te::dt::DateTime *t2) const
Definition: DateTime.h:119