An utility class to coordinate transactions. More...
#include <ScopedTransaction.h>
Public Member Functions | |
void | commit () |
It commits the transaction. More... | |
ScopedTransaction (te::da::DataSourceTransactor &transactor) | |
Constructor. More... | |
~ScopedTransaction () | |
Destructor. More... | |
Private Attributes | |
bool | m_rollback |
A flag that indicates if the transaction may be aborted at the end. More... | |
te::da::DataSourceTransactor & | m_t |
A reference to the underlying transactor. More... | |
An utility class to coordinate transactions.
This class can be used to create an object that automatically rollback a transaction when it goes out of scope.
When the client has finished performing operations it must explicitly call the commit method. This will inform ScopedTransaction to not rollback when it goes out of scope.
Definition at line 56 of file ScopedTransaction.h.
te::da::ScopedTransaction::ScopedTransaction | ( | te::da::DataSourceTransactor & | transactor | ) |
Constructor.
transactor | The transactor that will be used to initiate a transaction. |
Definition at line 30 of file ScopedTransaction.cpp.
References te::da::DataSourceTransactor::begin(), te::da::DataSourceTransactor::isInTransaction(), m_rollback, and m_t.
te::da::ScopedTransaction::~ScopedTransaction | ( | ) |
Destructor.
Definition at line 40 of file ScopedTransaction.cpp.
void te::da::ScopedTransaction::commit | ( | ) |
It commits the transaction.
It | throws an exception if something goes wrong during transaction commitment. |
Definition at line 46 of file ScopedTransaction.cpp.
Referenced by te::sqlite::DataSourceTransactor::add(), te::pgis::Transactor::add(), and te::sqlite::BatchExecutor::execute().
|
private |
A flag that indicates if the transaction may be aborted at the end.
Definition at line 80 of file ScopedTransaction.h.
Referenced by ScopedTransaction().
|
private |
A reference to the underlying transactor.
Definition at line 79 of file ScopedTransaction.h.
Referenced by ScopedTransaction().