Audacity 3.2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
audacity::sqlite::Transaction Class Referencefinal

A class representing a transaction in SQLite. More...

#include <Transaction.h>

Collaboration diagram for audacity::sqlite::Transaction:
[legend]

Public Member Functions

 Transaction (const Transaction &)=delete
 
 Transaction (Transaction &&)=delete
 
Transactionoperator= (const Transaction &)=delete
 
Transactionoperator= (Transaction &&)=delete
 
 ~Transaction ()
 
Error GetBeginResult () const noexcept
 
bool IsOpen () const noexcept
 
Error Commit () noexcept
 
Error Abort () noexcept
 

Private Types

enum class  TransactionOperation { BeginOp , CommitOp , RollbackOp }
 
using TransactionHandler = Error(*)(Connection &, TransactionOperation, Transaction &)
 

Private Member Functions

 Transaction (Connection &connection, TransactionHandler handler, std::string_view name) noexcept
 

Private Attributes

ConnectionmConnection
 
TransactionHandler mHandler
 
std::string mName
 
Error mBeginResult {}
 
bool mCommitted {}
 

Friends

class Connection
 

Detailed Description

A class representing a transaction in SQLite.

Definition at line 19 of file Transaction.h.

Member Typedef Documentation

◆ TransactionHandler

Definition at line 30 of file Transaction.h.

Member Enumeration Documentation

◆ TransactionOperation

Enumerator
BeginOp 
CommitOp 
RollbackOp 

Definition at line 23 of file Transaction.h.

24 {
25 BeginOp,
26 CommitOp,
27 RollbackOp,
28 };

Constructor & Destructor Documentation

◆ Transaction() [1/3]

audacity::sqlite::Transaction::Transaction ( Connection connection,
TransactionHandler  handler,
std::string_view  name 
)
privatenoexcept

◆ Transaction() [2/3]

audacity::sqlite::Transaction::Transaction ( const Transaction )
delete

◆ Transaction() [3/3]

audacity::sqlite::Transaction::Transaction ( Transaction &&  )
delete

◆ ~Transaction()

audacity::sqlite::Transaction::~Transaction ( )

Definition at line 22 of file Transaction.cpp.

23{
24 Abort();
25}

References Abort().

Here is the call graph for this function:

Member Function Documentation

◆ Abort()

Error audacity::sqlite::Transaction::Abort ( )
noexcept

Definition at line 48 of file Transaction.cpp.

49{
50 if (mCommitted)
51 return {};
52
54 return mBeginResult;
55
57}
bool IsError() const noexcept
Returns true if the object represents an error.
Definition: Error.cpp:25

References audacity::sqlite::Error::IsError(), mBeginResult, mCommitted, mConnection, mHandler, and RollbackOp.

Referenced by ~Transaction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Commit()

Error audacity::sqlite::Transaction::Commit ( )
noexcept

Definition at line 37 of file Transaction.cpp.

References CommitOp, audacity::sqlite::Error::IsError(), mBeginResult, mCommitted, mConnection, and mHandler.

Here is the call graph for this function:

◆ GetBeginResult()

Error audacity::sqlite::Transaction::GetBeginResult ( ) const
noexcept

Definition at line 27 of file Transaction.cpp.

28{
29 return mBeginResult;
30}

References mBeginResult.

◆ IsOpen()

bool audacity::sqlite::Transaction::IsOpen ( ) const
noexcept

Definition at line 32 of file Transaction.cpp.

33{
34 return mBeginResult.IsOk() && !mCommitted;
35}
bool IsOk() const noexcept
Returns true if the object represents a success code.
Definition: Error.cpp:30

References audacity::sqlite::Error::IsOk(), mBeginResult, and mCommitted.

Here is the call graph for this function:

◆ operator=() [1/2]

Transaction & audacity::sqlite::Transaction::operator= ( const Transaction )
delete

◆ operator=() [2/2]

Transaction & audacity::sqlite::Transaction::operator= ( Transaction &&  )
delete

Friends And Related Function Documentation

◆ Connection

friend class Connection
friend

Definition at line 21 of file Transaction.h.

Member Data Documentation

◆ mBeginResult

Error audacity::sqlite::Transaction::mBeginResult {}
private

Definition at line 55 of file Transaction.h.

Referenced by Abort(), Commit(), GetBeginResult(), and IsOpen().

◆ mCommitted

bool audacity::sqlite::Transaction::mCommitted {}
private

◆ mConnection

Connection& audacity::sqlite::Transaction::mConnection
private

Definition at line 52 of file Transaction.h.

Referenced by Abort(), and Commit().

◆ mHandler

TransactionHandler audacity::sqlite::Transaction::mHandler
private

Definition at line 53 of file Transaction.h.

Referenced by Abort(), and Commit().

◆ mName

std::string audacity::sqlite::Transaction::mName
private

Definition at line 54 of file Transaction.h.

Referenced by audacity::sqlite::Connection::TransactionHandler().


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