All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Observation.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 Observation.cpp
22 
23  \brief A class to represent an observation.
24  */
25 
26 // TerraLib
27 #include "../../../datatype/AbstractData.h"
28 #include "../../../datatype/DateTime.h"
29 #include "../../../datatype/TimeInstant.h"
30 #include "../../../datatype/TimePeriod.h"
31 
32 //DyGeo
33 #include "Observation.h"
34 
36  : m_phTime(),
37  m_resultTime(),
38  m_validTime()
39 {
40 }
41 
43  : m_phTime(phTime),
44  m_resultTime(),
45  m_validTime()
46 {
47 }
48 
50  : m_phTime(phTime),
51  m_resultTime(),
52  m_validTime()
53 {
54  m_observedValues.push_back(obsValue);
55 }
56 
58  const boost::ptr_vector<te::dt::AbstractData>& obsValues)
59  : m_phTime(phTime),
60  m_resultTime(),
61  m_validTime(),
62  m_observedValues(obsValues)
63  {
64  }
65 
67  te::dt::DateTimePeriod* valTime,
68  const boost::ptr_vector<te::dt::AbstractData>& obsValues)
69  : m_phTime(phTime),
70  m_resultTime(resTime),
71  m_validTime(valTime),
72  m_observedValues(obsValues)
73 {
74 }
75 
77 {
78  *this = obs;
79 }
80 
82 {
83  if(this == &rhs)
84  return *this;
85 
86  m_phTime.reset();
87  m_resultTime.reset();
88  m_validTime.reset();
89  m_observedValues.clear();
90 
91  if(rhs.m_phTime.get())
92  m_phTime.reset(dynamic_cast<te::dt::DateTime*>(rhs.m_phTime->clone()));
93  if(rhs.m_resultTime.get())
94  m_resultTime.reset(dynamic_cast<te::dt::DateTimeInstant*>(rhs.m_resultTime->clone()));
95  if(rhs.m_validTime.get())
96  m_validTime.reset(dynamic_cast<te::dt::DateTimePeriod*>(rhs.m_validTime->clone()));
97 
98  m_observedValues = rhs.m_observedValues.clone();
99  return *this;
100 }
101 
103 {
104  return m_phTime.get();
105 }
106 
108 {
109  m_phTime.reset(phTime);
110 }
111 
113 {
114  return m_resultTime.get();
115 }
116 
118 {
119  m_resultTime.reset(resTime);
120 }
121 
123 {
124  return m_validTime.get();
125 }
126 
128 {
129  m_validTime.reset(valTime);
130 }
131 
132 boost::ptr_vector<te::dt::AbstractData>& te::st::Observation::getObservedValues()
133 {
134  return m_observedValues;
135 }
136 
138 {
139  return &m_observedValues[idx];
140 }
141 
143 {
144  m_observedValues.push_back(value);
145 }
146 
147 void te::st::Observation::setValues(const boost::ptr_vector<te::dt::AbstractData>& values)
148 {
149  m_observedValues.clear();
150  m_observedValues = values; //deep copy?
151 }
152 
154 {
155  return new Observation(*this);
156 }
157 
159 {
160 }
161 
162 
te::dt::DateTimeInstant * getResultTime() const
It returns the result time.
const Observation & operator=(const Observation &rhs)
Assignment operator.
Definition: Observation.cpp:81
boost::ptr_vector< te::dt::AbstractData > m_observedValues
The observed values.
Definition: Observation.h:224
virtual ~Observation()
Virtual destructor.
Observation * clone() const
It returns a clone of this object.
void setTime(te::dt::DateTime *phTime)
It sets the phenomenon time.
A class to represent an observation.
Definition: Observation.h:58
void addValue(te::dt::AbstractData *value)
It adds an observed value.
const te::dt::AbstractData * getObservedValue(int idx=0) const
It returns the idx-th observed value.
void setResultTime(te::dt::DateTimeInstant *resTime)
It sets the result time.
An abstract class to represent a period of date and time.
Observation()
It constructs an empty Observation.
Definition: Observation.cpp:35
void setValidTime(te::dt::DateTimePeriod *valTime)
It sets the valid time.
void setValues(const boost::ptr_vector< te::dt::AbstractData > &values)
It sets the observed values.
std::auto_ptr< te::dt::DateTimeInstant > m_resultTime
The result time.
Definition: Observation.h:222
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
An abstract class to represent an instant of date and time.
boost::ptr_vector< te::dt::AbstractData > & getObservedValues()
It returns the observed values.
std::auto_ptr< te::dt::DateTime > m_phTime
The phenomenon time.
Definition: Observation.h:221
te::dt::DateTimePeriod * getValidTime() const
It returns the valid time.
te::dt::DateTime * getTime() const
It returns the phenomenon time.
std::auto_ptr< te::dt::DateTimePeriod > m_validTime
The valid time.
Definition: Observation.h:223