test
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 33 of file ConnectionPool.h.

Constructor & Destructor Documentation

ora::ConnectionPool::ConnectionPool ( )

Definition at line 48 of file ConnectionPool.cc.

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

Definition at line 51 of file ConnectionPool.cc.

51  {
52 }

Member Function Documentation

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

Definition at line 57 of file ConnectionPool.cc.

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

Definition at line 61 of file ConnectionPool.cc.

References models::session, and tmp.

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

62  {
63  bool valid = false;
64  boost::shared_ptr<coral::ISessionProxy> session;
65  std::map<std::string,boost::weak_ptr<coral::ISessionProxy> >::iterator iS = m_sessions.find( lookupString( connectionString, accessMode ) );
66  if( iS != m_sessions.end() ){
67  if( !iS->second.expired() ){
68  session = iS->second.lock();
69  valid = true;
70  }
71  } else {
72  iS = m_sessions.insert(std::make_pair( lookupString( connectionString, accessMode ),boost::weak_ptr<coral::ISessionProxy>())).first;
73  }
74  if(!valid){
75  session.reset(m_connectionService.connect( connectionString, accessMode ));
76  boost::weak_ptr<coral::ISessionProxy> tmp(session);
77  iS->second.swap( tmp );
78  }
79  return SharedSession( session );
80 }
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
string connectionString
Definition: autoCondHLT.py:4
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
session
Definition: models.py:201
ora::SharedSession ora::ConnectionPool::connect ( const std::string &  connectionString,
const std::string &  asRole,
coral::AccessMode  accessMode 
)

Definition at line 82 of file ConnectionPool.cc.

References models::session, and tmp.

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

84  {
85  bool valid = false;
86  boost::shared_ptr<coral::ISessionProxy> session;
87  std::map<std::string,boost::weak_ptr<coral::ISessionProxy> >::iterator iS = m_sessions.find( lookupString( connectionString, asRole, accessMode ) );
88  if( iS != m_sessions.end() ){
89  if( !iS->second.expired() ){
90  session = iS->second.lock();
91  valid = true;
92  }
93  } else {
94  iS = m_sessions.insert(std::make_pair( lookupString( connectionString, asRole, accessMode ),boost::weak_ptr<coral::ISessionProxy>())).first;
95  }
96  if(!valid){
97  session.reset(m_connectionService.connect( connectionString, asRole, accessMode ));
98  boost::weak_ptr<coral::ISessionProxy> tmp(session);
99  iS->second.swap( tmp );
100  }
101  return SharedSession( session );
102 }
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
string connectionString
Definition: autoCondHLT.py:4
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
session
Definition: models.py:201
coral::IConnectionService & ora::ConnectionPool::connectionService ( )

Definition at line 54 of file ConnectionPool.cc.

54  {
55  return m_connectionService;
56 }
coral::ConnectionService m_connectionService
std::string ora::ConnectionPool::lookupString ( const std::string &  connectionString,
coral::AccessMode  accessMode 
)
staticprivate

Definition at line 105 of file ConnectionPool.cc.

106  {
107  std::stringstream lookupString;
108  lookupString << "["<<connectionString << "]_";
109  if(accessMode == coral::ReadOnly){
110  lookupString << "R";
111  } else {
112  lookupString << "W";
113  }
114  return lookupString.str();
115 }
static std::string lookupString(const std::string &connectionString, coral::AccessMode accessMode)
string connectionString
Definition: autoCondHLT.py:4
std::string ora::ConnectionPool::lookupString ( const std::string &  connectionString,
const std::string &  role,
coral::AccessMode  accessMode 
)
staticprivate

Definition at line 117 of file ConnectionPool.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

119  {
120  std::string rolePrefix(role);
121  return rolePrefix+lookupString( connectionString, accessMode );
122 }
static std::string lookupString(const std::string &connectionString, coral::AccessMode accessMode)
string connectionString
Definition: autoCondHLT.py:4

Member Data Documentation

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

Definition at line 54 of file ConnectionPool.h.

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

Definition at line 56 of file ConnectionPool.h.