All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataSetItem.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/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_MEMORY_INTERNAL_DATASETITEM_H
27 #define __TERRALIB_MEMORY_INTERNAL_DATASETITEM_H
28 
29 // TerraLib
30 #include "Config.h"
31 
32 // Boost
33 #include <boost/cstdint.hpp>
34 #include <boost/ptr_container/ptr_vector.hpp>
35 
36 // Forward declarations
37 namespace te { namespace dt { class AbstractData; class Array; class ByteArray; class DateTime; } }
38 namespace te { namespace gm { class Geometry; } }
39 namespace te { namespace rst { class Raster; } }
40 
41 namespace te
42 {
43  namespace core
44  {
45 // Forward declaration
46  class DataSet;
47  }
48 
49  namespace mem
50  {
51  /*!
52  \class DataSetItem
53 
54  \brief An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver.
55  */
57  {
58  public:
59 
60  /*!
61  \brief It creates a new item having the same schema as the parent dataset.
62 
63  \param parent The dataset to which this item is associated.
64 
65  \note The dataset item will NOT take the ownership of the given pointer.
66  */
67  explicit DataSetItem(const te::da::DataSet* parent);
68 
69  /*!
70  \brief It creates a new item by cloning the values in the source item (rhs).
71 
72  \param rhs The right-hand-side object to copy its values.
73  */
74  explicit DataSetItem(const DataSetItem& rhs);
75 
76  /*! \brief Destructor. */
77  ~DataSetItem();
78 
79  /*!
80  \brief Assignment operator.
81 
82  It copies the values from the rhs item.
83 
84  \param rhs The right-hand-side ibject to copy its values.
85 
86  \return A reference to this item.
87 
88  \pre The rhs item must be of a compatible type with the item being assigned.
89  */
90  DataSetItem& operator=(const DataSetItem& rhs);
91 
92  /*!
93  \brief It returns a clone of the DataSetItem.
94  */
95  std::auto_ptr<DataSetItem> clone() const;
96 
97  /*!
98  \brief It returns its parent.
99 
100  \note The caller does not have the ownership of the returned pointer.
101  */
102  te::da::DataSet* getParent() const;
103 
104  /*!
105  \brief It returns the number of properties.
106  */
107  std::size_t getNumProperties() const;
108 
109  /*!
110  \brief It returns the type of the pos-th property.
111  */
112  int getPropertyDataType(std::size_t pos) const;
113 
114  /*!
115  \brief It returns the name of the pos-th property.
116  */
117  std::string getPropertyName(std::size_t pos) const;
118 
119  /*!
120  \brief It returns the value of the i-th property.
121  */
122  char getChar(std::size_t i) const;
123 
124  /*!
125  \brief It sets the value of the i-th property.
126  */
127  void setChar(std::size_t i, char value);
128 
129  /*!
130  \brief It sets the value of the property, indicating its name.
131  */
132  void setChar(const std::string& name, char value);
133 
134  /*!
135  \brief It returns the value of the i-th property.
136  */
137  unsigned char getUChar(std::size_t i) const;
138 
139  /*!
140  \brief It sets the value of the i-th property.
141  */
142  void setUChar(std::size_t i, unsigned char value);
143 
144  /*!
145  \brief It sets the value of the property, indicating its name.
146  */
147  void setUChar(const std::string& name, unsigned char value);
148 
149  /*!
150  \brief It returns the value of the i-th property.
151  */
152  boost::int16_t getInt16(std::size_t i) const;
153 
154  /*!
155  \brief It sets the value of the i-th property.
156  */
157  void setInt16(std::size_t i, boost::int16_t value);
158 
159  /*!
160  \brief It sets the value of the property, indicating its name.
161  */
162  void setInt16(const std::string& name, boost::int16_t value);
163 
164  /*!
165  \brief It returns the value of the i-th property.
166  */
167  boost::int32_t getInt32(std::size_t i) const;
168 
169  /*!
170  \brief It sets the value of the i-th property.
171  */
172  void setInt32(std::size_t i, boost::int32_t value);
173 
174  /*!
175  \brief It sets the value of the property, indicating its name.
176  */
177  void setInt32(const std::string& name, boost::int32_t value);
178 
179  /*!
180  \brief It returns the value of the i-th property.
181  */
182  boost::int64_t getInt64(std::size_t i) const;
183 
184  /*!
185  \brief It sets the value of the i-th property.
186  */
187  void setInt64(std::size_t i, boost::int64_t value);
188 
189  /*!
190  \brief It sets the value of the property, indicating its name.
191  */
192  void setInt64(const std::string& name, boost::int64_t value);
193 
194  /*!
195  \brief It returns the value of the i-th property.
196  */
197  bool getBool(std::size_t i) const;
198 
199  /*!
200  \brief It sets the value of the i-th property.
201  */
202  void setBool(std::size_t i, bool value);
203 
204  /*!
205  \brief It sets the value of the property, indicating its name.
206  */
207  void setBool(const std::string& name, bool value);
208 
209  /*!
210  \brief It returns the value of the i-th property.
211  */
212  float getFloat(std::size_t i) const;
213 
214  /*!
215  \brief It sets the value of the i-th property.
216  */
217  void setFloat(std::size_t i, float value);
218 
219  /*!
220  \brief It sets the value of the property, indicating its name.
221  */
222  void setFloat(const std::string& name, float value);
223 
224  /*!
225  \brief It returns the value of the i-th property.
226  */
227  double getDouble(std::size_t i) const;
228 
229  /*!
230  \brief It sets the value of the i-th property.
231  */
232  void setDouble(std::size_t i, double value);
233 
234  /*!
235  \brief It sets the value of the property, indicating its name.
236  */
237  void setDouble(const std::string& name, double value);
238 
239  /*!
240  \brief It returns the value of the i-th property.
241  */
242  std::string getNumeric(std::size_t i) const;
243 
244  /*!
245  \brief It sets the value of the i-th property.
246  */
247  void setNumeric(std::size_t i, const std::string& value);
248 
249  /*!
250  \brief It sets the value of the property, indicating its name.
251  */
252  void setNumeric(const std::string& name, const std::string& value);
253 
254  /*!
255  \brief It returns the value of the i-th property.
256  */
257  std::string getString(std::size_t i) const;
258 
259  /*!
260  \brief It sets the value of the i-th property.
261  */
262  void setString(std::size_t i, const std::string& value);
263 
264  /*!
265  \brief It sets the value of the property, indicating its name.
266  */
267  void setString(const std::string& name, const std::string& value);
268 
269  /*!
270  \brief It returns the value of the i-th property.
271  */
272  std::auto_ptr<te::dt::ByteArray> getByteArray(std::size_t i) const;
273 
274  /*!
275  \brief It sets the value of the i-th property.
276 
277  \note It will take the ownership of the given pointer.
278  */
279  void setByteArray(std::size_t i, te::dt::ByteArray* value);
280 
281  /*!
282  \brief It sets the value of the property, indicating its name.
283 
284  \note It will take the ownership of the given pointer.
285  */
286  void setByteArray(const std::string& name, te::dt::ByteArray* value);
287 
288  /*!
289  \brief It returns the value of the i-th property.
290  */
291  std::auto_ptr<te::gm::Geometry> getGeometry(std::size_t i) const;
292 
293  /*!
294  \brief It sets the value of the i-th property.
295 
296  \note It will take the ownership of the given pointer.
297  */
298  void setGeometry(std::size_t i, te::gm::Geometry* value);
299 
300  /*!
301  \brief It sets the value of the property, indicating its name.
302 
303  \note It will take the ownership of the given pointer.
304  */
305  void setGeometry(const std::string& name, te::gm::Geometry* value);
306 
307  /*!
308  \brief It returns the value of the i-th property.
309  */
310  std::auto_ptr<te::rst::Raster> getRaster(std::size_t i) const;
311 
312  /*!
313  \brief It sets the value of the i-th property.
314 
315  \note It will take the ownership of the given pointer.
316  */
317  void setRaster(std::size_t i, te::rst::Raster* value);
318 
319  /*!
320  \brief It sets the value of the property, indicating its name.
321  */
322  void setRaster(const std::string& name, te::rst::Raster* value);
323 
324  /*!
325  \brief It returns the value of the i-th property.
326  */
327  std::auto_ptr<te::dt::DateTime> getDateTime(std::size_t i) const;
328 
329  /*!
330  \brief It sets the value of the i-th property.
331 
332  \note It will take the ownership of the given pointer.
333  */
334  void setDateTime(std::size_t i, te::dt::DateTime* value);
335 
336  /*!
337  \brief It sets the value of the property, indicating its name.
338 
339  \note It will take the ownership of the given pointer.
340  */
341  void setDateTime(const std::string& name, te::dt::DateTime* value);
342 
343  /*!
344  \brief It returns the value of the i-th property.
345  */
346  std::auto_ptr<te::dt::AbstractData> getValue(std::size_t i) const;
347 
348  /*!
349  \brief It sets the value of the i-th property.
350 
351  \note It will take the ownership of the given pointer.
352  */
353  void setValue(std::size_t i, te::dt::AbstractData* value);
354 
355  /*!
356  \brief It sets the value of the property, indicating its name.
357 
358  \note It will take the ownership of the given pointer.
359  */
360  void setValue(const std::string& name, te::dt::AbstractData* value);
361 
362  bool isNull(std::size_t i) const;
363 
364  protected:
365 
366  const te::da::DataSet* m_parent; //!< The parent dataset, if the item is associated to one.
367  boost::ptr_vector<boost::nullable<te::dt::AbstractData> > m_data; //!< The data values of the dataset item.
368 
369  friend class DataSet;
370  };
371 
372  /*!
373  \brief For use with boost containers.
374  */
376  {
377  return a.clone().release();
378  }
379 
380  } // end namespace mem
381 } // end namespace te
382 
383 #endif // __TERRALIB_MEMORY_INTERNAL_DATASETITEM_H
#define TEMEMORYEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:87
const te::da::DataSet * m_parent
The parent dataset, if the item is associated to one.
Definition: DataSetItem.h:366
double getDouble(const std::string &value, std::vector< std::string > &sVector)
Definition: Utils.cpp:59
Configuration flags for the TerraLib In-memory Data Access driver.
std::auto_ptr< DataSetItem > clone() const
It returns a clone of the DataSetItem.
Definition: DataSetItem.cpp:89
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
Definition: DataSet.h:65
An abstract class for raster data strucutures.
Definition: Raster.h:71
boost::ptr_vector< boost::nullable< te::dt::AbstractData > > m_data
The data values of the dataset item.
Definition: DataSetItem.h:367
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
Definition: DataSetItem.h:56
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
DataSetItem * new_clone(const DataSetItem &a)
For use with boost containers.
Definition: DataSetItem.h:375
A class for representing binary data.
Definition: ByteArray.h:51