Go to the documentation of this file.
   26 #ifndef __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCE_H 
   27 #define __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCE_H 
   30 #include "../../common/Enums.h" 
   31 #include "../../core/uri/URI.h" 
   32 #include "../../geometry/Enums.h" 
   33 #include "../dataset/CheckConstraint.h" 
   34 #include "../dataset/DataSet.h" 
   35 #include "../dataset/DataSetType.h" 
   36 #include "../dataset/ForeignKey.h" 
   37 #include "../dataset/Index.h" 
   38 #include "../dataset/PrimaryKey.h" 
   39 #include "../dataset/Sequence.h" 
   40 #include "../dataset/UniqueKey.h" 
   41 #include "../Config.h" 
   51 #include <boost/ptr_container/ptr_vector.hpp> 
   52 #include <boost/cstdint.hpp> 
   53 #include <boost/noncopyable.hpp> 
   54 #include <boost/shared_ptr.hpp> 
   71     class DataSetTypeCapabilities;
 
   72     class DataSourceCapabilities;
 
   73     class DataSourceTransactor;
 
   78     class CheckConstraint;
 
  310         virtual std::unique_ptr<DataSet> 
getDataSet(
const std::string& name, 
 
  337         virtual std::unique_ptr<DataSet> 
getDataSet(
const std::string& name,
 
  338                                                   const std::string& propertyName,
 
  361         virtual std::unique_ptr<DataSet> 
getDataSet(
const std::string& name,
 
  362                                                   const std::string& propertyName,
 
  387         std::unique_ptr<te::da::DataSet> 
getDataSet(
const std::string& name,
 
  437         virtual std::unique_ptr<DataSet> 
query(
const std::string& query, 
 
  466         virtual void execute(
const std::string& command);
 
  482         virtual std::string 
escape(
const std::string& value);
 
  557         virtual std::unique_ptr<te::da::DataSetType> 
getDataSetType(
const std::string& name);
 
  566         std::unique_ptr<te::da::DataSetTypeCapabilities> 
getCapabilities(
const std::string& name);
 
  579         virtual boost::ptr_vector<te::dt::Property> 
getProperties(
const std::string& datasetName);
 
  593         virtual std::unique_ptr<te::dt::Property> 
getProperty(
const std::string& datasetName, 
const std::string& name);
 
  607         virtual std::unique_ptr<te::dt::Property> 
getProperty(
const std::string& datasetName, std::size_t propertyPos);
 
  650         virtual bool propertyExists(
const std::string& datasetName, 
const std::string& name);
 
  675         virtual void dropProperty(
const std::string& datasetName, 
const std::string& name);
 
  689                                     const std::string& propertyName,
 
  690                                     const std::string& newPropertyName);
 
  694         virtual void changePropertiesDefinitions(
const std::string& datasetName, 
const std::vector<std::string>& propsNames, 
const std::vector<te::dt::Property*> newProps);
 
  707         virtual std::unique_ptr<te::da::PrimaryKey> 
getPrimaryKey(
const std::string& datasetName);
 
  759         virtual std::unique_ptr<ForeignKey> 
getForeignKey(
const std::string& datasetName, 
const std::string& name);
 
  809         virtual void dropForeignKey(
const std::string& datasetName, 
const std::string& fkName);
 
  823         virtual std::unique_ptr<te::da::UniqueKey> 
getUniqueKey(
const std::string& datasetName, 
const std::string& name);
 
  850         virtual bool uniqueKeyExists(
const std::string& datasetName, 
const std::string& name);
 
  875         virtual void dropUniqueKey(
const std::string& datasetName, 
const std::string& name);
 
  889         virtual std::unique_ptr<te::da::CheckConstraint> 
getCheckConstraint(
const std::string& datasetName, 
const std::string& name);
 
  955         virtual std::unique_ptr<te::da::Index> 
getIndex(
const std::string& datasetName, 
const std::string& name);
 
  968         virtual std::vector<std::string> 
getIndexNames(
const std::string& datasetName);
 
  982         virtual bool indexExists(
const std::string& datasetName, 
const std::string& name);
 
  997                               const std::map<std::string, std::string>& options);
 
 1009         virtual void dropIndex(
const std::string& datasetName, 
const std::string& idxName);
 
 1022         virtual std::unique_ptr<Sequence> 
getSequence(
const std::string& name);
 
 1084         virtual std::unique_ptr<te::gm::Envelope> 
getExtent(
const std::string& datasetName,
 
 1085                                                           const std::string& propertyName);
 
 1099         virtual std::unique_ptr<te::gm::Envelope> 
getExtent(
const std::string& datasetName, std::size_t propertyPos);
 
 1190                                   const std::string& cloneName,
 
 1191                                   const std::map<std::string, std::string>& options);
 
 1214         virtual void renameDataSet(
const std::string& name, 
const std::string& newName);
 
 1238         virtual void add(
const std::string& datasetName,
 
 1240                          const std::map<std::string, std::string>& options,
 
 1241                          std::size_t limit = 0);
 
 1276         virtual void update(
const std::string& datasetName,
 
 1278                             const std::vector<std::size_t>& properties,
 
 1280                             const std::map<std::string, std::string>& options,
 
 1281                             std::size_t limit = 0);
 
 1295         virtual void update(
const std::string& datasetName,
 
 1297                             const std::vector< std::set<int> >& properties,
 
 1298                             const std::vector<size_t>& ids);
 
 1336         static std::unique_ptr<DataSource> 
create(
const std::string& dsType, 
const std::string& connInfo);
 
 1352         static void drop(
const std::string& dsType, 
const std::string& connInfo);
 
 1366         static bool exists(
const std::string& dsType, 
const std::string& connInfo);
 
 1380         static std::vector<std::string> 
getDataSourceNames(
const std::string& dsType, 
const std::string& connInfo);
 
 1400         virtual void create(
const std::string& connInfo) = 0;
 
 1411         virtual void drop(
const std::string& connInfo) = 0;
 
 1424         virtual bool exists(
const std::string& connInfo) = 0;
 
 1454 #endif  // __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCE_H 
  
 
te::core::URI m_uri
The URI used to describe the datasource connection;.
 
std::string m_id
The data source identification.
 
virtual bool exists(const std::string &connInfo)=0
Check the existence of a data source in a driver.
 
virtual bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
 
An Envelope defines a 2D rectangular region.
 
virtual bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
 
A class that describes a check constraint.
 
virtual bool isDataSetNameValid(const std::string &datasetName)
It checks if the given dataset name is valid.
 
virtual std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
 
virtual void add(const std::string &datasetName, DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0)
It adds data items to the dataset in the data source.
 
virtual std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
 
virtual std::unique_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
 
virtual std::unique_ptr< te::da::CheckConstraint > getCheckConstraint(const std::string &datasetName, const std::string &name)
It gets the check constraint of the dataset with the given name.
 
virtual boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
 
It represents the SQL query dialect accepted by a given data source.
 
virtual void update(const std::string &datasetName, 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.
 
virtual std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
 
virtual bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
 
virtual std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
 
virtual void addSequence(Sequence *sequence)
It adds a new sequence in the data source.
 
void setId(const std::string &id)
It sets the data source identification.
 
virtual void changePropertiesDefinitions(const std::string &datasetName, const std::vector< std::string > &propsNames, const std::vector< te::dt::Property * > newProps)
 
virtual void addIndex(const std::string &datasetName, Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
 
virtual void create(const std::string &connInfo)=0
It creates a new data source.
 
virtual std::unique_ptr< te::da::UniqueKey > getUniqueKey(const std::string &datasetName, const std::string &name)
It gets the unique key in the dataset with the given name.
 
virtual std::unique_ptr< te::dt::Property > getProperty(const std::string &datasetName, std::size_t propertyPos)
It retrieves the property lying in the given position from the dataset.
 
virtual bool checkConstraintExists(const std::string &datasetName, const std::string &name)
It checks if a check-constraint with the given name exists in the data source.
 
virtual std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
 
virtual bool isValid() const =0
It checks if the data source is valid (available for using).
 
virtual bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
 
virtual std::unique_ptr< Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
 
virtual void update(const std::string &datasetName, DataSet *dataset, const std::vector< std::set< int > > &properties, const std::vector< size_t > &ids)
It updates the contents of a dataset.
 
virtual void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
 
virtual void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
 
virtual bool hasDataSets()
It checks if the data source has any dataset.
 
virtual void changePropertyDefinition(const std::string &datasetName, const std::string &propName, te::dt::Property *newProp)
 
A Query is independent from the data source language/dialect.
 
virtual std::unique_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, const std::string &propertyName)
It retrieves the bounding rectangle of the spatial property for the given dataset.
 
virtual void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
 
TraverseType
A dataset can be traversed in two ways:
 
It describes an index associated to a DataSetType.
 
virtual std::vector< std::string > getDataSourceNames(const std::string &connInfo)=0
It gets the data source names available in a driver.
 
virtual bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
 
virtual void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
 
DataSource(const te::core::URI &uri)
Default constructor that can be called by subclasses.
 
virtual bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
 
virtual void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
 
virtual const DataSourceCapabilities & getCapabilities() const =0
It returns the known capabilities of the data source.
 
virtual void close()=0
It closes the data source and clears all the resources used by its internal communication channel.
 
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
 
virtual void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
 
const std::string & getId() const
An identification value for the data source.
 
virtual void setEncoding(const te::core::EncodingType &et)
It sets the encodings for the data source.
 
virtual ~DataSource()
Virtual destructor.
 
virtual std::unique_ptr< DataSourceTransactor > getTransactor()=0
It returns the set of parameters used to set up the access channel to the underlying repository.
 
std::unique_ptr< te::da::DataSetTypeCapabilities > getCapabilities(const std::string &name)
It gets capabilities about a data set.
 
virtual void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
 
static bool exists(const std::string &dsType, const std::string &connInfo)
It checks if the data source exists with the connection information and the driver type.
 
virtual void execute(const std::string &command)
It executes the specified command in the data source native language.
 
virtual void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the given dataset.
 
virtual std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
 
virtual void dropSequence(const std::string &name)
It removes the sequence from the data source.
 
DataSource(const std::string &connInfo)
 
virtual 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.
 
virtual void addCheckConstraint(const std::string &datasetName, CheckConstraint *cc)
It adds a check constraint to the dataset.
 
virtual void drop(const std::string &connInfo)=0
It removes the data source with the connection information from a driver.
 
virtual void addPrimaryKey(const std::string &datasetName, PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
 
It models a foreign key constraint for a DataSetType.
 
SpatialRelation
Spatial relations between geometric objects.
 
virtual void createDataSet(DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
 
virtual 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.
 
A class to store the proxy information that must be used to access data located in URIs.
 
virtual std::unique_ptr< DataSet > query(const Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. This method always returns a dis...
 
static void drop(const std::string &dsType, const std::string &connInfo)
It removes a data source identified by its connection information and the driver type.
 
const te::core::URI & getConnectionInfo() const
An Uniform Resource Identifier used to describe the datasource connection.
 
virtual std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
 
virtual void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
 
virtual void open()=0
It opens the data source and makes it ready for using.
 
static std::unique_ptr< DataSource > create(const std::string &dsType, const std::string &connInfo)
It creates a new repository for a data source.
 
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,...
 
virtual std::unique_ptr< ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
 
virtual std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
 
A Select models a query to be used when retrieving data from a DataSource.
 
It describes a unique key (uk) constraint.
 
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
 
virtual std::unique_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, std::size_t propertyPos)
It retrieves the bounding rectangle for the spatial property lying in the given position in the datas...
 
virtual bool isOpened() const =0
It returns true if the data source is opened, otherwise it returns false.
 
An abstract class for data providers like a DBMS, Web Services or a regular file.
 
virtual void addForeignKey(const std::string &datasetName, ForeignKey *fk)
It adds a foreign key constraint to a dataset.
 
virtual void execute(const Query &command)
It executes the specified command using a generic query representation.
 
It models a property definition.
 
boost::shared_ptr< DataSource > DataSourcePtr
 
virtual std::string getType() const =0
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS,...
 
A dataset is the unit of information manipulated by the data access module of TerraLib.
 
It describes a sequence (a number generator).
 
EncodingType
Supported character encodings.
 
virtual std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
 
virtual std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
 
It describes a primary key (pk) constraint.
 
virtual std::unique_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name)
It gets the index with the given name from the dataset.
 
A class that models the description of a dataset.
 
virtual std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
 
static std::vector< std::string > getDataSourceNames(const std::string &dsType, const std::string &connInfo)
It returns the data source names available in the driver.
 
virtual std::unique_ptr< DataSet > query(const std::string &query, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using the data source native language....
 
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
 
virtual const SQLDialect * getDialect() const =0
It returns the data source SQL dialect, if there is one.
 
virtual void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
 
virtual bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
 
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
 
virtual te::core::EncodingType getEncoding()
It return the DataSource current encoding.
 
virtual std::unique_ptr< DataSet > getDataSet(const std::string &name, const std::string &propertyName, const te::gm::Geometry *g, te::gm::SpatialRelation r, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name using a spatial filter over the given geometric prop...
 
virtual std::string getGeometryTypeName(te::gm::GeomType type)
It gets the datasource geometry type name equivalent to terralib.
 
virtual void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
 
AccessPolicy
Supported data access policies (can be used as bitfield).
 
virtual std::unique_ptr< DataSet > getDataSet(const std::string &name, const std::string &propertyName, const te::gm::Envelope *e, te::gm::SpatialRelation r, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name using a spatial filter over the specified property....
 
This class represents a set of unique ids created in the same context. i.e. from the same data set.
 
virtual std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
 
virtual bool foreignKeyExists(const std::string &datasetName, const std::string &name)
It checks if a foreign key with the given name exists in the data source.
 
virtual void addUniqueKey(const std::string &datasetName, UniqueKey *uk)
It adds a unique key constraint to the dataset.
 
std::unique_ptr< te::da::DataSet > getDataSet(const std::string &name, const te::da::ObjectIdSet *oids, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name using the identification of the objects....