Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ConnectionPool.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/ConnectionPool.h
22
23
\brief A class that implements a connection pool for PostGIS.
24
*/
25
26
#ifndef __TERRALIB_POSTGIS_INTERNAL_CONNECTIONPOOL_H
27
#define __TERRALIB_POSTGIS_INTERNAL_CONNECTIONPOOL_H
28
29
// TerraLib
30
#include "../dataaccess/datasource/AbstractConnectionPool.h"
31
#include "
Config.h
"
32
33
namespace
te
34
{
35
namespace
pgis
36
{
37
// Forward declarations
38
class
Connection;
39
class
DataSource;
40
41
/*!
42
\class ConnectionPool
43
44
\brief This class implements a connection pool for the PostGIS driver.
45
46
\sa AbstractConnectionPool, ConnectionPoolManager, Connection
47
*/
48
class
TEPGISEXPORT
ConnectionPool
:
public
te::da::AbstractConnectionPool
49
{
50
public
:
51
52
void
initialize();
53
54
void
finalize();
55
56
void
idle();
57
58
bool
isValid()
const
;
59
60
bool
isInitialized()
const
;
61
62
te::pgis::DataSource
* getDataSource()
const
;
63
64
std::size_t getPoolSize()
const
;
65
66
std::size_t getInitialPoolSize()
const
;
67
68
void
setInitialPoolSize(std::size_t size);
69
70
std::size_t getMinPoolSize()
const
;
71
72
void
setMinPoolSize(std::size_t size);
73
74
std::size_t getMaxPoolSize()
const
;
75
76
void
setMaxPoolSize(std::size_t size);
77
78
/*!
79
\brief It returns a connection from the pool.
80
81
\return A connection if one is available or an exception will be raised.
82
83
\exception Exception It throws an exception if it is not possible to get a connection.
84
85
\warning You must call the release() method after using the connection to assure
86
that the connection was returned to the pool. This approach
87
will increase concurrency in the connection.
88
89
\note PostGIS extended method.
90
*/
91
Connection
* getConnection();
92
93
/*!
94
\brief It brings the informed connection back to the pool.
95
96
\param conn The connection to be put back the pool.
97
98
\note PostGIS extended method.
99
*/
100
void
release(
Connection
* conn);
101
102
/*!
103
\brief It returns the maximum idle time in seconds that a connection can be maintained in the pool without being used.
104
105
\return The maximum idle time that a connection can be maintained in the pool without being used.
106
107
\note Thread-safe.
108
109
\note PostGIS extended method.
110
*/
111
unsigned
int
getMaxIdleTime()
const
;
112
113
/*!
114
\brief It sets the maximum idle time that a connection can be maintained in the pool without being used.
115
116
\param t It specifies the maximum idle time in seconds that a connection
117
can be maintained in the pool without being used.
118
119
\note A zero value indicates that the connections will not be removed from the
120
pool when it is not being used for a while.
121
122
\note Thread-safe.
123
124
\note PostGIS extended method.
125
*/
126
void
setMaxIdleTime(
unsigned
int
t);
127
128
private
:
129
130
/*!
131
\brief It creates a new connection pool for the database informed.
132
133
\param ds The data source using this pool.
134
*/
135
ConnectionPool
(
DataSource
* ds);
136
137
/*!
138
\brief Destructor.
139
140
It will automatically close all connections to a PostgreSQL database.
141
*/
142
~
ConnectionPool
();
143
144
private
:
145
146
class
ConnectionPoolImpl;
147
148
ConnectionPoolImpl*
m_pImpl
;
//!< A pointer to the pool implementation.
149
150
friend
class
DataSource
;
151
};
152
153
}
// end namespace pgis
154
}
// end namespace te
155
156
157
#endif // __TERRALIB_POSTGIS_INTERNAL_CONNECTIONPOOL_H
te::pgis::Connection
A class that implements a connection to a PostgreSQL database.
Definition:
Connection.h:68
TEPGISEXPORT
#define TEPGISEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition:
Config.h:195
te::pgis::DataSource
The PostGIS driver.
Definition:
DataSource.h:54
Config.h
Configuration flags for the PostGIS Driver Implementation of TerraLib.
te::pgis::ConnectionPool::m_pImpl
ConnectionPoolImpl * m_pImpl
A pointer to the pool implementation.
Definition:
ConnectionPool.h:146
te::pgis::ConnectionPool
This class implements a connection pool for the PostGIS driver.
Definition:
ConnectionPool.h:48
te::da::AbstractConnectionPool
This class defines the basic interface for a connection pool.
Definition:
AbstractConnectionPool.h:64
AA_TL5_master
terralib5
src
terralib
postgis
ConnectionPool.h
Generated on Wed Mar 16 2016 15:42:01 for TerraLib by
1.8.7