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_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 da
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 having the given number of properties.
71 
72  \param nproperties The number of properties.
73  */
74  explicit DataSetItem(const std::size_t& nproperties);
75 
76  /*!
77  \brief It creates a new item by cloning the values in the source item (rhs).
78 
79  \param rhs The right-hand-side object to copy its values.
80  */
81  explicit DataSetItem(const DataSetItem& rhs);
82 
83  /*! \brief Destructor. */
84  virtual ~DataSetItem();
85 
86  /*!
87  \brief Assignment operator.
88 
89  It copies the values from the rhs item.
90 
91  \param rhs The right-hand-side ibject to copy its values.
92 
93  \return A reference to this item.
94 
95  \pre The rhs item must be of a compatible type with the item being assigned.
96  */
97  DataSetItem& operator=(const DataSetItem& rhs);
98 
99  /*!
100  \brief It returns a clone of the DataSetItem.
101  */
102  std::auto_ptr<DataSetItem> clone() const;
103 
104  /*!
105  \brief It returns its parent.
106 
107  \note The caller does not have the ownership of the returned pointer.
108  */
109  te::da::DataSet* getParent() const;
110 
111  /*!
112  \brief It returns the number of properties.
113  */
114  std::size_t getNumProperties() const;
115 
116  /*!
117  \brief It returns the type of the pos-th property.
118  */
119  int getPropertyDataType(std::size_t pos) const;
120 
121  /*!
122  \brief It returns the name of the pos-th property.
123  */
124  std::string getPropertyName(std::size_t pos) const;
125 
126  /*!
127  \brief It returns the value of the i-th property.
128  */
129  char getChar(std::size_t i) const;
130 
131  /*!
132  \brief It sets the value of the i-th property.
133  */
134  void setChar(std::size_t i, char value);
135 
136  /*!
137  \brief It sets the value of the property, indicating its name.
138  */
139  void setChar(const std::string& name, char value);
140 
141  /*!
142  \brief It returns the value of the i-th property.
143  */
144  unsigned char getUChar(std::size_t i) const;
145 
146  /*!
147  \brief It sets the value of the i-th property.
148  */
149  void setUChar(std::size_t i, unsigned char value);
150 
151  /*!
152  \brief It sets the value of the property, indicating its name.
153  */
154  void setUChar(const std::string& name, unsigned char value);
155 
156  /*!
157  \brief It returns the value of the i-th property.
158  */
159  boost::int16_t getInt16(std::size_t i) const;
160 
161  /*!
162  \brief It sets the value of the i-th property.
163  */
164  void setInt16(std::size_t i, boost::int16_t value);
165 
166  /*!
167  \brief It sets the value of the property, indicating its name.
168  */
169  void setInt16(const std::string& name, boost::int16_t value);
170 
171  /*!
172  \brief It returns the value of the i-th property.
173  */
174  boost::int32_t getInt32(std::size_t i) const;
175 
176  /*!
177  \brief It sets the value of the i-th property.
178  */
179  void setInt32(std::size_t i, boost::int32_t value);
180 
181  /*!
182  \brief It sets the value of the property, indicating its name.
183  */
184  void setInt32(const std::string& name, boost::int32_t value);
185 
186  /*!
187  \brief It returns the value of the i-th property.
188  */
189  boost::int64_t getInt64(std::size_t i) const;
190 
191  /*!
192  \brief It sets the value of the i-th property.
193  */
194  void setInt64(std::size_t i, boost::int64_t value);
195 
196  /*!
197  \brief It sets the value of the property, indicating its name.
198  */
199  void setInt64(const std::string& name, boost::int64_t value);
200 
201  /*!
202  \brief It returns the value of the i-th property.
203  */
204  bool getBool(std::size_t i) const;
205 
206  /*!
207  \brief It sets the value of the i-th property.
208  */
209  void setBool(std::size_t i, bool value);
210 
211  /*!
212  \brief It sets the value of the property, indicating its name.
213  */
214  void setBool(const std::string& name, bool value);
215 
216  /*!
217  \brief It returns the value of the i-th property.
218  */
219  float getFloat(std::size_t i) const;
220 
221  /*!
222  \brief It sets the value of the i-th property.
223  */
224  void setFloat(std::size_t i, float value);
225 
226  /*!
227  \brief It sets the value of the property, indicating its name.
228  */
229  void setFloat(const std::string& name, float value);
230 
231  /*!
232  \brief It returns the value of the i-th property.
233  */
234  double getDouble(std::size_t i) const;
235 
236  /*!
237  \brief It sets the value of the i-th property.
238  */
239  void setDouble(std::size_t i, double value);
240 
241  /*!
242  \brief It sets the value of the property, indicating its name.
243  */
244  void setDouble(const std::string& name, double value);
245 
246  /*!
247  \brief It returns the value of the i-th property.
248  */
249  std::string getNumeric(std::size_t i) const;
250 
251  /*!
252  \brief It sets the value of the i-th property.
253  */
254  void setNumeric(std::size_t i, const std::string& value);
255 
256  /*!
257  \brief It sets the value of the property, indicating its name.
258  */
259  void setNumeric(const std::string& name, const std::string& value);
260 
261  /*!
262  \brief It returns the value of the i-th property.
263  */
264  std::string getString(std::size_t i) const;
265 
266  /*!
267  \brief It sets the value of the i-th property.
268  */
269  void setString(std::size_t i, const std::string& value);
270 
271  /*!
272  \brief It sets the value of the property, indicating its name.
273  */
274  void setString(const std::string& name, const std::string& value);
275 
276  /*!
277  \brief It returns the value of the i-th property.
278  */
279  std::auto_ptr<te::dt::ByteArray> getByteArray(std::size_t i) const;
280 
281  /*!
282  \brief It sets the value of the i-th property.
283 
284  \note It will take the ownership of the given pointer.
285  */
286  void setByteArray(std::size_t i, te::dt::ByteArray* value);
287 
288  /*!
289  \brief It sets the value of the property, indicating its name.
290 
291  \note It will take the ownership of the given pointer.
292  */
293  void setByteArray(const std::string& name, te::dt::ByteArray* value);
294 
295  /*!
296  \brief It returns the value of the i-th property.
297  */
298  std::auto_ptr<te::gm::Geometry> getGeometry(std::size_t i) const;
299 
300  /*!
301  \brief It sets the value of the i-th property.
302 
303  \note It will take the ownership of the given pointer.
304  */
305  void setGeometry(std::size_t i, te::gm::Geometry* value);
306 
307  /*!
308  \brief It sets the value of the property, indicating its name.
309 
310  \note It will take the ownership of the given pointer.
311  */
312  void setGeometry(const std::string& name, te::gm::Geometry* value);
313 
314  /*!
315  \brief It returns the value of the i-th property.
316  */
317  std::auto_ptr<te::rst::Raster> getRaster(std::size_t i) const;
318 
319  /*!
320  \brief It sets the value of the i-th property.
321 
322  \note It will take the ownership of the given pointer.
323  */
324  void setRaster(std::size_t i, te::rst::Raster* value);
325 
326  /*!
327  \brief It sets the value of the property, indicating its name.
328  */
329  void setRaster(const std::string& name, te::rst::Raster* value);
330 
331  /*!
332  \brief It returns the value of the i-th property.
333  */
334  std::auto_ptr<te::dt::DateTime> getDateTime(std::size_t i) const;
335 
336  /*!
337  \brief It sets the value of the i-th property.
338 
339  \note It will take the ownership of the given pointer.
340  */
341  void setDateTime(std::size_t i, te::dt::DateTime* value);
342 
343  /*!
344  \brief It sets the value of the property, indicating its name.
345 
346  \note It will take the ownership of the given pointer.
347  */
348  void setDateTime(const std::string& name, te::dt::DateTime* value);
349 
350  /*!
351  \brief It returns the value of the i-th property.
352  */
353  std::auto_ptr<te::dt::AbstractData> getValue(std::size_t i) const;
354 
355  /*!
356  \brief It sets the value of the i-th property.
357 
358  \note It will take the ownership of the given pointer.
359  */
360  void setValue(std::size_t i, te::dt::AbstractData* value);
361 
362  /*!
363  \brief It sets the value of the property, indicating its name.
364 
365  \note It will take the ownership of the given pointer.
366  */
367  void setValue(const std::string& name, te::dt::AbstractData* value);
368 
369  bool isNull(std::size_t i) const;
370 
371  protected:
372 
373  const te::da::DataSet* m_parent; //!< The parent dataset, if the item is associated to one.
374  boost::ptr_vector<boost::nullable<te::dt::AbstractData> > m_data; //!< The data values of the dataset item.
375 
376  friend class DataSet;
377  };
378 
379  /*!
380  \brief For use with boost containers.
381  */
383  {
384  return a.clone().release();
385  }
386 
387  } // end namespace mem
388 } // end namespace te
389 
390 #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:84
const te::da::DataSet * m_parent
The parent dataset, if the item is associated to one.
Definition: DataSetItem.h:373
Configuration flags for the TerraLib In-memory Data Access driver.
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:374
URI C++ Library.
std::auto_ptr< DataSetItem > clone() const
It returns a clone of the DataSetItem.
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:74
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:382
A class for representing binary data.
Definition: ByteArray.h:51