Main Page
Modules
Namespaces
Classes
Files
File List
File Members
ScopedConnection.cpp
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/ScopedConnection.cpp
22
23
\brief A class that control the use of the connection to a PostgreSQL database.
24
*/
25
26
// TerraLib
27
#include "
Connection.h
"
28
#include "
ConnectionPool.h
"
29
#include "
ScopedConnection.h
"
30
31
te::pgis::ScopedConnection::ScopedConnection
(
ConnectionPool
* pool,
int
id
)
32
: m_connectionPool(pool){
33
m_connection
=
m_connectionPool
->
getConnection
(
id
);
34
}
35
36
te::pgis::ScopedConnection::~ScopedConnection
(){
37
release
();
38
}
39
40
void
te::pgis::ScopedConnection::release
(){
41
if
(
m_connection
!=
nullptr
)
42
{
43
m_connectionPool
->
release
(
m_connection
);
44
m_connection
=
nullptr
;
45
}
46
}
47
48
te::pgis::Connection
*
te::pgis::ScopedConnection::operator->
()
const
{
49
return
m_connection
;
50
}
ScopedConnection.h
A class that control the use of connection to a PostgreSQL database.
te::pgis::ScopedConnection::m_connectionPool
ConnectionPool * m_connectionPool
The connection pool associated to the connection.
Definition:
ScopedConnection.h:73
te::pgis::Connection
A class that implements a connection to a PostgreSQL database.
Definition:
postgis/Connection.h:68
te::pgis::ConnectionPool::release
void release(Connection *conn)
It brings the informed connection back to the pool.
Definition:
ConnectionPool.cpp:360
Connection.h
A class that implements a connection to a PostgreSQL database.
te::pgis::ScopedConnection::release
void release()
Release connection.
Definition:
ScopedConnection.cpp:40
te::pgis::ConnectionPool::getConnection
Connection * getConnection(int id=-1)
It returns a connection from the pool.
Definition:
ConnectionPool.cpp:300
te::pgis::ConnectionPool
This class implements a connection pool for the PostGIS driver.
Definition:
ConnectionPool.h:49
te::pgis::ScopedConnection::~ScopedConnection
~ScopedConnection()
Destructor.
Definition:
ScopedConnection.cpp:36
ConnectionPool.h
A class that implements a connection pool for PostGIS.
te::pgis::ScopedConnection::m_connection
Connection * m_connection
An available connection that will be released when the scopedConnection is deleted.
Definition:
ScopedConnection.h:72
te::pgis::ScopedConnection::ScopedConnection
ScopedConnection(ConnectionPool *pool, int id=-1)
Constructor.
Definition:
ScopedConnection.cpp:31
te::pgis::ScopedConnection::operator->
Connection * operator->() const
Definition:
ScopedConnection.cpp:48
terralib5_src
src
terralib
postgis
ScopedConnection.cpp
Generated on Wed Jun 6 2018 12:16:14 for TerraLib by
1.8.11