Transaction.h
Go to the documentation of this file.
1 #ifndef cetlib_sqlite_Transaction_h
2 #define cetlib_sqlite_Transaction_h
3 
4 // ====================================================================
5 // Transaction
6 //
7 // A Transaction object encapsulates a single SQLite transaction. Such
8 // transactions cannot be nested. Look into using SAVEPOINT if you
9 // need nesting.
10 //
11 // Creating a Transaction begins a transaction in the given db, which
12 // is to have been already be opened.
13 //
14 // A transaction is committed by specifying 'commit()', which can be
15 // called ONLY ONCE per transaction object. If 'commit' is not called
16 // before the Transaction object is destroyed, then the transaction is
17 // rolled back.
18 // ====================================================================
19 
20 struct sqlite3;
21 
22 namespace cet::sqlite {
23 
24  class Transaction {
25  public:
26  explicit Transaction(sqlite3* db) noexcept(false);
27  ~Transaction() noexcept;
28 
29  void commit() noexcept(false);
30 
31  // Transactions may not be copied or moved.
32  Transaction(Transaction const&) = delete;
33  Transaction(Transaction&&) = delete;
34  Transaction& operator=(Transaction const&) = delete;
35  Transaction& operator=(Transaction&&) = delete;
36 
37  private:
39  };
40 
41 } // cet::sqlite
42 
43 #endif /* cetlib_sqlite_Transaction_h */
44 
45 // Local Variables:
46 // mode: c++
47 // End:
Transaction(sqlite3 *db) noexcept(false)
Definition: Transaction.cc:20
struct sqlite3 sqlite3
void commit() noexcept(false)
Definition: Transaction.cc:42
Transaction & operator=(Transaction const &)=delete