LMDBAL 0.6.0
LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer
Loading...
Searching...
No Matches
transaction.h
1/*
2 * LMDB Abstraction Layer.
3 * Copyright (C) 2023 Yury Gubich <blue@macaw.me>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#include "base.h"
22
23namespace LMDBAL {
24class iStorage;
25
27 friend class Base;
28 friend class iStorage;
29public:
30 explicit Transaction();
31 explicit Transaction(Transaction&& other);
32 Transaction(const Transaction& other) = delete;
33 Transaction& operator = (const Transaction& other) = delete;
34 Transaction& operator = (Transaction&& other);
35 virtual ~Transaction();
36
37 void terminate();
38 bool isActive() const;
39
40protected:
41 Transaction(TransactionID txn, const Base* parent);
42 void reset();
43
44protected:
45 TransactionID txn;
46 bool active;
47 const Base* parent;
48};
49
51 friend class Base;
52public:
53 explicit WriteTransaction();
54 explicit WriteTransaction(WriteTransaction&& other);
55 WriteTransaction(const WriteTransaction& other) = delete;
56 WriteTransaction& operator = (const WriteTransaction& other) = delete;
57 WriteTransaction& operator = (WriteTransaction&& other);
58
59 void commit();
60 void abort();
61
62protected:
63 WriteTransaction(TransactionID txn, Base* parent);
64};
65
66}
Database abstraction.
Definition base.h:53
Public read only transaction.
Definition transaction.h:26
bool active
Transaction state.
Definition transaction.h:46
TransactionID txn
Transaction inner handler.
Definition transaction.h:45
virtual ~Transaction()
Destroys transaction.
Definition transaction.cpp:75
void reset()
Resets inner transaction properties to inactive state.
Definition transaction.cpp:118
void terminate()
Terminates transaction if it was active.
Definition transaction.cpp:106
Transaction()
Constructs inactive transaction.
Definition transaction.cpp:40
const Base * parent
Pointer to the database this transaction belongs to.
Definition transaction.h:47
bool isActive() const
Returns transaction states.
Definition transaction.cpp:130
Public writable transaction.
Definition transaction.h:50
WriteTransaction()
Constructs inactive write transaction.
Definition transaction.cpp:167
void commit()
Commits transaction submitting all changes.
Definition transaction.cpp:198
void abort()
Aborts transaction cancelling all changes.
Definition transaction.cpp:189
Storage interface.
Definition storage.h:36