The transaction class. More...
#include <transaction.hpp>
Inherits oos::object_observer.
Public Types | |
typedef std::list< action * > | action_list_t |
typedef action_list_t::iterator | iterator |
typedef action_list_t::const_iterator | const_iterator |
Public Member Functions | |
transaction (session &db) | |
Create a transaction. More... | |
long | id () const |
void | begin () |
Start the transaction. More... | |
void | commit () |
Commit the started transaction. More... | |
void | rollback () |
Abort and rollback the started transaction. More... | |
session & | db () |
const session & | db () const |
virtual void | on_insert (object *o) |
Called on object insertion. More... | |
virtual void | on_update (object *o) |
Called on object update. More... | |
virtual void | on_delete (object *o) |
Called on object deletion. More... | |
Friends | |
class | object_store |
class | session |
Detailed Description
The transaction class.
This class provides transaction functionality for the object_store with a specific database. If the object_store uses a database backend this transaction class handles the commit and rollback behaviour of the database. On rollback it restores the stored data to the objects modified within the transaction.
Member Typedef Documentation
typedef std::list<action*> oos::transaction::action_list_t |
Shortcut for the action list class type.
typedef action_list_t::const_iterator oos::transaction::const_iterator |
Shortcut for the action list const iterator.
typedef action_list_t::iterator oos::transaction::iterator |
Shortcut for the action list iterator.
Constructor & Destructor Documentation
oos::transaction::transaction | ( | session & | db | ) |
Create a transaction.
A transaction for the given database is created. To begin the transaction start must be called.
- Parameters
-
db The underlaying database.
Member Function Documentation
void oos::transaction::begin | ( | ) |
Start the transaction.
Start the transaction. All object insertions, modifications and deletions are stored.
void oos::transaction::commit | ( | ) |
Commit the started transaction.
Commit the started transaction. All object insertions, modifications and deletions are written to the database.
session& oos::transaction::db | ( | ) |
Returns the underlaying pointer to the database.
- Returns
- The pointer to the database.
const session& oos::transaction::db | ( | ) | const |
Returns the underlaying pointer to the database.
- Returns
- The pointer to the database.
long oos::transaction::id | ( | ) | const |
Return the unique transaction id.
- Returns
- The transaction id.
|
virtual |
Called on object deletion.
Called when an object is deleted from the object_store.
- Parameters
-
o The deleted object.
Implements oos::object_observer.
|
virtual |
Called on object insertion.
Called when an object is inserted into the object_store.
- Parameters
-
o The inserted object.
Implements oos::object_observer.
|
virtual |
Called on object update.
Called when an object is updated in the object_store.
- Parameters
-
o The updated object.
Implements oos::object_observer.
void oos::transaction::rollback | ( | ) |
Abort and rollback the started transaction.
Abort and rollback the started transaction. All object insertions, modifications and deletions are rolled back in the object_store.
The documentation for this class was generated from the following file:
- database/transaction.hpp