CMS 3D CMS Logo

SessionImpl.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_SessionImpl_h
2 #define CondCore_CondDB_SessionImpl_h
3 
5 #include "IOVSchema.h"
6 #include "GTSchema.h"
7 #include "RunInfoSchema.h"
8 //
9 #include "RelationalAccess/ConnectionService.h"
10 #include "RelationalAccess/ISessionProxy.h"
11 //
12 #include <memory>
13 #include <mutex>
14 // temporarely
15 
16 namespace coral {
17  class ISessionProxy;
18  class ISchema;
19 } // namespace coral
20 
21 namespace cond {
22 
23  namespace persistency {
24 
25  class ITransaction {
26  public:
27  virtual ~ITransaction() {}
28  virtual void commit() = 0;
29  virtual void rollback() = 0;
30  virtual bool isActive() = 0;
31  bool iovDbExists = false;
32  bool iovDbOpen = false;
33  bool gtDbExists = false;
34  bool gtDbOpen = false;
35  bool runInfoDbExists = false;
36  bool runInfoDbOpen = true;
37  size_t clients = 0;
38  };
39 
40  class SessionImpl {
41  public:
43 
44  public:
45  SessionImpl();
46  SessionImpl(std::shared_ptr<coral::ISessionProxy>& session, const std::string& connectionString);
47 
48  ~SessionImpl();
49 
50  void close();
51  bool isActive() const;
52  void startTransaction(bool readOnly = true);
53  void commitTransaction();
54  void rollbackTransaction();
55  bool isTransactionActive(bool deep = true) const;
56 
57  void openIovDb(FailureOnOpeningPolicy policy = THROW);
58  void openGTDb(FailureOnOpeningPolicy policy = THROW);
59  void openRunInfoDb();
60  void openDb();
64 
65  public:
66  // allows for session shared among more services. To be changed to unique_ptr when we stop needing this feature.
67  std::shared_ptr<coral::ISessionProxy> coralSession;
68  // not really useful outside the ORA bridging...
70  std::unique_ptr<ITransaction> transaction;
71  std::unique_ptr<IIOVSchema> iovSchemaHandle;
72  std::unique_ptr<IGTSchema> gtSchemaHandle;
73  std::unique_ptr<IRunInfoSchema> runInfoSchemaHandle;
74 
75  private:
76  std::recursive_mutex transactionMutex;
77  std::unique_lock<std::recursive_mutex> transactionLock;
78  };
79 
80  } // namespace persistency
81 
82 } // namespace cond
83 
84 #endif
cond::persistency::ITransaction::runInfoDbExists
bool runInfoDbExists
Definition: SessionImpl.h:35
cond::persistency::SessionImpl::openGTDb
void openGTDb(FailureOnOpeningPolicy policy=THROW)
Definition: SessionImpl.cc:116
cond::persistency::SessionImpl::isActive
bool isActive() const
Definition: SessionImpl.cc:45
cond::persistency::ITransaction::runInfoDbOpen
bool runInfoDbOpen
Definition: SessionImpl.h:36
IOVSchema.h
cond::persistency::SessionImpl::connectionString
std::string connectionString
Definition: SessionImpl.h:69
cond::persistency::SessionImpl::transactionLock
std::unique_lock< std::recursive_mutex > transactionLock
Definition: SessionImpl.h:77
cond::persistency::IGTSchema
Definition: IDbSchema.h:207
cond::persistency::SessionImpl::close
void close()
Definition: SessionImpl.cc:35
cond::persistency::IIOVSchema
Definition: IDbSchema.h:155
cond::persistency::ITransaction::iovDbExists
bool iovDbExists
Definition: SessionImpl.h:31
cond::persistency::ITransaction::rollback
virtual void rollback()=0
cond::persistency::SessionImpl::rollbackTransaction
void rollbackTransaction()
Definition: SessionImpl.cc:78
cond::persistency::SessionImpl::~SessionImpl
~SessionImpl()
Definition: SessionImpl.cc:33
cond::persistency::ITransaction::isActive
virtual bool isActive()=0
cond::persistency::SessionImpl::openRunInfoDb
void openRunInfoDb()
Definition: SessionImpl.cc:134
cond::persistency::SessionImpl
Definition: SessionImpl.h:40
coral
Definition: Binary.h:9
cond::persistency::IRunInfoSchema
Definition: IDbSchema.h:239
cond::persistency::SessionImpl::openDb
void openDb()
Definition: SessionImpl.cc:146
cond::persistency::ITransaction::~ITransaction
virtual ~ITransaction()
Definition: SessionImpl.h:27
cond::persistency::SessionImpl::DO_NOT_THROW
Definition: SessionImpl.h:42
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
cond::persistency::SessionImpl::iovSchema
IIOVSchema & iovSchema()
Definition: SessionImpl.cc:167
cond::persistency::ITransaction
Definition: SessionImpl.h:25
cond::persistency::SessionImpl::startTransaction
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:47
RunInfoSchema.h
cond::persistency::ITransaction::iovDbOpen
bool iovDbOpen
Definition: SessionImpl.h:32
cond::persistency::SessionImpl::iovSchemaHandle
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:71
cond::persistency::ITransaction::commit
virtual void commit()=0
cond::persistency::ITransaction::gtDbOpen
bool gtDbOpen
Definition: SessionImpl.h:34
cond::persistency::SessionImpl::SessionImpl
SessionImpl()
Definition: SessionImpl.cc:28
cond::persistency::SessionImpl::runInfoSchemaHandle
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:73
cond::persistency::SessionImpl::isTransactionActive
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:90
cond::persistency::SessionImpl::gtSchema
IGTSchema & gtSchema()
Definition: SessionImpl.cc:169
cond::persistency::SessionImpl::runInfoSchema
IRunInfoSchema & runInfoSchema()
Definition: SessionImpl.cc:171
cond::persistency::SessionImpl::transactionMutex
std::recursive_mutex transactionMutex
Definition: SessionImpl.h:76
cond::persistency::ITransaction::clients
size_t clients
Definition: SessionImpl.h:37
cond::persistency::SessionImpl::coralSession
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:67
cond::persistency::SessionImpl::gtSchemaHandle
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:72
cond::persistency::SessionImpl::CREATE
Definition: SessionImpl.h:42
cond::persistency::SessionImpl::THROW
Definition: SessionImpl.h:42
Types.h
cond::persistency::SessionImpl::openIovDb
void openIovDb(FailureOnOpeningPolicy policy=THROW)
Definition: SessionImpl.cc:98
cond::persistency::SessionImpl::commitTransaction
void commitTransaction()
Definition: SessionImpl.cc:63
cond::persistency::SessionImpl::FailureOnOpeningPolicy
FailureOnOpeningPolicy
Definition: SessionImpl.h:42
GTSchema.h
cond::persistency::ITransaction::gtDbExists
bool gtDbExists
Definition: SessionImpl.h:33
cond::persistency::SessionImpl::transaction
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:70