TimePeriod.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/TimePeriod.h
22 
23  \brief A class to represent time period.
24 */
25 
26 #ifndef __TERRALIB_DATATYPE_INTERNAL_TIMEPERIOD_H
27 #define __TERRALIB_DATATYPE_INTERNAL_TIMEPERIOD_H
28 
29 // TerraLib
30 #include "DateTimePeriod.h"
31 
32 // Boost
33 #include <boost/date_time/posix_time/posix_time.hpp>
34 
35 namespace te
36 {
37  namespace dt
38  {
39  class TimeInstant;
40 
41  /*!
42  \class TimePeriod
43 
44  \brief A class to represent time period.
45 
46  A time period is a part of the continous time axis limited by two
47  time instants or points. Each time instant is composed
48  of a date that uses the Gregorian calendar and of a local time.
49  Internally, it uses the datetime boost library to represent time
50  period, by using the data type boost::posix_time::time_period.
51 
52  \sa DateTime, Date, DatePeriod, DateDuration, TimePeriodTZ, TimeInstant, TimeInstantTZ, TimeDuration
53  */
55  {
56  public:
57 
58  /*! \brief Constructor. */
59  TimePeriod();
60 
61  /*!
62  \brief Constructor.
63 
64  \param initialTime A initial time instant.
65  \param finalTime A final time instant.
66  */
67  TimePeriod(const TimeInstant& initialTime, const TimeInstant& finalTime);
68 
69  /*!
70  \brief Constructor.
71 
72  \param t A time period.
73  */
74  TimePeriod(const boost::posix_time::time_period& t);
75 
76  /*!
77  \brief Assignment operator.
78  */
79  //const TimePeriod& operator=(const TimePeriod& rhs);
80 
81  /*!
82  \brief It returns the boost time period type.
83 
84  \return The boost time period type.
85  */
86  const boost::posix_time::time_period& getTimePeriod() const { return m_timePeriod; }
87 
88  /*!
89  \brief It returns the boost time period type.
90 
91  \return The boost time period type.
92  */
93  boost::posix_time::time_period& getTimePeriod() { return m_timePeriod; }
94 
95  /*!
96  \brief It gets the initial time instant.
97 
98  \return The initial time instant
99  */
100  TimeInstant getInitialTimeInstant() const;
101 
102  /*!
103  \brief It gets the final time instant.
104 
105  \return The final time instant
106  */
107  TimeInstant getFinalTimeInstant() const;
108 
109  /*!
110  \brief It gets the initial date time instant.
111 
112  \return The initial time instant
113 
114  \note The caller will take the ownership of the returned pointer.
115  */
116  DateTimeInstant* getInitialInstant() const;
117 
118  /*!
119  \brief It gets the final date time instant.
120 
121  \return The final time instant
122 
123  \note The caller will take the ownership of the returned pointer.
124  */
125  DateTimeInstant* getFinalInstant() const;
126 
127  /*!
128  \brief Operator ==
129 
130  \param rhs The time period to be compared.
131 
132  \return It returns true if the two time period are equal. Otherwise, it returns false.
133  */
134  bool operator==(const DateTime& rhs) const;
135 
136  /*!
137  \brief Operator !=
138 
139  \param rhs The time period to be compared.
140 
141  \return It returns true if the two time periods are not equal. Otherwise, it returns false.
142  */
143  bool operator!=(const DateTime& rhs) const;
144 
145  /*!
146  \brief Operator <
147 
148  \param rhs The right-hand-side time period to be compared.
149 
150  \return It returns true if the right-hand-side time period is greater than the lefth side one. Otherwise, it returns false.
151  */
152  bool operator<(const DateTime& rhs) const;
153 
154  /*!
155  \brief Operator >
156 
157  \param rhs The right-hand-side time period to be compared.
158 
159  \return It returns true if the right-hand-side time period is less than the lefth side one. Otherwise, it returns false.
160  */
161  bool operator>(const DateTime& rhs) const;
162 
163  /*!
164  \brief It returns a clone of this object.
165 
166  \return A clone of this object.
167  */
168  AbstractData* clone() const;
169 
170  /*!
171  \brief It returns the time period in the ISO textual format (YYYYMMDDThhmmss/YYYYMMDDThhmmss).
172 
173  \return The time period in the ISO textual format (YYYYMMDDThhmmss/YYYYMMDDThhmmss).
174  */
175  std::string toString() const;
176 
177  /*!
178  \brief It returns the subtype of the date and time type.
179 
180  \return The subtype of the date and time type.
181  */
183 
184  /*!
185  \brief Destructor
186  */
187  virtual ~TimePeriod();
188 
189  protected:
190 
191  boost::posix_time::time_period m_timePeriod; //!< Time period information.
192  };
193 
194  } // end namespace dt
195 } // end namespace te
196 
197 #endif // __TERRALIB_DATATYPE_INTERNAL_TIMEPERIOD_H
198 
TEDATAACCESSEXPORT te::da::Expression * operator<(const te::da::Expression &e1, const te::da::Expression &e2)
DateTimeType getDateTimeType() const
It returns the subtype of the date and time type.
Definition: TimePeriod.h:182
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
A class to represent time instant.
Definition: TimeInstant.h:55
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
A class to represent time period.
Definition: TimePeriod.h:54
const boost::posix_time::time_period & getTimePeriod() const
Assignment operator.
Definition: TimePeriod.h:86
boost::posix_time::time_period & getTimePeriod()
It returns the boost time period type.
Definition: TimePeriod.h:93
An abstract class to represent a period of date and time.
DateTimeType
The subtype of date and time type, based on ISO 8621.
Definition: Enums.h:45
boost::posix_time::time_period m_timePeriod
Time period information.
Definition: TimePeriod.h:191
An abstract class to represent a period of date and time.
An abstract class to represent an instant of date and time.