Loading...
Searching...
No Matches
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/postgis/DataSource.h
22
23 \brief Implementation of the data source for the PostGIS driver.
24*/
25
26#ifndef __TERRALIB_POSTGIS_INTERNAL_DATASOURCE_H
27#define __TERRALIB_POSTGIS_INTERNAL_DATASOURCE_H
28
29// TerraLib
30#include "../dataaccess/datasource/DataSource.h"
31#include "../dataaccess/datasource/DataSourceCapabilities.h"
32#include "Config.h"
33
34namespace te
35{
36 namespace core { class URI; }
37 namespace gm { class GeometryProperty; }
38 namespace rst { class RasterProperty; }
39
40 namespace pgis
41 {
42 // Forward declaration
43 class Connection;
44 class ConnectionPool;
45 struct VersionInfo;
46
47 /*!
48 \class DataSource
49
50 \brief The PostGIS driver.
51
52 \sa te::da::DataSource, te::da::DataSourceFactory, te::da::DataSourceManager, DataSourceFactory
53 */
55 {
56 public:
57
58 /** @name Initializer Methods
59 * Methods related to the instantiation and destruction.
60 */
61 //@{
62
63 DataSource(const std::string& connInfo);
64
66
68
69 std::string getType() const;
70
71 std::unique_ptr<te::da::DataSourceTransactor> getTransactor();
72
74
76
78
79 void setTimeAsInteger(bool timeIsInteger);
80
81 /*!
82 \brief It opens the connection(s) to the PostgreSQL database server.
83
84 This method will:
85 <ul>
86 <li>start the connection pool;</li>
87 <li>register the data type maps and get PostGIS geometry type OID;</li>
88 <li>get PostgreSQL version information;</li>
89 <li>get PostGIS version information;</li>
90 <li>get default schema name;</li>
91 <li>register user defined types (udts);</li>
92 </ul>
93
94 \exception Exception It throws an exception if the data source can not be opened.
95
96 \note Not thread safe!
97 */
98 void open();
99
100 void close();
101
102 bool isOpened() const;
103
104 bool isValid() const;
105
107
109
110 /*!
111 \brief It returns the type id associated to the PostGIS Geometry type.
112
113 \return The type id associated to the PostGIS Geometry type.
114
115 \note PostGIS driver extended method.
116 */
117 unsigned int getGeomTypeId() const;
118
119 /*!
120 \brief It returns the type id associated to the PostGIS Raster type.
121
122 \return The type id associated to the PostGIS Raster type.
123
124 \note PostGIS driver extended method.
125 */
126 unsigned int getRasterTypeId() const;
127
128 /*!
129 \brief It returns the current schema associated to the database connection, or NULL, if none is set.
130
131 \return The current schema associated to the database connection, or NULL, if none is set.
132
133 \note PostGIS driver extended method.
134 */
135 const std::string& getCurrentSchema() const;
136
137 /*!
138 \brief It returns a pointer to the internal connection pool.
139
140 \return A pointer to the internal connection pool.
141
142 \note The caller must not delete the connectio pool. It is used by transactor class.
143
144 \note PostGIS driver extended method.
145 */
147
148 protected:
149
150 void create(const std::string& connInfo);
151
152 void drop(const std::string& connInfo);
153
154 bool exists(const std::string& connInfo);
155
156 std::vector<std::string> getDataSourceNames(const std::string& connInfo);
157
158 private:
159
160 ConnectionPool* m_pool; //!< The connection pool.
161 unsigned int m_geomTypeOid; //!< PostGIS Geometry type OID.
162 unsigned int m_rasterTypeOid; //!< PostGIS Raster type OID.
163 std::string m_currentSchema; //!< The default schema used when no one is provided.
164 bool m_timeIsInteger; //!< It indicates if the postgis stores, internally, time and timestamp as an integer.
165
166 static te::da::DataSourceCapabilities sm_capabilities; //!< PostGIS capabilities.
167 static te::da::SQLDialect* sm_dialect; //!< PostGIS SQL dialect.
168 };
169
170 } // end namespace pgis
171} // end namespace te
172
173#endif // __TERRALIB_POSTGIS_INTERNAL_DATASOURCE_H
A class to store the proxy information that must be used to access data located in URIs.
Definition: URI.h:50
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:56
This class implements a connection pool for the PostGIS driver.
A class that implements a connection to a PostgreSQL database.
Definition: Connection.h:69
The PostGIS driver.
Definition: DataSource.h:55
const std::string & getCurrentSchema() const
It returns the current schema associated to the database connection, or NULL, if none is set.
void drop(const std::string &connInfo)
It removes the data source with the connection information from a driver.
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
std::unique_ptr< te::da::DataSourceTransactor > getTransactor()
It returns the set of parameters used to set up the access channel to the underlying repository.
DataSource(const te::core::URI &uri)
bool exists(const std::string &connInfo)
Check the existence of a data source in a driver.
unsigned int m_geomTypeOid
PostGIS Geometry type OID.
Definition: DataSource.h:161
~DataSource()
Virtual destructor.
unsigned int getRasterTypeId() const
It returns the type id associated to the PostGIS Raster type.
ConnectionPool * getConnPool() const
It returns a pointer to the internal connection pool.
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
unsigned int m_rasterTypeOid
PostGIS Raster type OID.
Definition: DataSource.h:162
void setTimeAsInteger(bool timeIsInteger)
std::vector< std::string > getDataSourceNames(const std::string &connInfo)
It gets the data source names available in a driver.
std::string m_currentSchema
The default schema used when no one is provided.
Definition: DataSource.h:163
bool m_timeIsInteger
It indicates if the postgis stores, internally, time and timestamp as an integer.
Definition: DataSource.h:164
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS,...
DataSource(const std::string &connInfo)
void closeConnection(Connection *conn)
void close()
It closes the data source and clears all the resources used by its internal communication channel.
te::pgis::Connection * getConnection()
bool isValid() const
It checks if the data source is valid (available for using).
static te::da::DataSourceCapabilities sm_capabilities
PostGIS capabilities.
Definition: DataSource.h:166
unsigned int getGeomTypeId() const
It returns the type id associated to the PostGIS Geometry type.
void open()
It opens the connection(s) to the PostgreSQL database server.
void create(const std::string &connInfo)
It creates a new data source.
static te::da::SQLDialect * sm_dialect
PostGIS SQL dialect.
Definition: DataSource.h:167
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
ConnectionPool * m_pool
The connection pool.
Definition: DataSource.h:160
TerraLib.
#define TEPGISEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:195
Proxy configuration file for TerraView (see terraview_config.h).