QuickFIX: FIX::DatabaseConnectionPool< T > Class Template Reference

Index Source Files Annotated Class List Alphabetical Class List Class Hierarchy Graphical Class Hierarchy

# FIX::DatabaseConnectionPool< T > Class Template Reference

`#include <DatabaseConnectionPool.h>`

List of all members.

## 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

template<typename T >

typedef std::pair<T*, int> FIX::DatabaseConnectionPool< T >::Connection`[private]`

Definition at line 82 of file DatabaseConnectionPool.h.

template<typename T >

typedef std::map<DatabaseConnectionID, Connection> FIX::DatabaseConnectionPool< T >::Connections`[private]`

Definition at line 84 of file DatabaseConnectionPool.h.

## Constructor & Destructor Documentation

template<typename T >

FIX::DatabaseConnectionPool< T >::DatabaseConnectionPool | ( | bool | poolConnections | ) | `[inline]`

Definition at line 38 of file DatabaseConnectionPool.h.

    00039   : m_poolConnections( poolConnections ) {}

## Member Function Documentation

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.

    00042   {
    00043     if( !m_poolConnections )
    00044       return new T( id );
    00045
    00046     if( m_connections.find( id ) == m_connections.end() )
    00047     {
    00048       m_connections[id] = Connection
    00049         ( new T(id), 0 );
    00050     }
    00051     m_connections[id].second++;
    00052     return m_connections[id].first;
    00053   }

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.

    00056   {
    00057     if( !m_poolConnections )
    00058     {
    00059       delete pConnection;
    00060       return true;
    00061     }
    00062
    00063     const DatabaseConnectionID& id = pConnection->connectionID();
    00064     if( m_connections.find( id ) == m_connections.end() )
    00065       return false;
    00066
    00067     Connection& connection = m_connections[id];
    00068     if( connection.first != pConnection )
    00069       return false;
    00070
    00071     connection.second--;
    00072     if( connection.second == 0 )
    00073     {
    00074       m_connections.erase( id );
    00075       delete pConnection;
    00076     }
    00077     return true;
    00078   }

## Member Data Documentation

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().

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:

- /home/omiller/Development/autobuild/quickfix/src/C++/DatabaseConnectionPool.h