CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DbConnection.cc
Go to the documentation of this file.
1 //local includes
5 // coral includes
6 //#include "CoralKernel/Context.h"
7 //#include "CoralKernel/IHandle.h"
8 //#include "RelationalAccess/ConnectionService.h"
9 //#include "RelationalAccess/ISessionProxy.h"
10 //#include "RelationalAccess/IConnectionServiceConfiguration.h"
11 // ora includes
13 
14 namespace cond {
16  public:
19  m_connectionPool( new ora::ConnectionPool ),
21  }
22 
23  virtual ~ConnectionImpl(){
24  close();
25  }
26 
27  void close(){
28  m_connectionPool.reset();
29  }
30 
32  boost::shared_ptr<ora::ConnectionPool> m_connectionPool;
34  };
35 }
36 
38  m_implementation(new ConnectionImpl()){
39  configure();
40 }
41 
43  m_implementation( conn.m_implementation ){
44 }
45 
47 }
48 
50 {
51  if(this!=&conn) m_implementation = conn.m_implementation;
52  return *this;
53 }
54 
56 {
57  m_implementation->m_configuration.configure( m_implementation->m_connectionPool->configuration() );
58  m_implementation->m_initialized = true;
59 }
60 
62  m_implementation->m_configuration = DbConnectionConfiguration::defaultConfigurations()[ defaultItem ];
63  configure();
64 }
65 
66 void
68  m_implementation->m_configuration.setParameters( connectionPset );
69  configure();
70 }
71 
73  if(!isOpen())
74  throw cond::Exception("DbConnection::createSession: cannot create session. Connection has been closed.");
75  return cond::DbSession( *this );
76 }
77 
78 
80 {
81  m_implementation->close();
82 }
83 
85 {
86  return m_implementation->m_connectionPool.get();
87 }
88 
90 {
91  return m_implementation->m_configuration;
92 }
93 
95 {
96  return m_implementation->m_configuration;
97 }
98 
99 boost::shared_ptr<ora::ConnectionPool> cond::DbConnection::connectionPool() const {
100  return m_implementation->m_connectionPool;
101 }
102 
103 coral::IConnectionService& cond::DbConnection::connectionService() const {
104  if(!isOpen())
105  throw cond::Exception("DbConnection::connectionService: cannot get connection service. Connection has not been open.");
106  return m_implementation->m_connectionPool->connectionService();
107 }
108 
109 const coral::IMonitoringReporter& cond::DbConnection::monitoringReporter() const {
110  if(!isOpen())
111  throw cond::Exception("DbConnection::monitoringReporter: cannot get connection service. Connection has not been open.");
112  return m_implementation->m_connectionPool->connectionService().monitoringReporter();
113 }
114 
115 coral::IWebCacheControl& cond::DbConnection::webCacheControl() const{
116  if(!isOpen())
117  throw cond::Exception("DbConnection::webCacheControl: cannot get connection service. Connection has not been open.");
118  return m_implementation->m_connectionPool->connectionService().webCacheControl();
119 }
120 
virtual ~DbConnection()
Definition: DbConnection.cc:46
DbConnectionConfiguration m_configuration
Definition: DbConnection.cc:33
const coral::IMonitoringReporter & monitoringReporter() const
bool isOpen() const
Definition: DbConnection.cc:84
DbConnectionConfiguration & configuration()
Definition: DbConnection.cc:89
coral::IWebCacheControl & webCacheControl() const
coral::IConnectionService & connectionService() const
boost::shared_ptr< ora::ConnectionPool > m_connectionPool
Definition: DbConnection.cc:32
DbConnection & operator=(const DbConnection &conn)
Definition: DbConnection.cc:49
boost::shared_ptr< ora::ConnectionPool > connectionPool() const
Definition: DbConnection.cc:99
DbSession createSession() const
Definition: DbConnection.cc:72
boost::shared_ptr< ConnectionImpl > m_implementation
Definition: DbConnection.h:69
static std::vector< DbConnectionConfiguration > & defaultConfigurations()
tuple conn
Definition: results_mgr.py:53