Loading...
Searching...
No Matches
TimeSeriesObservation.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 TimeSeriesObservation.h
22
23 \brief This file contains a class to represent a time series observation.
24*/
25
26#ifndef __TERRALIB_ST_INTERNAL_TIMESERIESOBSERVATION_H
27#define __TERRALIB_ST_INTERNAL_TIMESERIESOBSERVATION_H
28
29//TerraLib
30#include "../../../datatype/DateTime.h"
31#include "../../../datatype/AbstractData.h"
32
33//ST
34#include "../../Config.h"
35
36//STL
37#include <vector>
38
39//Boost
40#include <boost/shared_ptr.hpp>
41#include <boost/multi_index_container.hpp>
42#include <boost/multi_index/ordered_index.hpp>
43#include <boost/multi_index/identity.hpp>
44#include <boost/multi_index/mem_fun.hpp>
45
46// Forward declarations
47namespace te { namespace dt { class AbstractData; class DateTime; } }
48
49namespace te
50{
51 namespace st
52 {
53 /*!
54 \class TimeSeriesObservation.
55
56 \brief A class to represent an observation (time and value) of a time series.
57
58 \sa TimeSeries
59 */
61 {
62 public:
63
64 /*!
65 \brief Constructor.
66
67 \param t A date time.
68 \param v A value.
69
70 \note It will take the ownership of the input pointers.
71 */
73
74 /*! \brief It returns the date time.
75
76 \note The caller will not take the ownership of the returned pointer.
77 */
79
80 /*! \brief It sets the date time.
81
82 \note The caller will take the ownership of the returned pointer.
83 */
85
86 /*! \brief It returns the value.
87
88 \note The caller will not take the ownership of the returned pointer.
89 */
91
92 /*! \brief It returns the value as a double. */
93 double getDouble() const;
94
95 /*! \brief It returns the value as a integer. */
96 int getInt() const;
97
98 /*! \brief It returns the value as a string. */
99 std::string getString() const;
100
101 /*! \brief Operator <.
102
103 It returns TRUE if the internal time is less than the time of the object "other".
104 Otherwise, it returns FALSE.
105 */
106 bool operator<(const TimeSeriesObservation& other) const;
107
108 /*!
109 \brief Destructor.
110 */
112
113 protected:
114
117 };
118
119 //typedef TimeSeriesObservationSet
120 typedef boost::multi_index_container<
122 boost::multi_index::indexed_by<
123 //(0) indexed by time using the operator <
124 boost::multi_index::ordered_unique<
125 boost::multi_index::identity<TimeSeriesObservation> >,
126
127 //(1) indexed by value as double
128 boost::multi_index::ordered_non_unique<
129 boost::multi_index::const_mem_fun<TimeSeriesObservation, double, &TimeSeriesObservation::getDouble> >,
130
131 //(2) indexed by value as string
132 boost::multi_index::ordered_non_unique<
133 boost::multi_index::const_mem_fun<TimeSeriesObservation, std::string, &TimeSeriesObservation::getString> >
134
136
137 typedef TimeSeriesObservationSet::nth_index<0>::type TimeSeriesByTime;
138
139 typedef TimeSeriesObservationSet::nth_index<1>::type TimeSeriesByValue;
140
141 } // end namespace st
142} // end namespace te
143
144#endif // __TERRALIB_ST_INTERNAL_TIMESERIESOBSERVATION_H
145
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
A class to represent an observation (time and value) of a time series.
te::dt::AbstractDataShrPtr m_value
te::dt::DateTime * getTime() const
It returns the date time.
te::dt::AbstractData * getValue() const
It returns the value.
int getInt() const
It returns the value as a integer.
bool operator<(const TimeSeriesObservation &other) const
Operator <.
TimeSeriesObservation(te::dt::DateTime *t, te::dt::AbstractData *v)
Constructor.
void setTime(te::dt::DateTime *t)
It sets the date time.
std::string getString() const
It returns the value as a string.
double getDouble() const
It returns the value as a double.
std::shared_ptr< AbstractData > AbstractDataShrPtr
Definition: AbstractData.h:96
boost::shared_ptr< DateTime > DateTimeShrPtr
Definition: DateTime.h:126
TimeSeriesObservationSet::nth_index< 0 >::type TimeSeriesByTime
TimeSeriesObservationSet::nth_index< 1 >::type TimeSeriesByValue
boost::multi_index_container< TimeSeriesObservation, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::identity< TimeSeriesObservation > >, boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun< TimeSeriesObservation, double, &TimeSeriesObservation::getDouble > >, boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun< TimeSeriesObservation, std::string, &TimeSeriesObservation::getString > > > > TimeSeriesObservationSet
TerraLib.
#define TESTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:88