28#include <QStandardPaths>
33#include "exceptions.h"
39class WriteTransaction;
44template <
class K,
class V>
47template <
class K,
class V>
50typedef MDB_txn* TransactionID;
51typedef uint32_t SizeType;
59 Base(
const QString& name, uint16_t mapSize = 10);
74 template <
class K,
class V>
77 template <
class K,
class V>
80 template <
class K,
class V>
83 template <
class K,
class V>
87 typedef std::map<std::string, LMDBAL::iStorage*> Storages;
88 typedef std::map<TransactionID, Transaction*> Transactions;
90 void commitTransaction(TransactionID
id);
91 void abortTransaction(TransactionID
id)
const;
94 void commitTransaction(TransactionID
id,
const std::string& storageName);
95 void abortTransaction(TransactionID
id,
const std::string& storageName)
const;
97 TransactionID beginPrivateReadOnlyTransaction(
const std::string& storageName)
const;
98 TransactionID beginPrivateTransaction(
const std::string& storageName)
const;
99 void commitPrivateTransaction(TransactionID
id,
const std::string& storageName);
100 void abortPrivateTransaction(TransactionID
id,
const std::string& storageName)
const;
106 MDB_env* environment;
108 mutable Transactions transactions;
110 inline static const std::string emptyName =
"";
114#include "operators.hpp"
133template <
class K,
class V>
136 throw Opened(name,
"add storage " + storageName);
139 std::pair<Storages::const_iterator, bool> pair = storages.insert(std::make_pair(storageName, (
iStorage*)storage));
161template<
class K,
class V>
164 throw Opened(name,
"add cache " + storageName);
167 std::pair<Storages::const_iterator, bool> pair = storages.insert(std::make_pair(storageName, (
iStorage*)cache));
191template <
class K,
class V>
193 return static_cast<Storage<K, V>*
>(storages.at(storageName));
213template <
class K,
class V>
215 return static_cast<Cache<K, V>*
>(storages.at(storageName));
Database abstraction.
Definition base.h:53
void close()
Closes the database.
Definition base.cpp:67
Transaction beginReadOnlyTransaction() const
Begins read-only transaction.
Definition base.cpp:232
LMDBAL::Cache< K, V > * getCache(const std::string &storageName)
Returns LMDBAL::Cache handle.
Definition base.h:214
void drop()
Drops the database.
Definition base.cpp:198
WriteTransaction beginTransaction()
Begins writable transaction.
Definition base.cpp:255
QString getName() const
Returns database name.
Definition base.cpp:167
Base(const QString &name, uint16_t mapSize=10)
Creates the database.
Definition base.cpp:40
LMDBAL::Cache< K, V > * addCache(const std::string &storageName)
Adds LMDBAL::Cache to the database.
Definition base.h:162
LMDBAL::Storage< K, V > * addStorage(const std::string &storageName, bool duplicates=false)
Adds LMDBAL::Storage to the database.
Definition base.h:134
bool ready() const
Returns database state.
Definition base.cpp:187
void open()
Opens the database.
Definition base.cpp:92
LMDBAL::Storage< K, V > * getStorage(const std::string &storageName)
Returns LMDBAL::Storage handle.
Definition base.h:192
bool removeDirectory()
Removes database directory.
Definition base.cpp:120
~Base()
Destroys the database.
Definition base.cpp:52
QString getPath() const
Returns database name.
Definition base.cpp:175
QString createDirectory()
Creates database directory.
Definition base.cpp:147
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
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:134
Public read only transaction.
Definition transaction.h:26
Public writable transaction.
Definition transaction.h:50
Storage interface.
Definition storage.h:36