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 86 of file SessionImpl.cc.

86  :
87  coralSession(),
89  }
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 91 of file SessionImpl.cc.

93  :
95  connectionString( connectionStr ),
96  theBackendType( backType ){
97  }
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:70
cond::persistency::SessionImpl::~SessionImpl ( )

Definition at line 99 of file SessionImpl.cc.

References close().

99  {
100  close();
101  }

Member Function Documentation

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

Definition at line 103 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().

103  {
104  if( coralSession.get() ){
105  if( coralSession->transaction().isActive() ){
106  coralSession->transaction().rollback();
107  }
108  coralSession.reset();
109  }
110  transaction.reset();
111  }
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 141 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, and transaction.

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

141  {
142  if( transaction ) {
143  transaction->clients--;
144  if( !transaction->clients ){
145  transaction->commit();
146  transaction.reset();
147  iovSchemaHandle.reset();
148  gtSchemaHandle.reset();
149  }
150  }
151  }
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 199 of file SessionImpl.cc.

References gtSchemaHandle.

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

Definition at line 195 of file SessionImpl.cc.

References iovSchemaHandle.

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

Definition at line 113 of file SessionImpl.cc.

References coralSession.

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

Definition at line 203 of file SessionImpl.cc.

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

203  {
204  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::open" );
205  return transaction->isOra;
206  }
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 162 of file SessionImpl.cc.

References transaction.

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

162  {
163  if( !transaction ) return false;
164  if( !deep ) return true;
165  return transaction->isActive();
166  }
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74
void cond::persistency::SessionImpl::openGTDb ( )

Definition at line 184 of file SessionImpl.cc.

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

184  {
185  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::open" );
186  if( !transaction->gtDbOpen ){
187  transaction->gtDbExists = gtSchemaHandle->exists();
188  transaction->gtDbOpen = true;
189  }
190  if( !transaction->gtDbExists ){
191  throwException( "GT Database does not exist.","SessionImpl::openGTDb");
192  }
193  }
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 168 of file SessionImpl.cc.

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

168  {
169  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openIovDb" );
170  if( !transaction->iovDbOpen ){
171  transaction->iovDbExists = iovSchemaHandle->exists();
172  transaction->iovDbOpen = true;
173  }
174  if( !transaction->iovDbExists ){
175  if( policy==CREATE ){
176  iovSchemaHandle->create();
177  transaction->iovDbExists = true;
178  } else {
179  if( policy==THROW) throwException( "IOV Database does not exist.","SessionImpl::openIovDb");
180  }
181  }
182  }
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 153 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, and transaction.

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

153  {
154  if( transaction ) {
155  transaction->rollback();
156  transaction.reset();
157  iovSchemaHandle.reset();
158  gtSchemaHandle.reset();
159  }
160  }
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 117 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().

117  {
118  if( !transaction.get() ){
119  if ( theBackendType == ORA_DB ) {
120  cond::DbSession oraSession;
121  oraSession.open( coralSession, connectionString );
122  oraSession.transaction().start( readOnly );
123  iovSchemaHandle.reset( new OraIOVSchema( oraSession ) );
124  gtSchemaHandle.reset( new OraGTSchema( oraSession ) );
125  transaction.reset( new OraTransaction( oraSession ) );
126  } else if ( theBackendType == COND_DB ){
127  coralSession->transaction().start( readOnly );
128  iovSchemaHandle.reset( new IOVSchema( coralSession->nominalSchema() ) );
129  gtSchemaHandle.reset( new GTSchema( coralSession->nominalSchema() ) );
130  transaction.reset( new CondDBTransaction( coralSession ) );
131  } else {
132  throwException( "No valid database found.", "SessionImpl::startTransaction" );
133  }
134  } else {
135  if(!readOnly ) throwException( "An update transaction is already active.",
136  "SessionImpl::startTransaction" );
137  }
138  transaction->clients++;
139  }
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