CMS 3D CMS Logo

Public Member Functions | Static Private Member Functions | Private Attributes

ora::ConnectionPool Class Reference

To be moved in DBCommon, has to serve also the pure coral use case. More...

#include <ConnectionPool.h>

List of all members.

Public Member Functions

coral::IConnectionServiceConfiguration & configuration ()
SharedSession connect (const std::string &connectionString, coral::AccessMode accessMode)
 ConnectionPool ()
coral::IConnectionService & connectionService ()
virtual ~ConnectionPool ()

Static Private Member Functions

static std::string lookupString (const std::string &connectionString, coral::AccessMode accessMode)

Private Attributes

coral::ConnectionService m_connectionService
std::map< std::string,
boost::weak_ptr
< coral::ISessionProxy > > 
m_sessions

Detailed Description

To be moved in DBCommon, has to serve also the pure coral use case.

Definition at line 32 of file ConnectionPool.h.


Constructor & Destructor Documentation

ora::ConnectionPool::ConnectionPool ( )

Definition at line 43 of file ConnectionPool.cc.

ora::ConnectionPool::~ConnectionPool ( ) [virtual]

Definition at line 46 of file ConnectionPool.cc.

                                  {
}

Member Function Documentation

coral::IConnectionServiceConfiguration & ora::ConnectionPool::configuration ( )

Definition at line 52 of file ConnectionPool.cc.

                                                                      {
  return m_connectionService.configuration();
}
ora::SharedSession ora::ConnectionPool::connect ( const std::string &  connectionString,
coral::AccessMode  accessMode 
)

Definition at line 56 of file ConnectionPool.cc.

References python::CommonUtils::session, tmp, and TrackValidation_HighPurity_cff::valid.

                                                                              {
  bool valid = false;
  boost::shared_ptr<coral::ISessionProxy> session;
  std::map<std::string,boost::weak_ptr<coral::ISessionProxy> >::iterator iS = m_sessions.find( lookupString( connectionString, accessMode ) );
  if( iS != m_sessions.end() ){
    if( !iS->second.expired() ){
      session = iS->second.lock();
      valid = true;
    } 
  } else {
    iS = m_sessions.insert(std::make_pair( lookupString( connectionString, accessMode ),boost::weak_ptr<coral::ISessionProxy>())).first;
  }
  if(!valid){
    session.reset(m_connectionService.connect( connectionString, accessMode ));
    boost::weak_ptr<coral::ISessionProxy> tmp(session);
    iS->second.swap( tmp );
  }
  return SharedSession( session );
}
coral::IConnectionService & ora::ConnectionPool::connectionService ( )

Definition at line 49 of file ConnectionPool.cc.

                                                             {
  return m_connectionService;
}
std::string ora::ConnectionPool::lookupString ( const std::string &  connectionString,
coral::AccessMode  accessMode 
) [static, private]

Definition at line 77 of file ConnectionPool.cc.

                                                                           {
  std::stringstream lookupString;
  lookupString << connectionString << "_";
  if(accessMode == coral::ReadOnly){
    lookupString << "R";
  } else {
    lookupString << "W";
  }
  return lookupString.str();
}

Member Data Documentation

coral::ConnectionService ora::ConnectionPool::m_connectionService [private]

Definition at line 51 of file ConnectionPool.h.

std::map<std::string,boost::weak_ptr<coral::ISessionProxy> > ora::ConnectionPool::m_sessions [private]

Definition at line 53 of file ConnectionPool.h.