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:
42  typedef enum { THROW, DO_NOT_THROW, CREATE } FailureOnOpeningPolicy;
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();
61  IIOVSchema& iovSchema();
62  IGTSchema& gtSchema();
63  IRunInfoSchema& runInfoSchema();
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
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:67
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:71
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:73
std::recursive_mutex transactionMutex
Definition: SessionImpl.h:76
std::unique_lock< std::recursive_mutex > transactionLock
Definition: SessionImpl.h:77
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:72
Definition: Binary.h:9
Definition: plugin.cc:23
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:70