Loading...
Searching...
No Matches
DataSetItem.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/memory/DataSetItem.h
22
23 \brief An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver.
24*/
25
26#ifndef __TERRALIB_DATAACCESS_INTERNAL_DATASETITEM_H
27#define __TERRALIB_DATAACCESS_INTERNAL_DATASETITEM_H
28
29// TerraLib
30#include "../Config.h"
31
32#include <boost/cstdint.hpp>
33#include <boost/noncopyable.hpp>
34#include <boost/ptr_container/ptr_vector.hpp>
35#include <boost/shared_ptr.hpp>
36
37#include <string>
38#include <vector>
39
40// Forward declarations
41namespace te { namespace dt { class AbstractData; class Array; class ByteArray; class DateTime; } }
42namespace te { namespace gm { class Geometry; } }
43namespace te { namespace rst { class Raster; } }
44
45namespace te
46{
47 namespace da
48 {
49 // Forward declaration
50 class DataSet;
51 class DataSetType;
52
53 /*!
54 \class DataSetItem
55
56 \brief An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver.
57 */
59 {
60 public:
61
62 /*!
63 \brief It creates a new item having the same schema as the given column names and types
64
65 \param vecNames The names of the properties of this item
66 \param vecTypes The types of the properties of this item
67 */
68 explicit DataSetItem(const std::vector<std::string>& vecNames, const std::vector<int>& vecTypes);
69
70 /*!
71 \brief It creates a new item having the same schema as the parent dataset.
72
73 \param parent The dataset to which this item is associated.
74
75 \note The dataset item will NOT take the ownership of the given pointer.
76 */
77 explicit DataSetItem(const te::da::DataSet* dataSet);
78
79 /*!
80 \brief It creates a new item having the same schema as the dataset type.
81
82 \param parent The dataset to which this item is associated.
83
84 \note The dataset item will NOT take the ownership of the given pointer.
85 */
86 explicit DataSetItem(const te::da::DataSetType* dataSetType);
87
88 /*!
89 \brief It creates a new item by cloning the values in the source item (rhs).
90
91 \param rhs The right-hand-side object to copy its values.
92 */
93 explicit DataSetItem(const DataSetItem& rhs);
94
95 /*! \brief Destructor. */
96 virtual ~DataSetItem();
97
98 /*!
99 \brief Creates a dataSetItem based on the current row of the givem DataSet
100 */
102
103 /*!
104 \brief Assignment operator.
105
106 It copies the values from the rhs item.
107
108 \param rhs The right-hand-side ibject to copy its values.
109
110 \return A reference to this item.
111
112 \pre The rhs item must be of a compatible type with the item being assigned.
113 */
114
116
117 /*!
118 \brief It returns a clone of the DataSetItem.
119 */
120 virtual DataSetItem* clone() const;
121
122 /*!
123 \brief It returns the number of properties.
124 */
125 std::size_t getNumProperties() const;
126
127 /*!
128 \brief It returns the name of properties.
129 */
130 const std::vector<std::string>& getPropertyNames() const;
131
132 /*!
133 \brief It returns the types of properties.
134 */
135 const std::vector<int>& getPropertyTypes() const;
136
137 /*!
138 \brief It returns the type of the pos-th property.
139 */
140 int getPropertyDataType(std::size_t pos) const;
141
142 /*!
143 \brief It returns the name of the pos-th property.
144 */
145 const std::string& getPropertyName(std::size_t pos) const;
146
147 /*!
148 \brief It returns the name of the pos-th property.
149 */
150 std::size_t getPropertyPos(const std::string& name) const;
151
152 /*!
153 \brief It returns the value of the i-th property.
154 */
155 char getChar(std::size_t i) const;
156
157 /*!
158 \brief It returns the value of the i-th property.
159 */
160 unsigned char getUChar(std::size_t i) const;
161
162 /*!
163 \brief It returns the value of the i-th property.
164 */
165 boost::int16_t getInt16(std::size_t i) const;
166
167 /*!
168 \brief It returns the value of the i-th property.
169 */
170 boost::int32_t getInt32(std::size_t i) const;
171
172 /*!
173 \brief It returns the value of the i-th property.
174 */
175 boost::int64_t getInt64(std::size_t i) const;
176
177 /*!
178 \brief It returns the value of the i-th property.
179 */
180 bool getBool(std::size_t i) const;
181
182 /*!
183 \brief It returns the value of the i-th property.
184 */
185 float getFloat(std::size_t i) const;
186
187 /*!
188 \brief It returns the value of the i-th property.
189 */
190 double getDouble(std::size_t i) const;
191
192 /*!
193 \brief It returns the value of the i-th property.
194 */
195 std::string getNumeric(std::size_t i) const;
196
197 /*!
198 \brief It returns the value of the i-th property.
199 */
200 std::string getString(std::size_t i) const;
201
202 /*!
203 \brief It returns the value of the i-th property.
204 */
205 std::unique_ptr<te::dt::ByteArray> getByteArray(std::size_t i) const;
206
207 /*!
208 \brief It returns the value of the i-th property.
209 */
210 std::unique_ptr<te::gm::Geometry> getGeometry(std::size_t i) const;
211
212 /*!
213 \brief It returns the value of the i-th property.
214 */
215 std::unique_ptr<te::rst::Raster> getRaster(std::size_t i) const;
216
217 /*!
218 \brief It returns the value of the i-th property.
219 */
220 std::unique_ptr<te::dt::DateTime> getDateTime(std::size_t i) const;
221
222 /*!
223 \brief It returns the value of the i-th property.
224 */
225 std::unique_ptr<te::dt::AbstractData> getValue(std::size_t i) const;
226
227 /*!
228 \brief Checks if the value in the given index is null
229 */
230 bool isNull(std::size_t i) const;
231
232 protected:
233
234 std::vector<std::string> m_vecNames; //!< Vector containing the names of the attributes of the dataSet item
235 std::vector<int> m_vecTypes; //!< Vector containing the types of the attributes of the dataSet item
236 boost::ptr_vector<boost::nullable<te::dt::AbstractData> > m_data; //!< The data values of the
237 };
238 }// end namespace da
239}// end namespace te
240
241#endif // __TERRALIB_DATAACCESS_INTERNAL_DATASETITEM_H
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver.
Definition: DataSetItem.h:59
const std::vector< std::string > & getPropertyNames() const
It returns the name of properties.
boost::ptr_vector< boost::nullable< te::dt::AbstractData > > m_data
The data values of the.
Definition: DataSetItem.h:236
static te::da::DataSetItem * createFromCurrent(const te::da::DataSet *dataSet)
Creates a dataSetItem based on the current row of the givem DataSet.
bool isNull(std::size_t i) const
Checks if the value in the given index is null.
virtual ~DataSetItem()
Destructor.
std::vector< std::string > m_vecNames
Vector containing the names of the attributes of the dataSet item.
Definition: DataSetItem.h:234
float getFloat(std::size_t i) const
It returns the value of the i-th property.
std::size_t getPropertyPos(const std::string &name) const
It returns the name of the pos-th property.
std::unique_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const
It returns the value of the i-th property.
char getChar(std::size_t i) const
It returns the value of the i-th property.
DataSetItem(const std::vector< std::string > &vecNames, const std::vector< int > &vecTypes)
It creates a new item having the same schema as the given column names and types.
bool getBool(std::size_t i) const
It returns the value of the i-th property.
std::vector< int > m_vecTypes
Vector containing the types of the attributes of the dataSet item.
Definition: DataSetItem.h:235
boost::int32_t getInt32(std::size_t i) const
It returns the value of the i-th property.
DataSetItem(const te::da::DataSet *dataSet)
It creates a new item having the same schema as the parent dataset.
std::string getString(std::size_t i) const
It returns the value of the i-th property.
DataSetItem(const DataSetItem &rhs)
It creates a new item by cloning the values in the source item (rhs).
const std::string & getPropertyName(std::size_t pos) const
It returns the name of the pos-th property.
std::unique_ptr< te::dt::AbstractData > getValue(std::size_t i) const
It returns the value of the i-th property.
boost::int16_t getInt16(std::size_t i) const
It returns the value of the i-th property.
double getDouble(std::size_t i) const
It returns the value of the i-th property.
std::unique_ptr< te::rst::Raster > getRaster(std::size_t i) const
It returns the value of the i-th property.
std::size_t getNumProperties() const
It returns the number of properties.
std::string getNumeric(std::size_t i) const
It returns the value of the i-th property.
std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const
It returns the value of the i-th property.
unsigned char getUChar(std::size_t i) const
It returns the value of the i-th property.
DataSetItem(const te::da::DataSetType *dataSetType)
It creates a new item having the same schema as the dataset type.
const std::vector< int > & getPropertyTypes() const
It returns the types of properties.
virtual DataSetItem * clone() const
It returns a clone of the DataSetItem.
boost::int64_t getInt64(std::size_t i) const
It returns the value of the i-th property.
std::unique_ptr< te::dt::DateTime > getDateTime(std::size_t i) const
It returns the value of the i-th property.
DataSetItem & operator=(const DataSetItem &rhs)
Assignment operator.
int getPropertyDataType(std::size_t pos) const
It returns the type of the pos-th property.
A class that models the description of a dataset.
Definition: DataSetType.h:73
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
TerraLib.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97