DbiCascader::Lock Class Reference

List of all members.

Public Member Functions

 Lock (DbiStatement *stmtDB, const string &seqnoTable, const string &dataTable)
 ~Lock ()
Bool_t IsLocked () const

Private Member Functions

void SetLock (Bool_t setting=kTRUE)

Private Attributes

DbiStatementfStmt
string fSeqnoTableName
string fDataTableName
Bool_t fLocked

Detailed Description

Definition at line 133 of file DbiCascader.h.


Constructor & Destructor Documentation

DbiCascader::Lock::Lock ( DbiStatement stmtDB,
const string &  seqnoTable,
const string &  dataTable 
)

Definition at line 546 of file DbiCascader.cxx.

References fStmt, Msg::kError, LEA_CTOR_NM, MAXMSG, and SetLock().

00546                                                                                              :
00547 fStmt(stmtDB),
00548 fSeqnoTableName(seqnoTable),
00549 fDataTableName(dataTable),
00550 fLocked(kFALSE)
00551 {
00552 //
00553 //
00554 //  Purpose:  Ctor: Create a lock on a table accessed via connection.
00555 //            (will be released by dtor)
00556 //  Arguments: 
00557 //          stmtDB    in  DbiStatement (given to Lock).
00558   
00559   LEA_CTOR_NM("DbiCascader::Lock",this);
00560 
00561   if ( ! fStmt ) {
00562     MAXMSG("Dbi",Msg::kError,20) << "Cannot obtain statment to set lock" << endl;
00563     return;
00564   }
00565 
00566   this->SetLock(kTRUE);
00567 
00568 }
//.....................................................................

DbiCascader::Lock::~Lock (  ) 

Definition at line 571 of file DbiCascader.cxx.

References fStmt, LEA_DTOR_NM, and SetLock().

00571                        {
00572 //
00573 //
00574 //  Purpose:  Dtor: Clear lock
00575 
00576   LEA_DTOR_NM("DbiCascader::Lock",this);
00577 
00578   this->SetLock(kFALSE);
00579   delete fStmt;
00580   fStmt = 0; 
00581 
00582 }


Member Function Documentation

Bool_t DbiCascader::Lock::IsLocked (  )  const [inline]

Definition at line 139 of file DbiCascader.h.

References fLocked.

Referenced by DbiCascader::ReserveNextSeqNo().

00139 { return fLocked; }

void DbiCascader::Lock::SetLock ( Bool_t  setting = kTRUE  )  [private]

Definition at line 586 of file DbiCascader.cxx.

References DbiStatement::ExecuteUpdate(), fDataTableName, fLocked, fSeqnoTableName, fStmt, DbiStatement::GetDBType(), DbiStatement::GetExceptionLog(), DbiExceptionLog::IsEmpty(), Dbi::kMySQL, Msg::kSynopsis, MSG, and DbiStatement::PrintExceptions().

Referenced by Lock(), and ~Lock().

00586                                              {
00587 
00588 //
00589 //
00590 //  Purpose:  Set or clear lock.
00591 //
00592 //  Arguments: 
00593 //    setting      in    Required setting of lock. [default kTRUE]
00594 
00595 //  Program Notes:-
00596 //  =============
00597 
00598 //  No-op unless connect to MySQL DB, in which case it uses the LOCK TABLES command.
00599 
00600   if ( setting == fLocked || ! fStmt ) return;
00601 
00602   if ( fStmt->GetDBType() != Dbi::kMySQL ) { 
00603     fLocked = setting;
00604     return;
00605   }
00606 
00607   string sql;
00608 
00609   if ( setting ) {
00610     sql = "LOCK TABLES ";
00611     sql += fSeqnoTableName + " WRITE";
00612     if ( fDataTableName != "" ) sql += ", " + fDataTableName  + "VLD WRITE";
00613   }
00614   else {
00615     sql = "UNLOCK TABLES;";
00616   }
00617   MSG("Dbi",Msg::kSynopsis) << "Lock requested: " << setting 
00618                          << " issuing lock command: " << sql << endl;
00619   fStmt->ExecuteUpdate(sql.c_str());
00620   if ( fStmt->GetExceptionLog().IsEmpty() ) fLocked = setting;
00621   fStmt->PrintExceptions();
00622 
00623 }


Member Data Documentation

Definition at line 147 of file DbiCascader.h.

Referenced by SetLock().

Bool_t DbiCascader::Lock::fLocked [private]

Definition at line 148 of file DbiCascader.h.

Referenced by IsLocked(), and SetLock().

Definition at line 146 of file DbiCascader.h.

Referenced by SetLock().

Definition at line 145 of file DbiCascader.h.

Referenced by Lock(), SetLock(), and ~Lock().


The documentation for this class was generated from the following files:

Generated on 24 Jul 2018 for loon by  doxygen 1.6.1