update// added ChatDataStore and SietchDataStore with factory-pattern
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef DATASTORE_H
|
||||
#define DATASTORE_H
|
||||
#ifndef CHATDATASTORE_H
|
||||
#define CHATDATASTORE_H
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -15,15 +15,15 @@ class ChatDataStore
|
||||
}
|
||||
|
||||
public:
|
||||
static ChatDataStore<T>* getInstance()
|
||||
static ChatDataStore* getInstance()
|
||||
{
|
||||
if(!ChatDataStore<T>::instanced)
|
||||
if(!ChatDataStore::instanced)
|
||||
{
|
||||
ChatDataStore<T>::instanced = true;
|
||||
ChatDataStore<T>::instance = new ChatDataStore();
|
||||
ChatDataStore::instanced = true;
|
||||
ChatDataStore::instance = new ChatDataStore();
|
||||
}
|
||||
|
||||
return ChatDataStore<ChatItem>::instance;
|
||||
return ChatDataStore::instance;
|
||||
}
|
||||
|
||||
void clear();
|
||||
@@ -33,7 +33,8 @@ class ChatDataStore
|
||||
|
||||
~ChatDataStore()
|
||||
{
|
||||
ChatDataStore<T>::instanced = false;
|
||||
ChatDataStore::instanced = false;
|
||||
ChatDataStore::instance = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,7 +44,7 @@ void ChatDataStore::clear()
|
||||
}
|
||||
|
||||
|
||||
void ChatDataStore:setData(QString key, ChatItem value)
|
||||
void ChatDataStore::setData(QString key, ChatItem value)
|
||||
{
|
||||
this->data[key] = value;
|
||||
}
|
||||
|
||||
@@ -6,16 +6,19 @@
|
||||
|
||||
class DataStore
|
||||
{
|
||||
public:
|
||||
static SietchDataStore* getSietchDataStore()
|
||||
{
|
||||
return SietchDataStore::getInstance();
|
||||
}
|
||||
public:
|
||||
static SietchDataStore* getSietchDataStore();
|
||||
static ChatDataStore* getChatDataStore();
|
||||
};
|
||||
|
||||
static ChatDataStore* getChatDataStore()
|
||||
{
|
||||
return ChatDataStore::getInstance();
|
||||
}
|
||||
SietchDataStore* DataStore::getSietchDataStore()
|
||||
{
|
||||
return SietchDataStore::getInstance();
|
||||
}
|
||||
|
||||
ChatDataStore* DataStore::getChatDataStore()
|
||||
{
|
||||
return ChatDataStore::getInstance();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef SietchDataStore_H
|
||||
#define SietchDataStore_H
|
||||
#ifndef SIETCHDATASTORE_H
|
||||
#define SIETCHDATASTORE_H
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -31,9 +31,10 @@ class SietchDataStore
|
||||
QString getData(QString key);
|
||||
QString dump();
|
||||
|
||||
~ChatDataStore()
|
||||
~SietchDataStore()
|
||||
{
|
||||
ChatDataStore::instanced = false;
|
||||
SietchDataStore::instanced = false;
|
||||
SietchDataStore::instance = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,12 +53,12 @@ QString SietchDataStore::getData(QString key)
|
||||
return this->data[key];
|
||||
}
|
||||
|
||||
QString ChatDataStore::dump()
|
||||
QString SietchDataStore::dump()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
ChatDataStore* ChatDataStore::instance = nullptr;
|
||||
bool ChatDataStore::instanced = false;
|
||||
SietchDataStore* SietchDataStore::instance = nullptr;
|
||||
bool SietchDataStore::instanced = false;
|
||||
|
||||
#endif
|
||||
@@ -10,10 +10,10 @@
|
||||
#include "websockets.h"
|
||||
#include "DataStore/DataStore.h"
|
||||
|
||||
template<>
|
||||
/*template<>
|
||||
DataStore<QString>* DataStore<QString>::instance = nullptr;
|
||||
template<>
|
||||
bool DataStore<QString>::instanced = false;
|
||||
bool DataStore<QString>::instanced = false;*/
|
||||
ChatModel *chatModel = new ChatModel();
|
||||
ContactModel *contactModel = new ContactModel();
|
||||
|
||||
@@ -131,7 +131,7 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
|
||||
dust.at(i)["address"] = DataStore::getSietchDataStore()->getData(QString("Sietch" + QString(i))).toStdString();
|
||||
}
|
||||
|
||||
DataStore<QString>::getInstance()->clear(); // clears the datastore
|
||||
DataStore::getSietchDataStore()->clear(); // clears the datastore
|
||||
|
||||
// Dust amt/memo, construct the JSON
|
||||
for(uint8_t i = 0; i < 10; i++)
|
||||
|
||||
Reference in New Issue
Block a user