matador::transaction Class Reference

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_ptrt_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.
 
transactionoperator= (const transaction &)=delete
 
 transaction (transaction &&x)=default
 Default copy move contructor for a transaction.
 
transactionoperator= (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.
 

Detailed Description

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

  • begin
  • commit
  • rollback

Transaction can be nested as well.

Member Typedef Documentation

◆ action_ptr

typedef std::shared_ptr<action> matador::transaction::action_ptr

Shortcut to an action shared pointer

◆ t_action_vector

Shortcut to a vector of action shared pointer

Constructor & Destructor Documentation

◆ transaction() [1/4]

matador::transaction::transaction ( object_store store)
explicit

Creates a transaction for the given object_store.

Parameters
storeThe object_store the transaction is created for

◆ transaction() [2/4]

matador::transaction::transaction ( object_store store,
const std::shared_ptr< observer > &  obsvr 
)

Creates a transaction for the given object_store and observer.

Parameters
storeThe object_store the transaction is created for
obsvrThe observer to be used for the transaction events

◆ transaction() [3/4]

matador::transaction::transaction ( const transaction x)

Copy construct a transaction.

Parameters
xThe transaction to be copied from

◆ transaction() [4/4]

matador::transaction::transaction ( transaction &&  x)
default

Default copy move contructor for a transaction.

Parameters
xThe transaction to be moved

Member Function Documentation

◆ commit()

void matador::transaction::commit ( )

Finish transaction.

Finish transaction and commit all changes

◆ id()

unsigned long long matador::transaction::id ( ) const

Returns the unique id of the transaction.

Returns
The unique id of the transaction

◆ on_delete()

void matador::transaction::on_delete ( object_proxy *  proxy)

Called when deletion took place.

Template Parameters
TThe type of the deleted object

◆ on_insert()

void matador::transaction::on_insert ( object_proxy *  proxy)

Called when insertion took place.

Template Parameters
TThe type of the inserted object

◆ on_update()

void matador::transaction::on_update ( object_proxy *  proxy)

Called when update took place.

Template Parameters
TThe type of the updated object

◆ operator=()

transaction & matador::transaction::operator= ( transaction &&  x)
default

Default assignment move contructor for a transaction.

Parameters
xThe transaction to be moved
Returns
Reference to the transaction

◆ rollback()

void matador::transaction::rollback ( )

Rollback transaction.

Rollback transaction and revert all changes

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const transaction a,
const transaction b 
)
friend

Unequal operator for two transaction objects.

Every transaction has a unique id. This id is used for the comparation.

Parameters
aThe left hand transaction to be compared
bThe right hand transaction to be compared
Returns
True if transactions are not the same

◆ operator==

bool operator== ( const transaction a,
const transaction b 
)
friend

Equal operator for two transaction objects.

Every transaction has a unique id. This id is used for the comparation.

Parameters
aThe left hand transaction to be compared
bThe right hand transaction to be compared
Returns
True if transactions are the same

The documentation for this class was generated from the following file:
  • matador/object/transaction.hpp