Base class documentation, doxugen tweaking, new exception for one case

This commit is contained in:
Blue 2023-04-10 18:01:19 -03:00
parent ec0d2d57f0
commit af0e48a684
Signed by: blue
GPG key ID: 9B203B252A63EE38
11 changed files with 408 additions and 20 deletions

View file

@ -109,7 +109,19 @@ private:
#include "operators.hpp"
/**
* Adds LMDBAL::Storage with the given name to the LMDBAL::Base, also returns it. The LMDBAL::Base must be closed
* \brief Adds LMDBAL::Storage to the database
*
* Defines that the database is going to have the following storage.
* The LMDBAL::Base must be closed
*
* \param[in] name - storage name
* \returns storage pointer. LMDBAL::Base keeps the ownership of the added storage, you don't need to destoroy it
*
* \tparam K - key type of the storage
* \tparam V - value type of the storage
*
* \exception LMDBAL::Opened thrown if this method is called on the opened database
* \exception LMDBAL::StorageDuplicate thrown if somebody tries to add storage with repeating name
*/
template <class K, class V>
LMDBAL::Storage<K, V>* LMDBAL::Base::addStorage(const std::string& p_name) {
@ -117,12 +129,27 @@ LMDBAL::Storage<K, V>* LMDBAL::Base::addStorage(const std::string& p_name) {
throw Opened(name, "add storage " + p_name);
}
Storage<K, V>* storage = new Storage<K, V>(p_name, this);
storages.insert(std::make_pair(p_name, (iStorage*)storage));
std::pair<Storages::const_iterator, bool> pair = storages.insert(std::make_pair(p_name, (iStorage*)storage));
if (!pair.second)
throw StorageDuplicate(name, p_name);
return storage;
}
/**
* Adds LMDBAL::Cache with given the name to the LMDBAL::Base, also returns it. The LMDBAL::Base must be closed
* \brief Adds LMDBAL::Cache to the database
*
* Defines that the database is going to have the following cache.
* The LMDBAL::Base must be closed
*
* \param[in] name - cache name
* \returns cache pointer. LMDBAL::Base keeps the ownership of the added cache, you don't need to destoroy it
*
* \tparam K - key type of the cache
* \tparam V - value type of the cahce
*
* \exception LMDBAL::Opened thrown if this method is called on the opened database
* \exception LMDBAL::StorageDuplicate thrown if somebody tries to add cache with repeating name
*/
template<class K, class V>
LMDBAL::Cache<K, V> * LMDBAL::Base::addCache(const std::string& p_name) {
@ -130,12 +157,29 @@ LMDBAL::Cache<K, V> * LMDBAL::Base::addCache(const std::string& p_name) {
throw Opened(name, "add cache " + p_name);
}
Cache<K, V>* cache = new Cache<K, V>(p_name, this);
storages.insert(std::make_pair(p_name, (iStorage*)cache));
std::pair<Storages::const_iterator, bool> pair = storages.insert(std::make_pair(p_name, (iStorage*)cache));
if (!pair.second)
throw StorageDuplicate(name, p_name);
return cache;
}
/**
* Returns LMDBAL::Storage with the given name
* \brief Returns LMDBAL::Storage handle
*
* Requested storage must have been added before opening database
* Note that template parameters is user responsibility zone!
* If user, for instance, had added storage <int, int> but calling
* this method with template parameters <std::string, std::string>
* on the same name of the previously added storage, or calling it on cache - the behaviour is undefined
*
* \param[in] name - storage name
* \returns storage pointer. LMDBAL::Base keeps the ownership of the added storage, you don't need to destoroy it
*
* \tparam K - key type of the storage
* \tparam V - value type of the storage
*
* \exception std::out_of_range thrown if storage with the given name was not found
*/
template <class K, class V>
LMDBAL::Storage<K, V>* LMDBAL::Base::getStorage(const std::string& p_name) {
@ -143,7 +187,21 @@ LMDBAL::Storage<K, V>* LMDBAL::Base::getStorage(const std::string& p_name) {
}
/**
* Returns LMDBAL::Cache with the given name
* \brief Returns LMDBAL::Cache handle
*
* Requested cache must have been added before opening database
* Note that template parameters is user responsibility zone!
* If user, for instance, had added cache <int, int> but calling
* this method with template parameters <std::string, std::string>
* on the same name of the previously added cache, or calling it on storage - the behaviour is undefined
*
* \param[in] name - cache name
* \returns cache pointer. LMDBAL::Base keeps the ownership of the added cache, you don't need to destoroy it
*
* \tparam K - key type of the cache
* \tparam V - value type of the cahce
*
* \exception std::out_of_range thrown if cache with the given name was not found
*/
template <class K, class V>
LMDBAL::Cache<K, V>* LMDBAL::Base::getCache(const std::string& p_name) {