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