47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "base.h"
|
|
|
|
namespace LMDBAL {
|
|
class iStorage;
|
|
|
|
class Transaction {
|
|
friend class Base;
|
|
friend class iStorage;
|
|
public:
|
|
explicit Transaction();
|
|
explicit Transaction(Transaction&& other);
|
|
Transaction(const Transaction& other) = delete;
|
|
Transaction& operator = (const Transaction& other) = delete;
|
|
Transaction& operator = (Transaction&& other);
|
|
virtual ~Transaction();
|
|
|
|
void terminate();
|
|
bool isActive() const;
|
|
|
|
protected:
|
|
Transaction(TransactionID txn, const Base* parent);
|
|
|
|
protected:
|
|
TransactionID txn; /**<\brief Transaction inner handler*/
|
|
bool active; /**<\brief Transaction state*/
|
|
const Base* parent; /**<\brief Pointer to the database this transaction belongs to*/
|
|
};
|
|
|
|
class WriteTransaction : public Transaction {
|
|
friend class Base;
|
|
public:
|
|
explicit WriteTransaction();
|
|
explicit WriteTransaction(WriteTransaction&& other);
|
|
WriteTransaction(const WriteTransaction& other) = delete;
|
|
WriteTransaction& operator = (const WriteTransaction& other) = delete;
|
|
|
|
void commit();
|
|
void abort();
|
|
|
|
protected:
|
|
WriteTransaction(TransactionID txn, Base* parent);
|
|
};
|
|
|
|
}
|