OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::gpkg::Transaction Class Reference

Noncopyable best-effort transaction guard borrowing one SQLite connection. More...

#include <GpkgUtils.hpp>

Collaboration diagram for openswmm::gpkg::Transaction:

Public Member Functions

 Transaction (sqlite3 *db)
 Borrow a connection and begin an immediate write transaction.
 
void commit ()
 Commit an unfinished transaction and mark the guard finished.
 
void rollback ()
 Best-effort reset all live statements and roll back an unfinished transaction.
 
 ~Transaction ()
 Attempt best-effort rollback unless already committed/rolled back.
 
 Transaction (const Transaction &)=delete
 Disallow copying one transaction cleanup responsibility.
 
Transaction & operator= (const Transaction &)=delete
 Disallow copy replacement of a transaction guard.
 

Detailed Description

Noncopyable best-effort transaction guard borrowing one SQLite connection.

Commits explicitly and otherwise rolls back on destruction. This is not a rollback-success guarantee: rollback() marks completion after a bounded retry loop even if SQLite remains in a transaction.

Constructor & Destructor Documentation

◆ Transaction() [1/2]

openswmm::gpkg::Transaction::Transaction ( sqlite3 * db)
inlineexplicit

Borrow a connection and begin an immediate write transaction.

Connection must outlive the guard and have no incompatible active transaction. Constructor invokes exec(BEGIN IMMEDIATE), which can wait under the connection busy policy or throw GpkgError. Do not concurrently use transaction control on this connection.

Parameters
[in]dbNon-null live SQLite connection borrowed for this call; caller serializes transaction/statement use.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Transaction()

openswmm::gpkg::Transaction::~Transaction ( )
inline

Attempt best-effort rollback unless already committed/rolled back.

Uses rollback() and therefore may reset every statement on the borrowed connection. Does not close the connection or report rollback refusal.

Here is the call graph for this function:

◆ Transaction() [2/2]

openswmm::gpkg::Transaction::Transaction ( const Transaction & )
delete

Disallow copying one transaction cleanup responsibility.

Here is the call graph for this function:

Member Function Documentation

◆ commit()

void openswmm::gpkg::Transaction::commit ( )
inline

Commit an unfinished transaction and mark the guard finished.

Already-finished guard is a no-op. Failure throws GpkgError and leaves finished_ false so rollback remains possible; the guard does not begin a replacement transaction.

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

◆ operator=()

Transaction & openswmm::gpkg::Transaction::operator= ( const Transaction & )
delete

Disallow copy replacement of a transaction guard.

Here is the call graph for this function:

◆ rollback()

void openswmm::gpkg::Transaction::rollback ( )
inline

Best-effort reset all live statements and roll back an unfinished transaction.

Up to three attempts: resets EVERY statement on the borrowed connection, issues ROLLBACK, then checks autocommit. Marks finished even if all attempts fail; no failure status is returned. Can disrupt other statement cursors, so the guard requires exclusive connection control. Already-finished is a no-op.

Here is the caller graph for this function:

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