30#include <QStandardPaths>
35#include "exceptions.h"
47template <
class K,
class V>
50template <
class K,
class V>
53typedef MDB_txn* TransactionID;
54typedef uint32_t SizeType;
57 friend class StorageCommon;
58 friend class Transaction;
59 friend class WriteTransaction;
63 Base(
const QString& name, uint16_t mapSize = 10);
77 template <
class K,
class V>
80 template <
class K,
class V>
83 template <
class K,
class V>
86 template <
class K,
class V>
90 typedef std::map<std::string, LMDBAL::StorageCommon *> Storages;
91 typedef std::map<TransactionID, Transaction*> Transactions;
92 typedef std::set<Session*> Sessions;
94 void commitTransaction(TransactionID
id);
95 void abortTransaction(TransactionID
id)
const;
98 void commitTransaction(TransactionID
id,
const std::string& storageName);
99 void abortTransaction(TransactionID
id,
const std::string& storageName)
const;
101 TransactionID beginPrivateReadOnlyTransaction(
const std::string& storageName)
const;
102 TransactionID beginPrivateTransaction(
const std::string& storageName)
const;
103 void commitPrivateTransaction(TransactionID
id,
const std::string& storageName);
104 void abortPrivateTransaction(TransactionID
id,
const std::string& storageName)
const;
106 void registerSession(Session* session);
107 void unregisterSession(Session* session);
108 void replaceSession(Session* closing, Session* opening);
117 MDB_env* environment;
119 mutable Transactions transactions;
122 inline static const std::string emptyName =
"";
126#include "operators.hpp"
145template <
class K,
class V>
148 throw Opened(name,
"add storage " + storageName);
150 auto storage =
new Storage<K, V>(
this, storageName, duplicates);
151 std::pair<Storages::const_iterator, bool> pair = storages.emplace(storageName,
static_cast<StorageCommon *
>(storage));
173template<
class K,
class V>
176 throw Opened(name,
"add cache " + storageName);
178 auto cache =
new Cache<K, V>(
this, storageName,
false);
179 std::pair<Storages::const_iterator, bool> pair = storages.emplace(storageName,
static_cast<StorageCommon *
>(cache));
203template <
class K,
class V>
205 return static_cast<Storage<K, V>*
>(storages.at(storageName));
225template <
class K,
class V>
227 return static_cast<Cache<K, V>*
>(storages.at(storageName));
bool opened() const
Returns database state.
Definition base.cpp:147
Transaction beginReadOnlyTransaction() const
Begins read-only transaction.
Definition base.cpp:193
LMDBAL::Cache< K, V > * getCache(const std::string &storageName)
Returns LMDBAL::Cache handle.
Definition base.h:226
void drop()
Drops the database.
Definition base.cpp:159
WriteTransaction beginTransaction()
Begins writable transaction.
Definition base.cpp:216
QString getName() const
Returns database name.
Definition base.cpp:127
Base(const QString &name, uint16_t mapSize=10)
Creates the database.
Definition base.cpp:42
LMDBAL::Cache< K, V > * addCache(const std::string &storageName)
Adds LMDBAL::Cache to the database.
Definition base.h:174
LMDBAL::Storage< K, V > * addStorage(const std::string &storageName, bool duplicates=false)
Adds LMDBAL::Storage to the database.
Definition base.h:146
LMDBAL::Storage< K, V > * getStorage(const std::string &storageName)
Returns LMDBAL::Storage handle.
Definition base.h:204
bool removeDirectory()
Removes database directory.
Definition base.cpp:80
~Base()
Destroys the database.
Definition base.cpp:55
QString getPath() const
Returns database name.
Definition base.cpp:135
QString createDirectory()
Creates database directory.
Definition base.cpp:107
Storage with additional caching in std::map.
Definition cache.h:30
Thrown if something in the database was called on opened state and it is not supported.
Definition exceptions.h:119
A class handling serialization/deserialization.
Definition serializer.h:33
Storage interface.
Definition storagecommon.h:33
Thrown if there was attempt to define storages with conflicting names.
Definition exceptions.h:159
This is a basic key value storage.
Definition storage.h:38
Public read only transaction.
Definition transaction.h:27
Public writable transaction.
Definition transaction.h:54