CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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>

Public Member Functions

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

Static Private Member Functions

static std::string lookupString (const std::string &connectionString, coral::AccessMode accessMode)
 
static std::string lookupString (const std::string &connectionString, const std::string &role, 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.

44 }
std::map< std::string, boost::weak_ptr< coral::ISessionProxy > > m_sessions
coral::ConnectionService m_connectionService
ora::ConnectionPool::~ConnectionPool ( )
virtual

Definition at line 46 of file ConnectionPool.cc.

46  {
47 }

Member Function Documentation

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

Definition at line 52 of file ConnectionPool.cc.

52  {
53  return m_connectionService.configuration();
54 }
coral::ConnectionService m_connectionService
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.

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

57  {
58  bool valid = false;
59  boost::shared_ptr<coral::ISessionProxy> session;
60  std::map<std::string,boost::weak_ptr<coral::ISessionProxy> >::iterator iS = m_sessions.find( lookupString( connectionString, accessMode ) );
61  if( iS != m_sessions.end() ){
62  if( !iS->second.expired() ){
63  session = iS->second.lock();
64  valid = true;
65  }
66  } else {
67  iS = m_sessions.insert(std::make_pair( lookupString( connectionString, accessMode ),boost::weak_ptr<coral::ISessionProxy>())).first;
68  }
69  if(!valid){
70  session.reset(m_connectionService.connect( connectionString, accessMode ));
71  boost::weak_ptr<coral::ISessionProxy> tmp(session);
72  iS->second.swap( tmp );
73  }
74  return SharedSession( session );
75 }
static std::string lookupString(const std::string &connectionString, coral::AccessMode accessMode)
std::map< std::string, boost::weak_ptr< coral::ISessionProxy > > m_sessions
coral::ConnectionService m_connectionService
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
ora::SharedSession ora::ConnectionPool::connect ( const std::string &  connectionString,
const std::string &  asRole,
coral::AccessMode  accessMode 
)

Definition at line 77 of file ConnectionPool.cc.

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

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

79  {
80  bool valid = false;
81  boost::shared_ptr<coral::ISessionProxy> session;
82  std::map<std::string,boost::weak_ptr<coral::ISessionProxy> >::iterator iS = m_sessions.find( lookupString( connectionString, asRole, accessMode ) );
83  if( iS != m_sessions.end() ){
84  if( !iS->second.expired() ){
85  session = iS->second.lock();
86  valid = true;
87  }
88  } else {
89  iS = m_sessions.insert(std::make_pair( lookupString( connectionString, asRole, accessMode ),boost::weak_ptr<coral::ISessionProxy>())).first;
90  }
91  if(!valid){
92  session.reset(m_connectionService.connect( connectionString, asRole, accessMode ));
93  boost::weak_ptr<coral::ISessionProxy> tmp(session);
94  iS->second.swap( tmp );
95  }
96  return SharedSession( session );
97 }
static std::string lookupString(const std::string &connectionString, coral::AccessMode accessMode)
std::map< std::string, boost::weak_ptr< coral::ISessionProxy > > m_sessions
coral::ConnectionService m_connectionService
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
coral::IConnectionService & ora::ConnectionPool::connectionService ( )

Definition at line 49 of file ConnectionPool.cc.

49  {
50  return m_connectionService;
51 }
coral::ConnectionService m_connectionService
std::string ora::ConnectionPool::lookupString ( const std::string &  connectionString,
coral::AccessMode  accessMode 
)
staticprivate

Definition at line 100 of file ConnectionPool.cc.

101  {
102  std::stringstream lookupString;
103  lookupString << "["<<connectionString << "]_";
104  if(accessMode == coral::ReadOnly){
105  lookupString << "R";
106  } else {
107  lookupString << "W";
108  }
109  return lookupString.str();
110 }
static std::string lookupString(const std::string &connectionString, coral::AccessMode accessMode)
std::string ora::ConnectionPool::lookupString ( const std::string &  connectionString,
const std::string &  role,
coral::AccessMode  accessMode 
)
staticprivate

Definition at line 112 of file ConnectionPool.cc.

114  {
115  std::string rolePrefix(role);
116  return rolePrefix+lookupString( connectionString, accessMode );
117 }
static std::string lookupString(const std::string &connectionString, coral::AccessMode accessMode)

Member Data Documentation

coral::ConnectionService ora::ConnectionPool::m_connectionService
private

Definition at line 53 of file ConnectionPool.h.

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

Definition at line 55 of file ConnectionPool.h.