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/ado/DataSource.h
22 
23  \brief Implementation of the data source class for the ADO driver.
24 */
25 
26 #ifndef __TERRALIB_ADO_INTERNAL_DATASOURCE_H
27 #define __TERRALIB_ADO_INTERNAL_DATASOURCE_H
28 
29 // TerraLib
30 #include "../dataaccess/datasource/DataSource.h"
31 #include "../dataaccess/datasource/DataSourceCapabilities.h"
32 #include "Config.h"
33 
34 // BOOST
35 #include <boost/thread/locks.hpp>
36 #include <boost/thread/mutex.hpp>
37 
38 // ADO
39 #import "msado15.dll" \
40  no_namespace rename("EOF", "EndOfFile")
41 #import "msadox.dll"
42 
43 
44 namespace te
45 {
46  namespace gm { class GeometryProperty; }
47 
48  namespace ado
49  {
50  // Forward declaration
51  class ConnectionPool;
52  struct VersionInfo;
53 
54  /*!
55  \class DataSource
56 
57  \brief The ADO driver.
58 
59  \sa te::da::DataSource, te::da::DataSourceFactory, te::da::DataSourceManager, DataSourceFactory
60  */
62  {
63  public:
64 
65  DataSource(const std::string& connInfo);
66 
68 
70 
71  std::string getType() const;
72 
73  std::unique_ptr<te::da::DataSourceTransactor> getTransactor();
74 
75  void open();
76 
77  void close();
78 
79  bool isOpened() const;
80 
81  bool isValid() const;
82 
84 
86 
87  const std::map<std::string, std::string>& getGeomColumns() const;
88 
89  void registerGeometryColumn(const std::string& datasetName,
90  const std::string& geomColName);
91 
92  bool isGeometryColumn(const std::string& datasetName,
93  const std::string& colName) const;
94 
95  protected:
96 
97  void create(const std::string& connInfo);
98 
99  void drop(const std::string& connInfo);
100 
101  bool exists(const std::string& connInfo);
102 
103  std::vector<std::string> getDataSourceNames(const std::string& connInfo);
104 
105  void loadGeometryColumnsCache(_ConnectionPtr& adoConn);
106 
107  private:
108 
109  std::map<std::string, std::string> m_geomColumns; //!< The list of geometry columns.
110  std::string m_currentSchema; //!< The default schema used when no one is provided.
111  mutable boost::mutex m_mtx;
113 
114  static te::da::DataSourceCapabilities sm_capabilities; //!< ADO capabilities.
116  };
117 
118 
119  } // end namespace pgis
120 } // end namespace te
121 
122 #endif // __TERRALIB_ADO_INTERNAL_DATASOURCE_H
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::da::SQLDialect
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:56
te::gm::GeometryProperty
Geometric property.
Definition: GeometryProperty.h:52
te::ado::DataSource::open
void open()
It opens the data source and makes it ready for using.
te::ado::DataSource::DataSource
DataSource(const te::core::URI &uri)
te::ado::DataSource::m_currentSchema
std::string m_currentSchema
The default schema used when no one is provided.
Definition: DataSource.h:110
te::ado::DataSource::getCapabilities
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
te::ado::DataSource::m_mtx
boost::mutex m_mtx
Definition: DataSource.h:111
te::ado::DataSource::isGeometryColumn
bool isGeometryColumn(const std::string &datasetName, const std::string &colName) const
te::ado::DataSource::create
void create(const std::string &connInfo)
It creates a new data source.
te::ado::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::ado::DataSource::m_isOpened
bool m_isOpened
Definition: DataSource.h:112
te::ado::DataSource::m_geomColumns
std::map< std::string, std::string > m_geomColumns
The list of geometry columns.
Definition: DataSource.h:109
te::ado::DataSource::close
void close()
It closes the data source and clears all the resources used by its internal communication channel.
te::ado::DataSource::sm_dialect
static te::da::SQLDialect * sm_dialect
Definition: DataSource.h:115
te::ado::DataSource::exists
bool exists(const std::string &connInfo)
Check the existence of a data source in a driver.
te::ado::DataSource
The ADO driver.
Definition: DataSource.h:62
te::ado::DataSource::getDialect
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
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::ado::DataSource::~DataSource
~DataSource()
Virtual destructor.
te::ado::DataSource::registerGeometryColumn
void registerGeometryColumn(const std::string &datasetName, const std::string &geomColName)
te::ado::DataSource::getType
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS,...
te::ado::DataSource::isValid
bool isValid() const
It checks if the data source is valid (available for using).
te::ado::DataSource::isOpened
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
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::ado::DataSource::loadGeometryColumnsCache
void loadGeometryColumnsCache(_ConnectionPtr &adoConn)
te::da::DataSource
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
TEADOEXPORT
#define TEADOEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:130
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::ado::DataSource::sm_capabilities
static te::da::DataSourceCapabilities sm_capabilities
ADO capabilities.
Definition: DataSource.h:114
te::ado::DataSource::getDataSourceNames
std::vector< std::string > getDataSourceNames(const std::string &connInfo)
It gets the data source names available in a driver.
te::ado::DataSource::DataSource
DataSource(const std::string &connInfo)
te::ado::DataSource::drop
void drop(const std::string &connInfo)
It removes the data source with the connection information from a driver.
te::ado::DataSource::getGeomColumns
const std::map< std::string, std::string > & getGeomColumns() const