#include <CdbTransaction.hh>
Inheritance diagram for CdbTransaction:

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. | |
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 ); ... }
Definition at line 55 of file CdbTransaction.hh.
|
|
Modes of transactions.
Definition at line 61 of file CdbTransaction.hh. |
|
|
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.
Definition at line 18 of file CdbTransaction.cc. References Cdb::instance(), and CdbCPtr< Cdb, CdbDoNotClosePolicy< Cdb > >::isNull(). |
|
||||||||||||
|
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.
Definition at line 46 of file CdbTransaction.cc. References CdbCPtr< Cdb, CdbDoNotClosePolicy< Cdb > >::isNull(). |
|
||||||||||||||||
|
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:
Definition at line 72 of file CdbTransaction.cc. References Cdb::instance(), and CdbCPtr< Cdb, CdbDoNotClosePolicy< Cdb > >::isNull(). |
|
|
The destructor. Return current transaction into the same state if was before instantiating an object of the class.
Definition at line 104 of file CdbTransaction.cc. |
|
|
Flush modifications made within the current transaction and keep going. Implements the corresponding method defined in a base class or an interface.
Implements CdbTransactionBase. Definition at line 111 of file CdbTransaction.cc. References CdbTransactionBase::commitAndHold(). Referenced by main(). |
1.3-rc3