test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Public Attributes
cond::persistency::SessionImpl Class Reference

#include <SessionImpl.h>

Public Types

enum  FailureOnOpeningPolicy { THROW, DO_NOT_THROW, CREATE }
 

Public Member Functions

void close ()
 
void commitTransaction ()
 
IGTSchemagtSchema ()
 
IIOVSchemaiovSchema ()
 
bool isActive () const
 
bool isOra ()
 
bool isTransactionActive (bool deep=true) const
 
void openDb ()
 
void openGTDb (FailureOnOpeningPolicy policy=THROW)
 
void openIovDb (FailureOnOpeningPolicy policy=THROW)
 
void rollbackTransaction ()
 
 SessionImpl ()
 
 SessionImpl (boost::shared_ptr< coral::ISessionProxy > &session, const std::string &connectionString)
 
void startTransaction (bool readOnly=true)
 
 ~SessionImpl ()
 

Public Attributes

std::string connectionString
 
boost::shared_ptr
< coral::ISessionProxy > 
coralSession
 
std::unique_ptr< IGTSchemagtSchemaHandle
 
std::unique_ptr< IIOVSchemaiovSchemaHandle
 
std::unique_ptr< ITransactiontransaction
 

Detailed Description

Definition at line 38 of file SessionImpl.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

cond::persistency::SessionImpl::SessionImpl ( )

Definition at line 35 of file SessionImpl.cc.

35  :
36  coralSession(){
37  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:65
cond::persistency::SessionImpl::SessionImpl ( boost::shared_ptr< coral::ISessionProxy > &  session,
const std::string &  connectionString 
)

Definition at line 39 of file SessionImpl.cc.

40  :
42  connectionString( connectionStr ){
43  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:65
session
Definition: models.py:201
cond::persistency::SessionImpl::~SessionImpl ( )

Definition at line 45 of file SessionImpl.cc.

References close().

45  {
46  close();
47  }

Member Function Documentation

void cond::persistency::SessionImpl::close ( void  )

Definition at line 49 of file SessionImpl.cc.

References coralSession, and transaction.

Referenced by lumiQTWidget.ApplicationWindow::fileQuit(), esMonitoring.AsyncLineReaderMixin::handle_close(), esMonitoring.FDJsonServer::handle_close(), Vispa.Gui.BoxContentDialog.BoxContentDialog::keyPressEvent(), Vispa.Gui.FindDialog.FindDialog::keyPressEvent(), and ~SessionImpl().

49  {
50  if( coralSession.get() ){
51  if( coralSession->transaction().isActive() ){
52  coralSession->transaction().rollback();
53  }
54  coralSession.reset();
55  }
56  transaction.reset();
57  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:65
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
void cond::persistency::SessionImpl::commitTransaction ( )

Definition at line 76 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, and transaction.

Referenced by cond::persistency::Transaction::commit().

76  {
77  if( transaction ) {
78  transaction->clients--;
79  if( !transaction->clients ){
80  transaction->commit();
81  transaction.reset();
82  iovSchemaHandle.reset();
83  gtSchemaHandle.reset();
84  }
85  }
86  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:69
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
IGTSchema & cond::persistency::SessionImpl::gtSchema ( )

Definition at line 159 of file SessionImpl.cc.

References gtSchemaHandle.

159  {
160  return *gtSchemaHandle;
161  }
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:70
IIOVSchema & cond::persistency::SessionImpl::iovSchema ( )

Definition at line 155 of file SessionImpl.cc.

References iovSchemaHandle.

155  {
156  return *iovSchemaHandle;
157  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:69
bool cond::persistency::SessionImpl::isActive ( ) const

Definition at line 59 of file SessionImpl.cc.

References coralSession.

59  {
60  return coralSession.get();
61  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:65
bool cond::persistency::SessionImpl::isOra ( )

Definition at line 163 of file SessionImpl.cc.

References cond::persistency::throwException(), and transaction.

163  {
164  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::open" );
165  return transaction->isOra;
166  }
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
bool cond::persistency::SessionImpl::isTransactionActive ( bool  deep = true) const

Definition at line 97 of file SessionImpl.cc.

References transaction.

Referenced by cond::persistency::Transaction::isActive().

97  {
98  if( !transaction ) return false;
99  if( !deep ) return true;
100  return transaction->isActive();
101  }
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
void cond::persistency::SessionImpl::openDb ( )

Definition at line 135 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, cond::persistency::throwException(), and transaction.

135  {
136  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openIovDb" );
137  if( !transaction->iovDbOpen ){
138  transaction->iovDbExists = iovSchemaHandle->exists();
139  transaction->iovDbOpen = true;
140  }
141  if( !transaction->gtDbOpen ){
142  transaction->gtDbExists = gtSchemaHandle->exists();
143  transaction->gtDbOpen = true;
144  }
145  if( !transaction->iovDbExists ){
146  iovSchemaHandle->create();
147  transaction->iovDbExists = true;
148  if( !transaction->gtDbExists ){
149  gtSchemaHandle->create();
150  transaction->gtDbExists = true;
151  }
152  }
153  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:69
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void cond::persistency::SessionImpl::openGTDb ( SessionImpl::FailureOnOpeningPolicy  policy = THROW)

Definition at line 119 of file SessionImpl.cc.

References CREATE, gtSchemaHandle, THROW, cond::persistency::throwException(), and transaction.

119  {
120  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::open" );
121  if( !transaction->gtDbOpen ){
122  transaction->gtDbExists = gtSchemaHandle->exists();
123  transaction->gtDbOpen = true;
124  }
125  if( !transaction->gtDbExists ){
126  if( policy==CREATE ){
127  gtSchemaHandle->create();
128  transaction->gtDbExists = true;
129  } else {
130  if( policy==THROW) throwException( "GT Database does not exist.","SessionImpl::openGTDb");
131  }
132  }
133  }
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void cond::persistency::SessionImpl::openIovDb ( SessionImpl::FailureOnOpeningPolicy  policy = THROW)

Definition at line 103 of file SessionImpl.cc.

References CREATE, iovSchemaHandle, THROW, cond::persistency::throwException(), and transaction.

103  {
104  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openIovDb" );
105  if( !transaction->iovDbOpen ){
106  transaction->iovDbExists = iovSchemaHandle->exists();
107  transaction->iovDbOpen = true;
108  }
109  if( !transaction->iovDbExists ){
110  if( policy==CREATE ){
111  iovSchemaHandle->create();
112  transaction->iovDbExists = true;
113  } else {
114  if( policy==THROW) throwException( "IOV Database does not exist.","SessionImpl::openIovDb");
115  }
116  }
117  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:69
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void cond::persistency::SessionImpl::rollbackTransaction ( )

Definition at line 88 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, and transaction.

Referenced by cond::persistency::Transaction::rollback().

88  {
89  if( transaction ) {
90  transaction->rollback();
91  transaction.reset();
92  iovSchemaHandle.reset();
93  gtSchemaHandle.reset();
94  }
95  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:69
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
void cond::persistency::SessionImpl::startTransaction ( bool  readOnly = true)

Definition at line 63 of file SessionImpl.cc.

References coralSession, gtSchemaHandle, iovSchemaHandle, cond::persistency::throwException(), and transaction.

Referenced by cond::persistency::Transaction::start().

63  {
64  if( !transaction.get() ){
65  coralSession->transaction().start( readOnly );
66  iovSchemaHandle.reset( new IOVSchema( coralSession->nominalSchema() ) );
67  gtSchemaHandle.reset( new GTSchema( coralSession->nominalSchema() ) );
68  transaction.reset( new CondDBTransaction( coralSession ) );
69  } else {
70  if(!readOnly ) throwException( "An update transaction is already active.",
71  "SessionImpl::startTransaction" );
72  }
73  transaction->clients++;
74  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:69
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:65
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:68
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14

Member Data Documentation

std::string cond::persistency::SessionImpl::connectionString

Definition at line 67 of file SessionImpl.h.

boost::shared_ptr<coral::ISessionProxy> cond::persistency::SessionImpl::coralSession

Definition at line 65 of file SessionImpl.h.

Referenced by close(), isActive(), and startTransaction().

std::unique_ptr<IGTSchema> cond::persistency::SessionImpl::gtSchemaHandle
std::unique_ptr<IIOVSchema> cond::persistency::SessionImpl::iovSchemaHandle
std::unique_ptr<ITransaction> cond::persistency::SessionImpl::transaction