All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataSource.cpp
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/DataSource.cpp
22 
23  \brief Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver.
24 */
25 
26 // TerraLib
27 #include "../common/Translator.h"
28 #include "../dataaccess/dataset/DataSetType.h"
29 #include "../dataaccess/datasource/DataSourceCatalog.h"
30 #include "../dataaccess/datasource/DataSourceCapabilities.h"
31 #include "../dataaccess/datasource/DataSourceTransactor.h"
32 #include "../dataaccess/query/SQLDialect.h"
33 #include "../dataaccess/utils/Utils.h"
34 #include "../geometry/Envelope.h"
35 #include "DataSet.h"
36 #include "DataSource.h"
37 #include "Exception.h"
38 
39 // Boost
40 #include <boost/algorithm/string/case_conv.hpp>
41 #include <boost/format.hpp>
42 #include <boost/lexical_cast.hpp>
43 
44 // STL
45 #include <cassert>
46 
47 
49 
51 
53  : m_numDatasets(0),
54  m_maxNumDatasets(TE_MEMORY_MAX_DATASETS),
55  m_isOpened(false),
56  m_deepCopy(false)
57 {
58 }
59 
61 {
62  close();
63 }
64 
65 const std::map<std::string, te::da::DataSetPtr>& te::mem::DataSource::getDataSets() const
66 {
67  return m_datasets;
68 }
69 
70 const std::map<std::string, te::da::DataSetTypePtr> te::mem::DataSource::getSchemas() const
71 {
72  return m_schemas;
73 }
74 
75 std::string te::mem::DataSource::getType() const
76 {
78 }
79 
80 const std::map<std::string, std::string>& te::mem::DataSource::getConnectionInfo() const
81 {
82  return m_connInfo;
83 }
84 
85 void te::mem::DataSource::setConnectionInfo(const std::map<std::string, std::string>& connInfo)
86 {
87  m_connInfo = connInfo;
88 }
89 
90 std::auto_ptr<te::da::DataSourceTransactor> te::mem::DataSource::getTransactor()
91 {
92  //return std::auto_ptr<te::da::DataSourceTransactor>(new te::mem::DataSourceTransactor(this));
93  return std::auto_ptr<te::da::DataSourceTransactor>(0);
94 }
95 
97 {
98  // Assure we are in a closed state
99  close();
100 
101  // Check if it is required a different dataset limit
102  std::map<std::string, std::string>::const_iterator it = m_connInfo.find("MAX_DATASETS");
103 
104  if(it != m_connInfo.end())
105  m_maxNumDatasets = boost::lexical_cast<std::size_t>(it->second);
106 
107  // Check operation mode
108  it = m_connInfo.find("OPERATION_MODE");
109 
110  if((it != m_connInfo.end()) && (boost::to_upper_copy(it->second) == "NON-SHARED"))
111  m_deepCopy = true;
112 
113  m_isOpened = true;
114 }
115 
117 {
118  if(!m_isOpened)
119  return;
120 
121  m_datasets.clear();
122  m_schemas.clear();
123 
124  m_numDatasets = 0;
125  m_maxNumDatasets = TE_MEMORY_MAX_DATASETS;
126 
127  m_isOpened = false;
128  m_deepCopy = false;
129 }
130 
132 {
133  return m_isOpened;
134 }
135 
137 {
138  return m_isOpened;
139 }
140 
142 {
143  return sm_capabilities;
144 }
145 
147 {
148  return &sm_dialect;
149 }
150 
151 std::auto_ptr<te::da::DataSet> te::mem::DataSource::getDataSet(const std::string& name,
152  te::common::TraverseType /*travType*/,
153  const te::common::AccessPolicy /*accessPolicy*/ )
154 {
155  if(!dataSetExists(name))
156  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % name).str());
157 
158  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
159 
160  std::map<std::string, te::da::DataSetPtr>::const_iterator it = m_datasets.find(name);
161 
162  return std::auto_ptr<te::da::DataSet>(new DataSet(*(it->second), m_deepCopy));
163 }
164 
165 std::vector<std::string> te::mem::DataSource::getDataSetNames()
166 {
167  std::vector<std::string> datasetNames;
168 
169  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
170 
171  std::map<std::string, te::da::DataSetTypePtr>::const_iterator it;
172  for(it = m_schemas.begin(); it != m_schemas.end(); ++it)
173  datasetNames.push_back(it->first);
174 
175  return datasetNames;
176 }
177 
179 {
180  return m_numDatasets;
181 }
182 
183 std::auto_ptr<te::da::DataSetType> te::mem::DataSource::getDataSetType(const std::string& datasetName)
184 {
185  if(!dataSetExists(datasetName))
186  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % datasetName).str());
187 
188  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
189 
190  std::map<std::string, te::da::DataSetTypePtr>::const_iterator it = m_schemas.find(datasetName);
191 
192  te::da::DataSetType* dt = static_cast<te::da::DataSetType*>(it->second.get()->clone());
193 
194  return std::auto_ptr<te::da::DataSetType>(dt);
195 }
196 
197 boost::ptr_vector<te::dt::Property> te::mem::DataSource::getProperties(const std::string& datasetName)
198 {
199  boost::ptr_vector<te::dt::Property> properties;
200 
201  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
202 
203  std::map<std::string, te::da::DataSetTypePtr>::const_iterator it = m_schemas.find(datasetName);
204 
205  if(it == m_schemas.end())
206  return properties;
207 
208  const te::da::DataSetTypePtr& dt = it->second;
209 
210  const std::size_t np = dt->size();
211 
212  for(std::size_t i = 0; i < np; ++i)
213  properties.push_back(dt->getProperty(i)->clone());
214 
215  return properties;
216 }
217 
218 std::auto_ptr<te::dt::Property> te::mem::DataSource:: getProperty(const std::string& datasetName, const std::string& name)
219 {
220  if(!propertyExists(datasetName,name))
221  throw Exception((boost::format(TE_TR("The dataset \"%1%\" has no property with this name: \"%2%\"!")) % datasetName % name).str());
222 
223  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
224 
225  std::auto_ptr<te::da::DataSetType> dt = getDataSetType(datasetName);
226 
227  te::dt::Property* p = dt->getProperty(name);
228 
229  return std::auto_ptr<te::dt::Property>(p->clone());
230 }
231 
232 std::auto_ptr<te::dt::Property> te::mem::DataSource::getProperty(const std::string& datasetName, std::size_t propertyPos)
233 {
234  if(!dataSetExists(datasetName))
235  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % datasetName).str());
236 
237  assert(propertyPos < getNumberOfProperties(datasetName));
238 
239  std::auto_ptr<te::da::DataSetType> dt = getDataSetType(datasetName);
240 
241  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
242 
243  te::dt::Property* p = dt->getProperty(propertyPos);
244 
245  return std::auto_ptr<te::dt::Property>(p->clone());
246 }
247 
248 std::vector<std::string> te::mem::DataSource::getPropertyNames(const std::string& datasetName)
249 {
250  if(!dataSetExists(datasetName))
251  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % datasetName).str());
252 
253  std::vector<std::string> pNames;
254 
255  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
256 
257  std::map<std::string, te::da::DataSetTypePtr>::const_iterator it = m_schemas.find(datasetName);
258 
259  const te::da::DataSetTypePtr& dt = it->second;
260 
261  std::vector<te::dt::Property*>& properties = dt->getProperties();
262  for(std::size_t i = 0; i < properties.size(); ++i)
263  pNames.push_back(properties[i]->getName());
264 
265  return pNames;
266 }
267 
268 std::size_t te::mem::DataSource::getNumberOfProperties(const std::string& datasetName)
269 {
270  return getPropertyNames(datasetName).size();
271 }
272 
273 bool te::mem::DataSource::propertyExists(const std::string& datasetName, const std::string& name)
274 {
275  std::vector<std::string> pNames = getPropertyNames(datasetName);
276 
277  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
278 
279  if(std::find(pNames.begin(), pNames.end(), name) != pNames.end())
280  return true;
281 
282  return false;
283 }
284 
285 void te::mem::DataSource::addProperty(const std::string& datasetName, te::dt::Property* p)
286 {
287  std::string pName = p->getName();
288 
289  if(propertyExists(datasetName, p->getName()))
290  throw Exception((boost::format(TE_TR("The dataset already \"%1%\" has a property with this name \"%2%\"!")) % datasetName % pName).str());
291 
292  std::auto_ptr<te::da::DataSetType> dt = getDataSetType(datasetName);
293 
294  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
295 
296  dt->add(p);
297 
298  // Adjust the dataset properties
299  std::auto_ptr<te::da::DataSet> dataset = getDataSet(datasetName);
300  te::mem::DataSet* datasetp = static_cast<te::mem::DataSet*>(dataset.release());
301 
302  datasetp->add(pName, p->getType());
303 }
304 
305 void te::mem::DataSource::dropProperty(const std::string& datasetName, const std::string& propertyName)
306 {
307  if(!propertyExists(datasetName, propertyName))
308  throw Exception((boost::format(TE_TR("The dataset \"%1%\" has no property with this name \"%2%\"!")) % datasetName % propertyName).str());
309 
310  std::auto_ptr<te::da::DataSet> dataset = getDataSet(datasetName);
311 
312  std::auto_ptr<te::da::DataSetType> dt = getDataSetType(datasetName);
313 
314  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
315 
316  te::mem::DataSet* datasetp = static_cast<te::mem::DataSet*>(dataset.release());
317  std::size_t pos = te::da::GetPropertyPos(datasetp, propertyName);
318 
319  datasetp->drop(pos);
320 
321  te::dt::Property* p = dt->getProperty(propertyName);
322 
323  dt->remove(p);
324 }
325 
326 void te::mem::DataSource::renameProperty(const std::string& datasetName,
327  const std::string& name,
328  const std::string& newName)
329 {
330  if(!propertyExists(datasetName, name))
331  throw Exception((boost::format(TE_TR("The dataset \"%1%\" has no property with this name \"%2%\"!")) % datasetName % name).str());
332 
333  if(!isPropertyNameValid(newName))
334  throw Exception((boost::format(TE_TR("The new property name \"%1%\" is not valid!")) % newName).str());
335 
336  std::auto_ptr<te::da::DataSetType> dt = getDataSetType(datasetName);
337 
338  // Update the property name in the dataset
339  std::auto_ptr<te::da::DataSet> dataset = getDataSet(datasetName);
340 
341  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
342 
343  te::mem::DataSet* datasetp = static_cast<te::mem::DataSet*>(dataset.release());
344 
345  std::size_t pos = te::da::GetPropertyPos(datasetp, name);
346  datasetp->setPropertyName(newName, pos);
347 
348  // Update the property name in the schema
349  dt->getProperty(pos)->setName(newName);
350 }
351 
352 std::size_t te::mem::DataSource::getNumberOfItems(const std::string& datasetName)
353 {
354  if(!dataSetExists(datasetName))
355  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % datasetName).str());
356 
357  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
358 
359  te::da::DataSetPtr& dataset = m_datasets.find(datasetName)->second;
360 
361  return dataset.get()->size();
362 }
363 
365 {
366  return (m_numDatasets == 0) ? false : true;
367 }
368 
369 bool te::mem::DataSource::dataSetExists(const std::string& name)
370 {
371  std::vector<std::string> datasetNames = getDataSetNames();
372 
373  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
374 
375  if(std::find(datasetNames.begin(), datasetNames.end(), name) != datasetNames.end())
376  return true;
377 
378  return false;
379 }
380 
382  const std::map<std::string, std::string>& /*options*/)
383 {
384  std::string datasetName = dt->getName();
385 
386  if(m_schemas.find(datasetName) != m_schemas.end())
387  throw Exception((boost::format(TE_TR("A dataset with the same name (%1%) already exists!")) % datasetName).str());
388 
389  if((m_numDatasets + 1) > m_maxNumDatasets)
390  throw Exception((boost::format(TE_TR("The maximum number of datasets was exceeded!"))).str());
391 
392  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
393 
394  te::da::DataSetTypePtr dtp(dt);
395  m_schemas[datasetName] = dtp;
396 
397  DataSetPtr dataset(new DataSet(dt));
398 
399  m_datasets[datasetName] = dataset;
400 
401  ++m_numDatasets;
402 }
403 
404 void te::mem::DataSource::cloneDataSet(const std::string& name,
405  const std::string& cloneName,
406  const std::map<std::string, std::string>& /*options*/)
407 {
408  if(!dataSetExists(name))
409  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % name).str());
410 
411  if(!isDataSetNameValid(cloneName))
412  throw Exception((boost::format(TE_TR("The dataset clone name \"%1%\" is not valid!")) % cloneName).str());
413 
414  if(!dataSetExists(cloneName))
415  throw Exception((boost::format(TE_TR("There is already a dataset with this name: \"%1%\"!")) % cloneName).str());
416 
417  // Clone the schema
418  const te::da::DataSetTypePtr& dtp = m_schemas[name];
419 
420  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
421 
422  te::da::DataSetType* clonedt = static_cast<te::da::DataSetType*>(dtp->clone());
423  te::da::DataSetTypePtr clonedtp(clonedt);
424  m_schemas[cloneName] = clonedtp;
425 
426  // Clone the dataset
427  te::da::DataSetPtr datasetClone(getDataSet(name).release());
428 
429  m_datasets[cloneName] = datasetClone;
430 
431  ++m_numDatasets;
432 }
433 
434 void te::mem::DataSource::dropDataSet(const std::string& name)
435 {
436  if(!dataSetExists(name))
437  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % name).str());
438 
439  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
440 
441  m_schemas.erase(m_schemas.find(name));
442  m_datasets.erase(m_datasets.find(name));
443 
444  --m_numDatasets;
445 }
446 
447 void te::mem::DataSource::renameDataSet(const std::string& name, const std::string& newName)
448 {
449  if(!dataSetExists(name))
450  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % name).str());
451 
452  if(!isDataSetNameValid(newName))
453  throw Exception((boost::format(TE_TR("The new name \"%1%\" is not valid!")) % newName).str());
454 
455  std::auto_ptr<te::da::DataSetType> dt = getDataSetType(name);
456 
457  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
458 
459  dt->setName(newName);
460  dt->setCompositeName(newName);
461 
462  m_schemas.erase(m_schemas.find(name));
463  m_schemas[newName] = dt;
464 
465  te::da::DataSetPtr& dataset = m_datasets[name];
466  m_datasets.erase(m_datasets.find(name));
467  m_datasets[newName] = dataset;
468 }
469 
470 void te::mem::DataSource::add(const std::string& datasetName,
471  te::da::DataSet* d,
472  const std::map<std::string, std::string>& /*options*/,
473  std::size_t limit)
474 {
475  if(!dataSetExists(datasetName))
476  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % datasetName).str());
477 
478  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
479 
480  te::mem::DataSet* datasetp = static_cast<te::mem::DataSet*>(m_datasets[datasetName].get());
481  datasetp->copy(*d, limit);
482 }
483 
484 void te::mem::DataSource::remove(const std::string& datasetName, const te::da::ObjectIdSet* oids)
485 {
486  if(!dataSetExists(datasetName))
487  throw Exception((boost::format(TE_TR("There is no dataset with this name: \"%1%\"!")) % datasetName).str());
488 
489  boost::lock_guard<boost::recursive_mutex> lock(m_mtx);
490 
491  std::auto_ptr<te::da::DataSet> datasetp = te::da::DataSource::getDataSet(datasetName, oids);
492 
493  te::mem::DataSet* dataset = static_cast<te::mem::DataSet*>(datasetp.get());
494 
495  while(dataset->moveNext())
496  dataset->remove();
497 }
498 
499 void te::mem::DataSource::update(const std::string& /*datasetName*/,
500  te::da::DataSet* /*dataset*/,
501  const std::vector<std::size_t>& /*properties*/,
502  const te::da::ObjectIdSet* /*oids*/,
503  const std::map<std::string, std::string>& /*options*/,
504  std::size_t /*limit*/)
505 {
506 }
507 
509 {
510  sm_capabilities = capabilities;
511 }
512 
513 
514 void te::mem::DataSource::create(const std::map<std::string, std::string>& /*dsInfo*/)
515 {
516 }
517 
518 void te::mem::DataSource::drop(const std::map<std::string, std::string>& /*dsInfo*/)
519 {
520 }
521 
522 bool te::mem::DataSource::exists(const std::map<std::string, std::string>& /*dsInfo*/)
523 {
524  return false;
525 }
526 
527 std::vector<std::string> te::mem::DataSource::getDataSourceNames(const std::map<std::string, std::string>& /*dsInfo*/)
528 {
529  return std::vector<std::string>();
530 }
531 
532 std::vector<te::common::CharEncoding> te::mem::DataSource::getEncodings(const std::map<std::string, std::string>& /*dsInfo*/)
533 {
534  return std::vector<te::common::CharEncoding>();
535 }
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
Definition: DataSource.cpp:352
const std::map< std::string, te::da::DataSetTypePtr > getSchemas() const
It returns a map relating the dataset names and their schemas.
Definition: DataSource.cpp:70
static te::da::DataSourceCapabilities sm_capabilities
The Memory data source capabilities.
Definition: DataSource.h:183
~DataSource()
Virtual destructor.
Definition: DataSource.cpp:60
boost::shared_ptr< DataSet > DataSetPtr
Definition: DataSet.h:391
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
Definition: DataSource.cpp:268
boost::shared_ptr< DataSetType > DataSetTypePtr
Definition: DataSetType.h:653
static void setCapabilities(const te::da::DataSourceCapabilities &capabilities)
It sets the capabilities document.
Definition: DataSource.cpp:508
void setConnectionInfo(const std::map< std::string, std::string > &connInfo)
It sets the connection information to be used when connecting to the data source. ...
Definition: DataSource.cpp:85
std::vector< std::string > getDataSourceNames(const std::map< std::string, std::string > &dsInfo)
It gets the data source names available in a driver.
Definition: DataSource.cpp:527
void drop(const std::map< std::string, std::string > &dsInfo)
It removes the data source with the connection information from a driver.
Definition: DataSource.cpp:518
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
Definition: DataSource.cpp:248
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS, or MYSQL.
Definition: DataSource.cpp:75
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
Definition: DataSource.cpp:369
A class that models the description of a dataset.
Definition: DataSetType.h:72
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
Definition: DataSource.cpp:131
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
Definition: DataSource.cpp:178
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
Definition: DataSource.cpp:197
virtual Property * clone() const =0
It returns a clone of the object.
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
Definition: Utils.cpp:500
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:55
static const te::da::SQLDialect sm_dialect
A dummy dialect.
Definition: DataSource.h:184
std::auto_ptr< te::da::DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. This method always returns a disconnected dataset...
Definition: DataSource.cpp:151
bool hasDataSets()
It checks if the data source has any dataset.
Definition: DataSource.cpp:364
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
An exception class for the TerraLib In-Memory Data Access driver.
It models a property definition.
Definition: Property.h:59
void drop(std::size_t pos)
It drops a property from the dataset.
Definition: DataSet.cpp:209
void createDataSet(te::da::DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
Definition: DataSource.cpp:381
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
Definition: DataSet.cpp:172
std::vector< te::common::CharEncoding > getEncodings(const std::map< std::string, std::string > &dsInfo)
It gets the encodings for the data source.
Definition: DataSource.cpp:532
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
Definition: DataSource.cpp:273
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
Definition: DataSource.cpp:434
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
void close()
It closes the data source and clears all the resources used by its internal communication channel...
Definition: DataSource.cpp:116
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
Definition: DataSet.h:65
void add(const std::string &datasetName, te::da::DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit)
It adds data items to the dataset in the data source.
Definition: DataSource.cpp:470
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
te::da::DataSourceCapabilities capabilities
bool isValid() const
It checks if the data source is valid (available for using).
Definition: DataSource.cpp:136
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
Definition: DataSource.cpp:447
virtual std::auto_ptr< DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. This method always returns a disconnected dataset...
Definition: DataSource.cpp:61
void update(const std::string &datasetName, te::da::DataSet *dataset, const std::vector< std::size_t > &properties, const te::da::ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit=0)
It updates the contents of a dataset for the set of data items.
Definition: DataSource.cpp:499
std::auto_ptr< te::da::DataSourceTransactor > getTransactor()
It returns an object that can execute transactions in the context of a data source.
Definition: DataSource.cpp:90
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void remove()
It removes the current dataset item.
Definition: DataSet.cpp:177
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
Definition: DataSource.cpp:285
std::auto_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)
It retrieves the property with the given name from the dataset.
Definition: DataSource.cpp:218
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &datasetName)
It gets information about the given dataset.
Definition: DataSource.cpp:183
bool moveNext()
It moves the internal pointer to the next item of the collection.
Definition: DataSet.cpp:316
int getType() const
It returns the property data type.
Definition: Property.h:161
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
void copy(te::da::DataSet &src, std::size_t limit=0)
It copies up to limit items from the source dataset.
Definition: DataSet.cpp:119
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
Definition: DataSource.cpp:146
const std::map< std::string, std::string > & getConnectionInfo() const
It returns the set of parameters used to set up the access channel to the underlying repository...
Definition: DataSource.cpp:80
boost::shared_ptr< DataSet > DataSetPtr
Definition: DataSet.h:681
const std::map< std::string, te::da::DataSetPtr > & getDataSets() const
It returns a map relating the dataset names and their contents.
Definition: DataSource.cpp:65
#define TE_MEMORY_MAX_DATASETS
The maximum number of datasets to be handled by a data source.
Definition: Config.h:54
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
Definition: DataSource.cpp:141
void create(const std::map< std::string, std::string > &dsInfo)
It creates a new data source.
Definition: DataSource.cpp:514
std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
Definition: DataSource.cpp:165
void renameProperty(const std::string &datasetName, const std::string &name, const std::string &newName)
It renames a property of the given dataset.
Definition: DataSource.cpp:326
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids)
It removes all the informed items from the dataset.
Definition: DataSource.cpp:484
void setPropertyName(const std::string &name, std::size_t pos)
Definition: DataSet.cpp:277
void cloneDataSet(const std::string &name, const std::string &cloneName, const std::map< std::string, std::string > &options)
It clones the dataset in the data source.
Definition: DataSource.cpp:404
void dropProperty(const std::string &datasetName, const std::string &propertyName)
It removes a property from the given dataset.
Definition: DataSource.cpp:305
bool exists(const std::map< std::string, std::string > &dsInfo)
Check the existence of a data source in a driver.
Definition: DataSource.cpp:522
#define TE_MEMORY_DRIVER_IDENTIFIER
The In-Memory driver identifier string.
Definition: Config.h:42
void open()
It opens the data source and makes it ready for using.
Definition: DataSource.cpp:96
const std::string & getName() const
It returns the property name.
Definition: Property.h:127