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 // temporarely
14 
15 namespace coral {
16  class ISessionProxy;
17  class ISchema;
18 }
19 
20 namespace cond {
21 
22  namespace persistency {
23 
24  class ITransaction {
25  public:
26  virtual ~ITransaction(){}
27  virtual void commit() = 0;
28  virtual void rollback() = 0;
29  virtual bool isActive() = 0;
30  bool iovDbExists = false;
31  bool iovDbOpen = false;
32  bool gtDbExists = false;
33  bool gtDbOpen = false;
34  bool runInfoDbExists = false;
35  bool runInfoDbOpen = true;
36  size_t clients = 0;
37  };
38 
39  class SessionImpl {
40  public:
41  typedef enum { THROW, DO_NOT_THROW, CREATE } FailureOnOpeningPolicy;
42  public:
43  SessionImpl();
44  SessionImpl( std::shared_ptr<coral::ISessionProxy>& session,
45  const std::string& connectionString );
46 
47  ~SessionImpl();
48 
49  void close();
50  bool isActive() const;
51  void startTransaction( bool readOnly=true );
52  void commitTransaction();
53  void rollbackTransaction();
54  bool isTransactionActive( bool deep=true ) const;
55 
56  void openIovDb( FailureOnOpeningPolicy policy = THROW );
57  void openGTDb( FailureOnOpeningPolicy policy = THROW );
58  void openRunInfoDb();
59  void openDb();
60  IIOVSchema& iovSchema();
61  IGTSchema& gtSchema();
62  IRunInfoSchema& runInfoSchema();
63 
64  public:
65  // allows for session shared among more services. To be changed to unique_ptr when we stop needing this feature.
66  std::shared_ptr<coral::ISessionProxy> coralSession;
67  // not really useful outside the ORA bridging...
69  std::unique_ptr<ITransaction> transaction;
70  std::unique_ptr<IIOVSchema> iovSchemaHandle;
71  std::unique_ptr<IGTSchema> gtSchemaHandle;
72  std::unique_ptr<IRunInfoSchema> runInfoSchemaHandle;
73  };
74 
75  }
76 
77 }
78 
79 #endif
80 
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:66
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:72
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:71
Definition: Binary.h:9
Definition: plugin.cc:24
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69