licensing, initial documentation initiative

This commit is contained in:
Blue 2023-03-23 20:27:46 +03:00
parent f5612dc3c5
commit 763d956bf8
Signed by: blue
GPG key ID: 9B203B252A63EE38
30 changed files with 1178 additions and 383 deletions

View file

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* LMDB Abstraction Layer.
* Copyright (C) 2023 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_BASE_H
#define LMDBAL_BASE_H
@ -67,19 +69,19 @@ public:
void abortTransaction(TransactionID id) const;
template <class K, class V>
Storage<K, V>* addTable(const std::string& name);
LMDBAL::Storage<K, V>* addStorage(const std::string& name);
template <class K, class V>
Cache<K, V>* addCache(const std::string& name);
LMDBAL::Cache<K, V>* addCache(const std::string& name);
template <class K, class V>
Storage<K, V>* getTable(const std::string& name);
LMDBAL::Storage<K, V>* getStorage(const std::string& name);
template <class K, class V>
Cache<K, V>* getCache(const std::string& name);
LMDBAL::Cache<K, V>* getCache(const std::string& name);
private:
typedef std::map<std::string, iStorage*> Tables;
typedef std::map<std::string, LMDBAL::iStorage*> Tables;
typedef std::set<TransactionID> Transactions;
TransactionID beginReadOnlyTransaction(const std::string& storageName) const;
@ -101,8 +103,11 @@ private:
}
#include "operators.hpp"
/**
* Adds LMDBAL::Storage with the given name to the LMDBAL::Base, also returns it. The LMDBAL::Base must be closed
*/
template <class K, class V>
LMDBAL::Storage<K, V>* LMDBAL::Base::addTable(const std::string& p_name) {
LMDBAL::Storage<K, V>* LMDBAL::Base::addStorage(const std::string& p_name) {
if (opened) {
throw Opened(name, "add table " + p_name);
}
@ -111,6 +116,9 @@ LMDBAL::Storage<K, V>* LMDBAL::Base::addTable(const std::string& p_name) {
return table;
}
/**
* Adds LMDBAL::Cache with given the name to the LMDBAL::Base, also returns it. The LMDBAL::Base must be closed
*/
template<class K, class V>
LMDBAL::Cache<K, V> * LMDBAL::Base::addCache(const std::string& p_name) {
if (opened) {
@ -121,11 +129,17 @@ LMDBAL::Cache<K, V> * LMDBAL::Base::addCache(const std::string& p_name) {
return cache;
}
/**
* Returns LMDBAL::Storage with the given name
*/
template <class K, class V>
LMDBAL::Storage<K, V>* LMDBAL::Base::getTable(const std::string& p_name) {
LMDBAL::Storage<K, V>* LMDBAL::Base::getStorage(const std::string& p_name) {
return static_cast<Storage<K, V>*>(tables.at(p_name));
}
/**
* Returns LMDBAL::Cache with the given name
*/
template <class K, class V>
LMDBAL::Cache<K, V>* LMDBAL::Base::getCache(const std::string& p_name) {
return static_cast<Cache<K, V>*>(tables.at(p_name));