Cursors refactoring part one
This commit is contained in:
parent
ef86d0adf9
commit
bfb1d007ad
19 changed files with 824 additions and 677 deletions
20
src/base.cpp
20
src/base.cpp
|
@ -52,7 +52,7 @@ LMDBAL::Base::Base(const QString& _name, uint16_t _mapSize):
|
|||
LMDBAL::Base::~Base() {
|
||||
close();
|
||||
|
||||
for (const std::pair<const std::string, iStorage*>& pair : storages)
|
||||
for (const std::pair<const std::string, StorageCommon*>& pair : storages)
|
||||
delete pair.second;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ void LMDBAL::Base::close() {
|
|||
pair.second->reset();
|
||||
}
|
||||
|
||||
for (const std::pair<const std::string, iStorage*>& pair : storages)
|
||||
for (const std::pair<const std::string, StorageCommon*>& pair : storages)
|
||||
pair.second->close();
|
||||
|
||||
mdb_env_close(environment);
|
||||
|
@ -99,8 +99,8 @@ void LMDBAL::Base::open() {
|
|||
mdb_env_open(environment, path.toStdString().c_str(), 0, 0664);
|
||||
|
||||
TransactionID txn = beginPrivateTransaction(emptyName);
|
||||
for (const std::pair<const std::string, iStorage*>& pair : storages) {
|
||||
iStorage* storage = pair.second;
|
||||
for (const std::pair<const std::string, StorageCommon*>& pair : storages) {
|
||||
StorageCommon* storage = pair.second;
|
||||
int rc = storage->open(txn);
|
||||
if (rc)
|
||||
throw Unknown(name, mdb_strerror(rc));
|
||||
|
@ -200,7 +200,7 @@ void LMDBAL::Base::drop() {
|
|||
throw Closed("drop", name);
|
||||
|
||||
TransactionID txn = beginPrivateTransaction(emptyName);
|
||||
for (const std::pair<const std::string, iStorage*>& pair : storages) {
|
||||
for (const std::pair<const std::string, StorageCommon*>& pair : storages) {
|
||||
int rc = pair.second->drop(txn);
|
||||
if (rc != MDB_SUCCESS) {
|
||||
abortPrivateTransaction(txn, emptyName);
|
||||
|
@ -209,7 +209,7 @@ void LMDBAL::Base::drop() {
|
|||
}
|
||||
|
||||
commitPrivateTransaction(txn, emptyName);
|
||||
for (const std::pair<const std::string, iStorage*>& pair : storages)
|
||||
for (const std::pair<const std::string, StorageCommon*>& pair : storages)
|
||||
pair.second->handleDrop();
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ LMDBAL::TransactionID LMDBAL::Base::beginReadOnlyTransaction(const std::string&
|
|||
throw Closed("beginReadOnlyTransaction", name, storageName);
|
||||
|
||||
TransactionID txn = beginPrivateReadOnlyTransaction(storageName);
|
||||
for (const std::pair<const std::string, LMDBAL::iStorage*>& pair : storages)
|
||||
for (const std::pair<const std::string, LMDBAL::StorageCommon*>& pair : storages)
|
||||
pair.second->transactionStarted(txn, true);
|
||||
|
||||
return txn;
|
||||
|
@ -331,7 +331,7 @@ LMDBAL::TransactionID LMDBAL::Base::beginTransaction(const std::string& storageN
|
|||
throw Closed("beginTransaction", name, storageName);
|
||||
|
||||
TransactionID txn = beginPrivateTransaction(storageName);
|
||||
for (const std::pair<const std::string, LMDBAL::iStorage*>& pair : storages)
|
||||
for (const std::pair<const std::string, LMDBAL::StorageCommon*>& pair : storages)
|
||||
pair.second->transactionStarted(txn, false);
|
||||
|
||||
return txn;
|
||||
|
@ -356,7 +356,7 @@ void LMDBAL::Base::abortTransaction(LMDBAL::TransactionID id, const std::string&
|
|||
throw Closed("abortTransaction", name, storageName);
|
||||
|
||||
abortPrivateTransaction(id, storageName);
|
||||
for (const std::pair<const std::string, LMDBAL::iStorage*>& pair : storages)
|
||||
for (const std::pair<const std::string, LMDBAL::StorageCommon*>& pair : storages)
|
||||
pair.second->transactionAborted(id);
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ void LMDBAL::Base::commitTransaction(LMDBAL::TransactionID id, const std::string
|
|||
throw Closed("abortTransaction", name, storageName);
|
||||
|
||||
commitPrivateTransaction(id, storageName);
|
||||
for (const std::pair<const std::string, LMDBAL::iStorage*>& pair : storages)
|
||||
for (const std::pair<const std::string, LMDBAL::StorageCommon*>& pair : storages)
|
||||
pair.second->transactionCommited(id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue