This class provides the transaction mechanism. More...
#include <transaction.hpp>
Classes | |
struct | observer |
Interface to an transaction observer. More... | |
Public Types | |
typedef std::shared_ptr< action > | action_ptr |
typedef std::vector< action_ptr > | t_action_vector |
Public Member Functions | |
transaction (object_store &store) | |
Creates a transaction for the given object_store. | |
transaction (object_store &store, const std::shared_ptr< observer > &obsvr) | |
Creates a transaction for the given object_store and observer. | |
transaction (const transaction &) | |
Copy construct a transaction. | |
transaction & | operator= (const transaction &)=delete |
transaction (transaction &&x)=default | |
Default copy move contructor for a transaction. | |
transaction & | operator= (transaction &&x)=default |
Default assignment move contructor for a transaction. | |
unsigned long long | id () const |
Returns the unique id of the transaction. | |
void | begin () |
Start a new transaction. | |
void | commit () |
Finish transaction. | |
void | rollback () |
Rollback transaction. | |
void | on_insert (object_proxy *proxy) |
void | on_update (object_proxy *proxy) |
void | on_delete (object_proxy *proxy) |
Friends | |
bool | operator== (const transaction &a, const transaction &b) |
Equal operator for two transaction objects. | |
bool | operator!= (const transaction &a, const transaction &b) |
Unequal operator for two transaction objects. | |
This class provides the transaction mechanism.
This class provides the transaction mechanism. It can be used if a couple of actions (insert, update, delete) should be made at once.
If one action fails all finished action we be rolled back. If all actions could be finished one can commit the changes.
Therefor the interface of this class provides the main methods
Transaction can be nested as well.
typedef std::shared_ptr<action> matador::transaction::action_ptr |
Shortcut to an action shared pointer
typedef std::vector<action_ptr> matador::transaction::t_action_vector |
Shortcut to a vector of action shared pointer
|
explicit |
Creates a transaction for the given object_store.
store | The object_store the transaction is created for |
matador::transaction::transaction | ( | object_store & | store, |
const std::shared_ptr< observer > & | obsvr | ||
) |
Creates a transaction for the given object_store and observer.
store | The object_store the transaction is created for |
obsvr | The observer to be used for the transaction events |
matador::transaction::transaction | ( | const transaction & | x | ) |
Copy construct a transaction.
x | The transaction to be copied from |
|
default |
Default copy move contructor for a transaction.
x | The transaction to be moved |
void matador::transaction::commit | ( | ) |
Finish transaction.
Finish transaction and commit all changes
unsigned long long matador::transaction::id | ( | ) | const |
Returns the unique id of the transaction.
void matador::transaction::on_delete | ( | object_proxy * | proxy | ) |
Called when deletion took place.
T | The type of the deleted object |
void matador::transaction::on_insert | ( | object_proxy * | proxy | ) |
Called when insertion took place.
T | The type of the inserted object |
void matador::transaction::on_update | ( | object_proxy * | proxy | ) |
Called when update took place.
T | The type of the updated object |
|
default |
Default assignment move contructor for a transaction.
x | The transaction to be moved |
void matador::transaction::rollback | ( | ) |
Rollback transaction.
Rollback transaction and revert all changes
|
friend |
Unequal operator for two transaction objects.
Every transaction has a unique id. This id is used for the comparation.
a | The left hand transaction to be compared |
b | The right hand transaction to be compared |
|
friend |
Equal operator for two transaction objects.
Every transaction has a unique id. This id is used for the comparation.
a | The left hand transaction to be compared |
b | The right hand transaction to be compared |