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