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

Provide a lightweight abstraction around the SAVEPOINT SQL concept. More...

#include <Savepoint.hpp>

+ Collaboration diagram for Leosac::db::Savepoint:

Public Member Functions

 Savepoint (odb::database &db)
 Construct a Savepoint with a random name. More...
 
 Savepoint (odb::database &db, const std::string &name)
 Construct a Savepoint with a given name. More...
 
 Savepoint (const Savepoint &)=delete
 
 Savepoint (Savepoint &&o)=delete
 
 ~Savepoint ()
 
void release ()
 Release the Savepoint if it wasn't released already, otherwise does nothing. More...
 
bool rollback_to ()
 Rollback to the Savepoint, unless the Savepoint was already released. More...
 

Private Attributes

odb::database & db_
 
bool released_ {false}
 
std::string name_
 

Detailed Description

Provide a lightweight abstraction around the SAVEPOINT SQL concept.

This class implements SAVEPOINT, RELEASE SAVEPOINT and ROLLBACK TO SAVEPOINT.

Note
This class leverages RAII:
  • The Savepoint is created (database-wise) when the object is instancied.
  • Upon deletion the Savepoint is released.

Definition at line 40 of file Savepoint.hpp.

Constructor & Destructor Documentation

◆ Savepoint() [1/4]

Leosac::db::Savepoint::Savepoint ( odb::database &  db)

Construct a Savepoint with a random name.

Definition at line 38 of file Savepoint.cpp.

◆ Savepoint() [2/4]

Leosac::db::Savepoint::Savepoint ( odb::database &  db,
const std::string &  name 
)

Construct a Savepoint with a given name.

Definition at line 43 of file Savepoint.cpp.

◆ Savepoint() [3/4]

Leosac::db::Savepoint::Savepoint ( const Savepoint )
delete

◆ Savepoint() [4/4]

Leosac::db::Savepoint::Savepoint ( Savepoint &&  o)
delete

◆ ~Savepoint()

Leosac::db::Savepoint::~Savepoint ( )

Definition at line 50 of file Savepoint.cpp.

Member Function Documentation

◆ release()

void Leosac::db::Savepoint::release ( )

Release the Savepoint if it wasn't released already, otherwise does nothing.

Definition at line 55 of file Savepoint.cpp.

◆ rollback_to()

bool Leosac::db::Savepoint::rollback_to ( )

Rollback to the Savepoint, unless the Savepoint was already released.

Returns
true if rollback was performed, false otherwise.

Definition at line 64 of file Savepoint.cpp.

Member Data Documentation

◆ db_

odb::database& Leosac::db::Savepoint::db_
private

Definition at line 74 of file Savepoint.hpp.

◆ name_

std::string Leosac::db::Savepoint::name_
private

Definition at line 76 of file Savepoint.hpp.

◆ released_

bool Leosac::db::Savepoint::released_ {false}
private

Definition at line 75 of file Savepoint.hpp.


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