StormByte C++ Library: Database module 1.0.0
StormByte-Database is a StormByte library module for handling database connections
Loading...
Searching...
No Matches
transaction.hxx
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte.
5 *
6 * StormByte is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * StormByte is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with StormByte. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <StormByte/database/visibility.h>
23
28namespace StormByte::Database {
29 class Database;
30
38 class STORMBYTE_DATABASE_PUBLIC Transaction {
39 public:
43 explicit Transaction(Database& db) noexcept;
44
48 Transaction(const Transaction&) = delete;
49
54
59 Transaction(Transaction&& other) noexcept;
60
66 Transaction& operator=(Transaction&& other) noexcept;
67
71 ~Transaction() noexcept;
72
76 void Commit();
77
81 void Rollback();
82
86 bool IsActive() const noexcept {
87 return m_active;
88 }
89
90 private:
91 Database* m_db;
92 bool m_active;
93 };
94}
RAII wrapper for a database transaction.
Definition transaction.hxx:38
Transaction & operator=(Transaction &&other) noexcept
Transaction(Database &db) noexcept
Transaction & operator=(const Transaction &)=delete
Transaction(const Transaction &)=delete
Transaction(Transaction &&other) noexcept
Contains classes and functions for database operations.
Contains classes and functions for database operations.
Definition database.hxx:35