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

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

Definition at line 86 of file SessionImpl.cc.

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

Definition at line 94 of file SessionImpl.cc.

References close().

94  {
95  close();
96  }

Member Function Documentation

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

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

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

Definition at line 136 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, and transaction.

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

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

Definition at line 219 of file SessionImpl.cc.

References gtSchemaHandle.

219  {
220  return *gtSchemaHandle;
221  }
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:77
IIOVSchema & cond::persistency::SessionImpl::iovSchema ( )

Definition at line 215 of file SessionImpl.cc.

References iovSchemaHandle.

215  {
216  return *iovSchemaHandle;
217  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:76
bool cond::persistency::SessionImpl::isActive ( ) const

Definition at line 108 of file SessionImpl.cc.

References coralSession.

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

Definition at line 223 of file SessionImpl.cc.

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

223  {
224  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::open" );
225  return transaction->isOra;
226  }
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:75
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 157 of file SessionImpl.cc.

References transaction.

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

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

Definition at line 195 of file SessionImpl.cc.

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

195  {
196  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openIovDb" );
197  if( !transaction->iovDbOpen ){
198  transaction->iovDbExists = iovSchemaHandle->exists();
199  transaction->iovDbOpen = true;
200  }
201  if( !transaction->gtDbOpen ){
202  transaction->gtDbExists = gtSchemaHandle->exists();
203  transaction->gtDbOpen = true;
204  }
205  if( !transaction->iovDbExists ){
206  iovSchemaHandle->create();
207  transaction->iovDbExists = true;
208  if( !transaction->gtDbExists ){
209  gtSchemaHandle->create();
210  transaction->gtDbExists = true;
211  }
212  }
213  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:76
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:77
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:75
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
void cond::persistency::SessionImpl::openGTDb ( SessionImpl::FailureOnOpeningPolicy  policy = THROW)

Definition at line 179 of file SessionImpl.cc.

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

179  {
180  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::open" );
181  if( !transaction->gtDbOpen ){
182  transaction->gtDbExists = gtSchemaHandle->exists();
183  transaction->gtDbOpen = true;
184  }
185  if( !transaction->gtDbExists ){
186  if( policy==CREATE ){
187  gtSchemaHandle->create();
188  transaction->gtDbExists = true;
189  } else {
190  if( policy==THROW) throwException( "GT Database does not exist.","SessionImpl::openGTDb");
191  }
192  }
193  }
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:77
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:75
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 163 of file SessionImpl.cc.

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

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

Definition at line 148 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, and transaction.

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

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

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

112  {
113  if( !transaction.get() ){
114  if ( theBackendType == ORA_DB ) {
115  cond::DbSession oraSession;
116  oraSession.open( coralSession, connectionString );
117  oraSession.transaction().start( readOnly );
118  iovSchemaHandle.reset( new OraIOVSchema( oraSession ) );
119  gtSchemaHandle.reset( new OraGTSchema( oraSession ) );
120  transaction.reset( new OraTransaction( oraSession ) );
121  } else if ( theBackendType == COND_DB ){
122  coralSession->transaction().start( readOnly );
123  iovSchemaHandle.reset( new IOVSchema( coralSession->nominalSchema() ) );
124  gtSchemaHandle.reset( new GTSchema( coralSession->nominalSchema() ) );
125  transaction.reset( new CondDBTransaction( coralSession ) );
126  } else {
127  throwException( "No valid database found.", "SessionImpl::startTransaction" );
128  }
129  } else {
130  if(!readOnly ) throwException( "An update transaction is already active.",
131  "SessionImpl::startTransaction" );
132  }
133  transaction->clients++;
134  }
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:76
int start(bool readOnly=false)
start transaction
boost::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:71
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:77
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:75
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 73 of file SessionImpl.h.

Referenced by startTransaction().

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

Definition at line 71 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 74 of file SessionImpl.h.

Referenced by startTransaction().

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