All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OrdinalPeriod.h
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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/OrdinalPeriod.h
22 
23  \brief A class to represent ordinal time period.
24 */
25 
26 #ifndef __TERRALIB_DATATYPE_INTERNAL_ORDINALPERIOD_H
27 #define __TERRALIB_DATATYPE_INTERNAL_ORDINALPERIOD_H
28 
29 // TerraLib
30 #include "DateTimePeriod.h"
31 #include "SimpleData.h"
32 #include "OrdinalInstant.h"
33 
34 namespace te
35 {
36  namespace dt
37  {
38  /*!
39  \class OrdinalPeriod
40 
41  \brief A class to represent ordinal time period.
42 
43  A time period represented by two ordinal numbers: the first one
44  to represent the inital time and the second one the final time.
45  Examples: a time period whose initial time is the first
46  epidemiological week and the final time is the fifht epidemiological
47  week.
48 
49  \sa DateTime
50  */
52  {
53  public:
54 
55  /*! \brief Empty constructor. */
56  OrdinalPeriod();
57 
58  /*!
59  \brief Constructor.
60 
61  \param it The initial time instant.
62  \param ft The final time instant.
63  */
64  OrdinalPeriod(Int64 it, Int64 ft);
65 
66  /*!
67  \brief It returns the inital time instant.
68 
69  \return The initial time instant.
70  */
71  Int64 getInitialTime() const { return m_initialInstant.getTimeInstant(); }
72 
73  /*!
74  \brief It returns the final time instant.
75 
76  \return The final time instant.
77  */
78  Int64 getFinalTime() const { return m_finalInstant.getTimeInstant(); }
79 
80  /*!
81  \brief It gets the initial date time instant.
82 
83  \return The initial time instant
84 
85  \note The caller will take the ownership of the returned pointer.
86  */
87  DateTimeInstant* getInitialInstant() const;
88 
89  /*!
90  \brief It gets the final date time instant.
91 
92  \return The final time instant
93 
94  \note The caller will take the ownership of the returned pointer.
95  */
96  DateTimeInstant* getFinalInstant() const;
97 
98  /*!
99  \brief It sets the inital time instant.
100 
101  \param it The initial time instant.
102  */
103  void setInitialInstant(Int64 it) { m_initialInstant = it; }
104 
105  /*!
106  \brief It sets the final time instant.
107 
108  \param ft The final time instant.
109  */
110  void setFinalInstant(Int64 ft) { m_finalInstant = ft; }
111 
112  /*!
113  \brief Operator ==
114 
115  \param rhs The time period to be compared.
116 
117  \return It returns true if the two time periods are equal. Otherwise, it returns false.
118  */
119  bool operator==(const DateTime& rhs) const;
120 
121  /*!
122  \brief Operator !=
123 
124  \param rhs The time period to be compared.
125 
126  \return It returns true if the two time periods are not equal. Otherwise, it returns false.
127  */
128  bool operator!=(const DateTime& rhs) const;
129 
130  /*!
131  \brief Operator <
132 
133  \param rhs The right-hand-side time period to be compared.
134 
135  \return It returns true if the right-hand-side time period is greater than the lefth side one. Otherwise, it returns false.
136  */
137  bool operator<(const DateTime& rhs) const;
138 
139  /*!
140  \brief Operator >
141 
142  \param rhs The right-hand-side time period to be compared.
143 
144  \return It returns true if the right-hand-side time period is less than the lefth side one. Otherwise, it returns false.
145  */
146  bool operator>(const DateTime& rhs) const;
147 
148  /*!
149  \brief It returns a clone of this object.
150 
151  \return A clone of this object.
152  */
153  AbstractData* clone() const;
154 
155  /*!
156  \brief It returns the time period in a textual format (initialTimeInstant-finalTimeinstant)
157 
158  \return The time period in a textual format (initialTimeInstant-finalTimeinstant)
159  */
160  std::string toString() const;
161 
162  /*!
163  \brief It returns the subtype of the date and time type.
164 
165  \return The subtype of the date and time type.
166  */
168 
169  protected:
170 
171  OrdinalInstant m_initialInstant; //!< The initial time instant information.
172  OrdinalInstant m_finalInstant; //!< The final time instant information.
173  };
174 
175  } // end namespace dt
176 } // end namespace te
177 
178 #endif // __TERRALIB_DATATYPE_INTERNAL_ORDINALPERIOD_H
179 
A class to represent ordinal time period.
Definition: OrdinalPeriod.h:51
te::da::Expression * operator==(const te::da::Expression &e1, const te::da::Expression &e2)
Definition: Expression.cpp:38
te::da::Expression * operator>(const te::da::Expression &e1, const te::da::Expression &e2)
Definition: Expression.cpp:63
Int64 getInitialTime() const
It returns the inital time instant.
Definition: OrdinalPeriod.h:71
OrdinalInstant m_finalInstant
The final time instant information.
Int64 getFinalTime() const
It returns the final time instant.
Definition: OrdinalPeriod.h:78
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:64
te::da::Expression * operator<(const te::da::Expression &e1, const te::da::Expression &e2)
Definition: Expression.cpp:73
A class to represent ordinal time instant.
te::da::Expression * operator!=(const te::da::Expression &e1, const te::da::Expression &e2)
Definition: Expression.cpp:43
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
A class to represent ordinal time instant.
void setFinalInstant(Int64 ft)
It sets the final time instant.
An abstract class to represent a period of date and time.
OrdinalInstant m_initialInstant
The initial time instant information.
DateTimeType getDateTimeType() const
It returns the subtype of the date and time type.
DateTimeType
The subtype of date and time type.
Definition: Enums.h:38
This file contains several implementations for atomic data types (integers, floats, strings and others).
void setInitialInstant(Int64 it)
It sets the inital time instant.
An abstract class to represent a period of date and time.
An abstract class to represent an instant of date and time.