update// changed datastore to factory pattern to get only the desired datastores

This commit is contained in:
maxisman
2020-05-08 19:39:16 +02:00
parent d599bf9190
commit 2e8b46c863
5 changed files with 199 additions and 51 deletions

View File

@@ -0,0 +1,63 @@
#ifndef SietchDataStore_H
#define SietchDataStore_H
using json = nlohmann::json;
class SietchDataStore
{
private:
static bool instanced;
static SietchDataStore* instance;
std::map<QString, QString> data;
SietchDataStore()
{
}
public:
static SietchDataStore* getInstance()
{
if(!SietchDataStore::instanced)
{
SietchDataStore::instanced = true;
SietchDataStore::instance = new SietchDataStore();
}
return SietchDataStore::instance;
}
void clear();
void setData(QString key, QString value);
QString getData(QString key);
QString dump();
~ChatDataStore()
{
ChatDataStore::instanced = false;
}
};
void SietchDataStore::clear()
{
this->data.clear();
}
void SietchDataStore::setData(QString key, QString value)
{
this->data[key] = value;
}
QString SietchDataStore::getData(QString key)
{
return this->data[key];
}
QString ChatDataStore::dump()
{
return "";
}
ChatDataStore* ChatDataStore::instance = nullptr;
bool ChatDataStore::instanced = false;
#endif