some tuning, specializations, basic testing

This commit is contained in:
Blue 2022-09-16 00:34:39 +03:00
parent 5f90a21fe6
commit 047f96b54a
Signed by: blue
GPG key ID: 9B203B252A63EE38
17 changed files with 370 additions and 508 deletions

View file

@ -39,13 +39,19 @@ public:
void open();
void close();
bool ready() const;
bool removeDirectory();
QString getName() const;
template <class K, class V>
Table<K, V>* addTable(const QString& name);
Table<K, V>* addTable(const std::string& name);
template <class K, class V>
Table<K, V>* getTable(const std::string& name);
public:
//exceptions
class Exception;
class Directory;
class Closed;
class Opened;
@ -64,14 +70,18 @@ private:
#include "exceptions.h"
template <class K, class V>
DataBase::Table<K, V>* DataBase::addTable(const QString& p_name) {
std::string nm = p_name.toStdString();
DataBase::Table<K, V>* DataBase::addTable(const std::string& p_name) {
if (opened) {
throw Opened(name, nm);
throw Opened(name, p_name);
}
DataBase::Table<K, V>* table = new DataBase::Table<K, V>(nm, this);
tables.insert(std::make_pair(nm, (_Table*)table));
DataBase::Table<K, V>* table = new DataBase::Table<K, V>(p_name, this);
tables.insert(std::make_pair(p_name, (_Table*)table));
return table;
}
template <class K, class V>
DataBase::Table<K, V>* DataBase::getTable(const std::string& p_name) {
return static_cast<DataBase::Table<K, V>*>(tables.at(p_name));
}
#endif // CORE_DATABASE_H