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 openGTDb ()
 
void openIovDb (FailureOnOpeningPolicy policy=THROW)
 
void rollbackTransaction ()
 
 SessionImpl ()
 
 SessionImpl (boost::shared_ptr< coral::ISessionProxy > &session, const std::string &connectionString, BackendType backType)
 
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
 
BackendType theBackendType
 
std::unique_ptr< ITransactiontransaction
 

Detailed Description

Definition at line 43 of file SessionImpl.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 80 of file SessionImpl.cc.

80  :
81  coralSession(),
83  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:70
cond::persistency::SessionImpl::SessionImpl ( boost::shared_ptr< coral::ISessionProxy > &  session,
const std::string &  connectionString,
BackendType  backType 
)

Definition at line 85 of file SessionImpl.cc.

87  :
89  connectionString( connectionStr ),
90  theBackendType( backType ){
91  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:70
cond::persistency::SessionImpl::~SessionImpl ( )

Definition at line 93 of file SessionImpl.cc.

References close().

93  {
94  close();
95  }

Member Function Documentation

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

Definition at line 97 of file SessionImpl.cc.

References coralSession, and transaction.

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

97  {
98  if( coralSession.get() ){
99  if( coralSession->transaction().isActive() ){
100  coralSession->transaction().rollback();
101  }
102  coralSession.reset();
103  }
104  transaction.reset();
105  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:70
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
void cond::persistency::SessionImpl::commitTransaction ( )

Definition at line 135 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, and transaction.

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

135  {
136  if( transaction ) {
137  transaction->clients--;
138  if( !transaction->clients ){
139  transaction->commit();
140  transaction.reset();
141  iovSchemaHandle.reset();
142  gtSchemaHandle.reset();
143  }
144  }
145  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:75
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:76
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
IGTSchema & cond::persistency::SessionImpl::gtSchema ( )

Definition at line 193 of file SessionImpl.cc.

References gtSchemaHandle.

193  {
194  return *gtSchemaHandle;
195  }
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:76
IIOVSchema & cond::persistency::SessionImpl::iovSchema ( )

Definition at line 189 of file SessionImpl.cc.

References iovSchemaHandle.

189  {
190  return *iovSchemaHandle;
191  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:75
bool cond::persistency::SessionImpl::isActive ( ) const

Definition at line 107 of file SessionImpl.cc.

References coralSession.

107  {
108  return coralSession.get();
109  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:70
bool cond::persistency::SessionImpl::isOra ( )

Definition at line 197 of file SessionImpl.cc.

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

197  {
198  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::open" );
199  return transaction->isOra;
200  }
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
bool cond::persistency::SessionImpl::isTransactionActive ( bool  deep = true) const

Definition at line 156 of file SessionImpl.cc.

References transaction.

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

156  {
157  if( !transaction ) return false;
158  if( !deep ) return true;
159  return transaction->isActive();
160  }
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
void cond::persistency::SessionImpl::openGTDb ( )

Definition at line 178 of file SessionImpl.cc.

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

178  {
179  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::open" );
180  if( !transaction->gtDbOpen ){
181  transaction->gtDbExists = gtSchemaHandle->exists();
182  transaction->gtDbOpen = true;
183  }
184  if( !transaction->gtDbExists ){
185  throwException( "GT Database does not exist.","SessionImpl::openGTDb");
186  }
187  }
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:76
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
void cond::persistency::SessionImpl::openIovDb ( SessionImpl::FailureOnOpeningPolicy  policy = THROW)

Definition at line 162 of file SessionImpl.cc.

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

162  {
163  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openIovDb" );
164  if( !transaction->iovDbOpen ){
165  transaction->iovDbExists = iovSchemaHandle->exists();
166  transaction->iovDbOpen = true;
167  }
168  if( !transaction->iovDbExists ){
169  if( policy==CREATE ){
170  iovSchemaHandle->create();
171  transaction->iovDbExists = true;
172  } else {
173  if( policy==THROW) throwException( "IOV Database does not exist.","SessionImpl::openIovDb");
174  }
175  }
176  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:75
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
void cond::persistency::SessionImpl::rollbackTransaction ( )

Definition at line 147 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, and transaction.

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

147  {
148  if( transaction ) {
149  transaction->rollback();
150  transaction.reset();
151  iovSchemaHandle.reset();
152  gtSchemaHandle.reset();
153  }
154  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:75
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:76
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
void cond::persistency::SessionImpl::startTransaction ( bool  readOnly = true)

Definition at line 111 of file SessionImpl.cc.

References cond::COND_DB, connectionString, coralSession, gtSchemaHandle, iovSchemaHandle, cond::DbSession::open(), cond::ORA_DB, cond::DbTransaction::start(), theBackendType, cond::persistency::throwException(), cond::DbSession::transaction(), and transaction.

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

111  {
112  if( !transaction.get() ){
113  if ( theBackendType == ORA_DB ) {
114  cond::DbSession oraSession;
115  oraSession.open( coralSession, connectionString );
116  oraSession.transaction().start( readOnly );
117  iovSchemaHandle.reset( new OraIOVSchema( oraSession ) );
118  gtSchemaHandle.reset( new OraGTSchema( oraSession ) );
119  transaction.reset( new OraTransaction( oraSession ) );
120  } else if ( theBackendType == COND_DB ){
121  coralSession->transaction().start( readOnly );
122  iovSchemaHandle.reset( new IOVSchema( coralSession->nominalSchema() ) );
123  gtSchemaHandle.reset( new GTSchema( coralSession->nominalSchema() ) );
124  transaction.reset( new CondDBTransaction( coralSession ) );
125  } else {
126  throwException( "No valid database found.", "SessionImpl::startTransaction" );
127  }
128  } else {
129  if(!readOnly ) throwException( "An update transaction is already active.",
130  "SessionImpl::startTransaction" );
131  }
132  transaction->clients++;
133  }
DbTransaction & transaction()
Definition: DbSession.cc:208
void open(const std::string &connectionString, bool readOnly=false)
Definition: DbSession.cc:159
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:75
int start(bool readOnly=false)
start transaction
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:70
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:76
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11

Member Data Documentation

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

Definition at line 72 of file SessionImpl.h.

Referenced by startTransaction().

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

Definition at line 70 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
BackendType cond::persistency::SessionImpl::theBackendType

Definition at line 73 of file SessionImpl.h.

Referenced by startTransaction().

std::unique_ptr<ITransaction> cond::persistency::SessionImpl::transaction