Leosac  0.8.0
Open Source Access Control
Leosac::db::OptionalTransaction Class Reference

An optional transaction is an object that behave like an odb::transaction if there is no currently active transaction. More...

#include <OptionalTransaction.hpp>

+ Collaboration diagram for Leosac::db::OptionalTransaction:

Public Member Functions

 OptionalTransaction (odb::transaction_impl *impl)
 
 ~OptionalTransaction ()
 
void commit ()
 Commit the transaction, if there was no currently active transaction at the time of this object's creation. More...
 
odb::transaction * get ()
 Retrieve the odb transaction object. More...
 

Private Attributes

std::unique_ptr< odb::transaction > transaction_
 

Detailed Description

An optional transaction is an object that behave like an odb::transaction if there is no currently active transaction.

If a transaction is already in progress, this object actually does nothing, and calling commit() on it will do nothing.

The goal of this object is simple:

  • That the same code can either run independently (ie manages its own transaction, and commit() it) or rely on the caller's transaction for operation (ie, persists/update its objects, but let the caller commit()).

Definition at line 43 of file OptionalTransaction.hpp.

Constructor & Destructor Documentation

◆ OptionalTransaction()

OptionalTransaction::OptionalTransaction ( odb::transaction_impl *  impl)

Definition at line 27 of file OptionalTransaction.cpp.

◆ ~OptionalTransaction()

OptionalTransaction::~OptionalTransaction ( )

Definition at line 33 of file OptionalTransaction.cpp.

Member Function Documentation

◆ commit()

void OptionalTransaction::commit ( )

Commit the transaction, if there was no currently active transaction at the time of this object's creation.

Definition at line 38 of file OptionalTransaction.cpp.

◆ get()

odb::transaction * OptionalTransaction::get ( )

Retrieve the odb transaction object.

Definition at line 44 of file OptionalTransaction.cpp.

Member Data Documentation

◆ transaction_

std::unique_ptr<odb::transaction> Leosac::db::OptionalTransaction::transaction_
private

Definition at line 61 of file OptionalTransaction.hpp.


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