DataSource.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/ogr/DataSource.h
22 
23  \brief A class for data providers of OGR.
24 */
25 
26 #ifndef __TERRALIB_OGR_INTERNAL_DATASOURCE_H
27 #define __TERRALIB_OGR_INTERNAL_DATASOURCE_H
28 
29 // TerraLib
30 #include "Config.h"
31 #include "../dataaccess/datasource/DataSource.h"
32 #include "../dataaccess/datasource/DataSourceCapabilities.h"
33 #include "../dataaccess/dataset/DataSetType.h"
34 #include "Exception.h"
35 
36 // Forward declarations
37 //class OGRDataSource;
38 class GDALDataset;
39 
40 namespace te
41 {
42  namespace ogr
43  {
44  /*!
45  \class DataSource
46 
47  \brief The OGR data source provider.
48  */
50  {
51  public:
52 
53  DataSource(const std::string& connInfo);
54 
56 
57  /*! \brief Virtual destructor. */
59 
60  std::string getType() const;
61 
62  std::unique_ptr<te::da::DataSourceTransactor> getTransactor();
63 
64  void open();
65 
66  void close();
67 
68  bool isOpened() const;
69 
70  bool isValid() const;
71 
73 
75 
76  void createDataSet(te::da::DataSetType* dt, const std::map<std::string, std::string>& options);
77 
78  static void setDialect(te::da::SQLDialect* dialect);
79 
80  GDALDataset* getOGRDataSource();
81 
83 
85 
87 
88  void begin();
89 
90  void commit();
91 
92  void rollBack();
93 
94  bool isInTransaction() const;
95 
97 
98  protected:
99 
100  void create(const std::string& connInfo);
101 
102  void drop(const std::string& connInfo);
103 
104  bool exists(const std::string& connInfo);
105 
106  std::vector<std::string> getDataSourceNames(const std::string& connInfo);
107 
108  protected:
109 
110  GDALDataset* m_ogrDS; //!< A pointer to OGR Data Source.
111  bool m_isValid; //!< True if this is a valid datasource.
113  static te::da::SQLDialect* sm_myDialect; //!< OGR SQL dialect.
114  te::core::EncodingType m_encoding; //!< The data source encoding type.
115  std::size_t m_transactionCount; //!< A counter to handle nested transactions
116  };
117 
119  } // end namespace da
120 } // end namespace te
121 
122 #endif // __TERRALIB_OGR_INTERNAL_DATASOURCE_H
te::ogr::DataSource::m_capabilities
te::da::DataSourceCapabilities m_capabilities
OGR capabilities.
Definition: DataSource.h:112
te::ogr::DataSource::getDialect
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
te::ogr::DataSource::getTransactor
std::unique_ptr< te::da::DataSourceTransactor > getTransactor()
It returns the set of parameters used to set up the access channel to the underlying repository.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::ogr::DataSource::m_isValid
bool m_isValid
True if this is a valid datasource.
Definition: DataSource.h:111
te::ogr::DataSource::isOpened
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
te::ogr::Build
te::da::DataSource * Build(const te::core::URI &uri)
te::da::SQLDialect
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:56
te::ogr::DataSource::open
void open()
It opens the data source and makes it ready for using.
te::ogr::DataSource::drop
void drop(const std::string &connInfo)
It removes the data source with the connection information from a driver.
te::ogr::DataSource::DataSource
DataSource(const std::string &connInfo)
te::ogr::DataSource::close
void close()
It closes the data source and clears all the resources used by its internal communication channel.
te::ogr::DataSource::rollBack
void rollBack()
te::ogr::DataSource::getDataSourceNames
std::vector< std::string > getDataSourceNames(const std::string &connInfo)
It gets the data source names available in a driver.
te::ogr::DataSource::m_encoding
te::core::EncodingType m_encoding
The data source encoding type.
Definition: DataSource.h:114
te::ogr::DataSource::sm_myDialect
static te::da::SQLDialect * sm_myDialect
OGR SQL dialect.
Definition: DataSource.h:113
te::ogr::DataSource::DataSource
DataSource(const te::core::URI &uri)
te::ogr::DataSource::createDataSet
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.
te::ogr::DataSource::m_ogrDS
GDALDataset * m_ogrDS
A pointer to OGR Data Source.
Definition: DataSource.h:110
te::ogr::DataSource::setEncoding
void setEncoding(const te::core::EncodingType &et)
It sets the encodings for the data source.
te::ogr::DataSource::begin
void begin()
te::ogr::DataSource::getCapabilities
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
te::ogr::DataSource::createOGRDataSource
void createOGRDataSource()
Exception.h
An exception class for the XML module.
te::ogr::DataSource::isValid
bool isValid() const
It checks if the data source is valid (available for using).
te::ogr::DataSource::setDialect
static void setDialect(te::da::SQLDialect *dialect)
te::ogr::DataSource::getEncoding
te::core::EncodingType getEncoding()
It return the DataSource current encoding.
te::core::URI
A class to store the proxy information that must be used to access data located in URIs.
Definition: URI.h:50
te::ogr::DataSource::getOGRDataSource
GDALDataset * getOGRDataSource()
te::ogr::DataSource::isInTransaction
bool isInTransaction() const
te::ogr::DataSource::exists
bool exists(const std::string &connInfo)
Check the existence of a data source in a driver.
te::ogr::DataSource::getType
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS,...
te::ogr::DataSource
The OGR data source provider.
Definition: DataSource.h:50
TEOGREXPORT
#define TEOGREXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:79
te::da::DataSourceCapabilities
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
Definition: DataSourceCapabilities.h:56
te::da::DataSource
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
te::core::EncodingType
EncodingType
Supported character encodings.
Definition: CharEncoding.h:51
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::ogr::DataSource::m_transactionCount
std::size_t m_transactionCount
A counter to handle nested transactions.
Definition: DataSource.h:115
te::ogr::DataSource::create
void create(const std::string &connInfo)
It creates a new data source.
te::ogr::DataSource::~DataSource
~DataSource()
Virtual destructor.
te::ogr::DataSource::commit
void commit()
te::da::DataSetType
A class that models the description of a dataset.
Definition: DataSetType.h:73
te::ogr::DataSource::updateCapabilities
void updateCapabilities()