All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OrdinalPeriod.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/OrdinalPeriod.cpp
22 
23  \brief A class to represent ordinal time period.
24 */
25 
26 // TerraLib
27 #include "OrdinalPeriod.h"
28 
30  : m_initialInstant(),
31  m_finalInstant()
32 {
33 }
34 
36  : m_initialInstant(it),
37  m_finalInstant(ft)
38 {
39 }
40 
42 {
43  return new te::dt::OrdinalInstant(m_initialInstant);
44 }
45 
47 {
48  return new te::dt::OrdinalInstant(m_finalInstant);
49 }
50 
52 {
53  const te::dt::OrdinalPeriod* t = dynamic_cast<const te::dt::OrdinalPeriod*>(&rhs);
54  return (m_initialInstant == t->m_initialInstant &&
55  m_finalInstant == t->m_finalInstant);
56 }
57 
59 {
60  const te::dt::OrdinalPeriod* t = dynamic_cast<const te::dt::OrdinalPeriod*>(&rhs);
61  return (m_initialInstant != t->m_initialInstant ||
62  m_finalInstant != t->m_finalInstant);
63 }
64 
66 {
67  const te::dt::OrdinalPeriod* t = dynamic_cast<const te::dt::OrdinalPeriod*>(&rhs);
68  return m_finalInstant < t->m_initialInstant;
69 }
70 
72 {
73  const te::dt::OrdinalPeriod* t = dynamic_cast<const te::dt::OrdinalPeriod*>(&rhs);
74  return m_initialInstant > t->m_finalInstant;
75 }
76 
78 {
79  return new OrdinalPeriod(*this);
80 }
81 
82 std::string te::dt::OrdinalPeriod::toString() const
83 {
84  return std::string(m_initialInstant.toString() + "-" + m_finalInstant.toString());
85 }
86 
A class to represent ordinal time period.
Definition: OrdinalPeriod.h:55
std::string toString() const
It returns the time period in a textual format (initialTimeInstant-finalTimeinstant) ...
OrdinalInstant m_finalInstant
The final time instant information.
A class to represent ordinal time period.
DateTimeInstant * getInitialInstant() const
It gets the initial date time instant.
bool operator>(const DateTime &rhs) const
Operator >
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
AbstractData * clone() const
It returns a clone of this object.
DateTimeInstant * getFinalInstant() const
It gets the final date time instant.
A class to represent ordinal time instant.
bool operator<(const DateTime &rhs) const
Operator <.
OrdinalInstant m_initialInstant
The initial time instant information.
OrdinalPeriod()
Empty constructor.
bool operator==(const DateTime &rhs) const
Operator ==.
An abstract class to represent an instant of date and time.
bool operator!=(const DateTime &rhs) const
Operator !=.