Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbTransaction Class Reference

The transaction management front-end. More...

#include <CdbTransaction.hh>

Inheritance diagram for CdbTransaction:

CdbTransactionBase List of all members.

Public Types

enum  Mode { Read, Update }
 Modes of transactions. More...


Public Member Functions

 CdbTransaction (CdbTransaction::Mode theMode=CdbTransaction::Read)
 The constructor.

 CdbTransaction (const CdbPtr &thePtr, CdbTransaction::Mode theMode=CdbTransaction::Read)
 The constructor.

 CdbTransaction (const char *theTechnologyName, const char *theImplementationName, CdbTransaction::Mode theMode=CdbTransaction::Read)
 The constructor.

 ~CdbTransaction ()
 The destructor.

void commitAndHold ()
 Flush modifications made within the current transaction and keep going.


Detailed Description

The transaction management front-end.

This is a technology neutral front-end class to technology specific implementations of the transaction management based on the "resource-acquisition-is-initialization" paradigm.

The transaction is started when a constructor of the class is invoked, and is commited when the destructor is executed. The desired transaction mode can be passed as an optional parameter of the class's constructor.

This paradigme lets us to implement the following code pattern:

// Begin a block of code (can be a function, a method, etc.)

{ CdbTransaction trans; // begin a transaction in default mode, // which is CdbTransaction::Read. ... }

// It's guaranteed that the transaction is always returned into the same // state it was before entering the block when the execution leaves // the block, no matter what happens to the control flow.

The main benefit of this approach is that a user should not warry about explicit matching each "start transaction" with the corresponding "end transaction", which in some cases may introduce an extra "noise" into the logic of the code. So the only extra action to be made is to provide a block and to declare a variable of this class in an appropriate place of the block (usually at its very beginninig).

Here is another example, requering the names of specific CDB API "technology" and "implementation" be specified:

// Begin a block of code (can be a function, a method, etc.)

{ CdbTransaction trans( "SomeTechnology", "SomeImplementation", CdbTransaction::Update ); ... }

See also:
class CdbTransactionBase

Definition at line 55 of file CdbTransaction.hh.


Member Enumeration Documentation

enum CdbTransaction::Mode
 

Modes of transactions.

Enumeration values:
Read 
Update 

Definition at line 61 of file CdbTransaction.hh.


Constructor & Destructor Documentation

CdbTransaction::CdbTransaction CdbTransaction::Mode    theMode = CdbTransaction::Read [explicit]
 

The constructor.

Make sure that there is a transaction started in the specified mode.

The operation is performed in a scope of the default CDB API implementation fetched through the top-level CDB API class: Cdb.If the default implementation won't be found then the crash in the constructor will take place.

See also:
CdbTransactionBase::CdbTransactionBase()

class Cdb

Definition at line 18 of file CdbTransaction.cc.

References Cdb::instance(), and CdbCPtr< Cdb, CdbDoNotClosePolicy< Cdb > >::isNull().

CdbTransaction::CdbTransaction const CdbPtr   thePtr,
CdbTransaction::Mode    theMode = CdbTransaction::Read
[explicit]
 

The constructor.

Make sure that there is a transaction started in the specified mode.

The operation is performed in a scope of an explicitly specified CDB API implementation. A non-zero pointer is expected. If not then the crash in the constructor will take place.

See also:
CdbTransactionBase::CdbTransactionBase()

class Cdb

Definition at line 46 of file CdbTransaction.cc.

References CdbCPtr< Cdb, CdbDoNotClosePolicy< Cdb > >::isNull().

CdbTransaction::CdbTransaction const char *    theTechnologyName,
const char *    theImplementationName,
CdbTransaction::Mode    theMode = CdbTransaction::Read
 

The constructor.

Make sure that there is a transaction started in the specified mode.

The operation is performed in a scope of an explicitly specified CDB API implementation. If the desired implementation won't be found then the crash in the constructor will take place.

NOTE ON PARAMETERS:

  • zero (0) pointer(s) passed where the "technology" and/or "implementation" names are expected would imply the default value(s) of the parameter(s).

See also:
CdbTransactionBase::CdbTransactionBase()

class Cdb

Definition at line 72 of file CdbTransaction.cc.

References Cdb::instance(), and CdbCPtr< Cdb, CdbDoNotClosePolicy< Cdb > >::isNull().

CdbTransaction::~CdbTransaction  
 

The destructor.

Return current transaction into the same state if was before instantiating an object of the class.

See also:
CdbTransactionBase::~CdbTransactionBase()

Definition at line 104 of file CdbTransaction.cc.


Member Function Documentation

void CdbTransaction::commitAndHold   [virtual]
 

Flush modifications made within the current transaction and keep going.

Implements the corresponding method defined in a base class or an interface.

See also:
CdbTransactionBase::commitAndHold()

Implements CdbTransactionBase.

Definition at line 111 of file CdbTransaction.cc.

References CdbTransactionBase::commitAndHold().

Referenced by main().


The documentation for this class was generated from the following files:
Generated on Mon Dec 5 18:22:27 2005 for CDB by doxygen1.3-rc3