FIX::DatabaseConnectionPool< T > Class Template Reference

`#include <DatabaseConnectionPool.h>`

## Public Member Functions

| DatabaseConnectionPool (bool poolConnections)
T * | create (const DatabaseConnectionID &id)
bool | destroy (T *pConnection)

## Private Types

typedef std::pair< T *, int > | Connection
typedef std::map< DatabaseConnectionID, Connection > | Connections

## Private Attributes

Connections | m_connections
bool | m_poolConnections

## Detailed Description

### template<typename T>
class FIX::DatabaseConnectionPool< T >

Definition at line 35 of file DatabaseConnectionPool.h.

## Member Typedef Documentation

## Connection

template<typename T >

typedef std::pair<T*, int> FIX::DatabaseConnectionPool< T >::Connection

private

Definition at line 82 of file DatabaseConnectionPool.h.

## Connections

template<typename T >

typedef std::map<DatabaseConnectionID, Connection> FIX::DatabaseConnectionPool< T >::Connections

private

Definition at line 84 of file DatabaseConnectionPool.h.

## Constructor & Destructor Documentation

## DatabaseConnectionPool()

template<typename T >

FIX::DatabaseConnectionPool< T >::DatabaseConnectionPool | ( | bool | poolConnections | ) |

inline

Definition at line 38 of file DatabaseConnectionPool.h.

: m_poolConnections( poolConnections ) {}
FIX::DatabaseConnectionPool::m_poolConnections
bool m_poolConnections
Definition: DatabaseConnectionPool.h:87

## Member Function Documentation

## create()

template<typename T >

T* FIX::DatabaseConnectionPool< T >::create | ( | const DatabaseConnectionID & | id | ) |

inline

Definition at line 41 of file DatabaseConnectionPool.h.

References FIX::DatabaseConnectionPool< T >::m_connections, and FIX::DatabaseConnectionPool< T >::m_poolConnections.

{
if( !m_poolConnections )
return new T( id );
if( m_connections.find( id ) == m_connections.end() )
{
m_connections[id] = Connection
( new T(id), 0 );
}
m_connections[id].second++;
return m_connections[id].first;
}
FIX::DatabaseConnectionPool::m_connections
Connections m_connections
Definition: DatabaseConnectionPool.h:86
FIX::DatabaseConnectionPool::m_poolConnections
bool m_poolConnections
Definition: DatabaseConnectionPool.h:87
FIX::DatabaseConnectionPool::Connection
std::pair< T *, int > Connection
Definition: DatabaseConnectionPool.h:82

## destroy()

template<typename T >

bool FIX::DatabaseConnectionPool< T >::destroy | ( | T * | pConnection | ) |

inline

Definition at line 55 of file DatabaseConnectionPool.h.

References FIX::DatabaseConnectionPool< T >::m_connections, and FIX::DatabaseConnectionPool< T >::m_poolConnections.

{
if( !m_poolConnections )
{
delete pConnection;
return true;
}
const DatabaseConnectionID& id = pConnection->connectionID();
if( m_connections.find( id ) == m_connections.end() )
return false;
Connection& connection = m_connections[id];
if( connection.first != pConnection )
return false;
connection.second--;
if( connection.second == 0 )
{
m_connections.erase( id );
delete pConnection;
}
return true;
}
FIX::DatabaseConnectionPool::m_connections
Connections m_connections
Definition: DatabaseConnectionPool.h:86
FIX::DatabaseConnectionPool::m_poolConnections
bool m_poolConnections
Definition: DatabaseConnectionPool.h:87
FIX::DatabaseConnectionPool::Connection
std::pair< T *, int > Connection
Definition: DatabaseConnectionPool.h:82

## Member Data Documentation

## m_connections

template<typename T >

Connections FIX::DatabaseConnectionPool< T >::m_connections

private

Definition at line 86 of file DatabaseConnectionPool.h.

Referenced by FIX::DatabaseConnectionPool< T >::create(), and FIX::DatabaseConnectionPool< T >::destroy().

## m_poolConnections

template<typename T >

bool FIX::DatabaseConnectionPool< T >::m_poolConnections

private

Definition at line 87 of file DatabaseConnectionPool.h.

Referenced by FIX::DatabaseConnectionPool< T >::create(), and FIX::DatabaseConnectionPool< T >::destroy().

The documentation for this class was generated from the following file:

- DatabaseConnectionPool.h