All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::da::ScopedTransaction Class Reference

An utility class to coordinate transactions. More...

#include <ScopedTransaction.h>

Inheritance diagram for te::da::ScopedTransaction:

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::DataSourceTransactorm_t
 A reference to the underlying transactor. More...
 

Detailed Description

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.

See also
DataSourceTransactor

Definition at line 56 of file ScopedTransaction.h.

Constructor & Destructor Documentation

te::da::ScopedTransaction::ScopedTransaction ( te::da::DataSourceTransactor transactor)

Constructor.

Parameters
transactorThe 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.

Member Function Documentation

void te::da::ScopedTransaction::commit ( )

It commits the transaction.

Exceptions
Itthrows 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().

Member Data Documentation

bool te::da::ScopedTransaction::m_rollback
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().

te::da::DataSourceTransactor& te::da::ScopedTransaction::m_t
private

A reference to the underlying transactor.

Definition at line 79 of file ScopedTransaction.h.

Referenced by ScopedTransaction().


The documentation for this class was generated from the following files: