diff --git a/src/DataStore/ChatDataStore.h b/src/DataStore/ChatDataStore.h index 84291fc..82651fd 100644 --- a/src/DataStore/ChatDataStore.h +++ b/src/DataStore/ChatDataStore.h @@ -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* getInstance() + static ChatDataStore* getInstance() { - if(!ChatDataStore::instanced) + if(!ChatDataStore::instanced) { - ChatDataStore::instanced = true; - ChatDataStore::instance = new ChatDataStore(); + ChatDataStore::instanced = true; + ChatDataStore::instance = new ChatDataStore(); } - return ChatDataStore::instance; + return ChatDataStore::instance; } void clear(); @@ -33,7 +33,8 @@ class ChatDataStore ~ChatDataStore() { - ChatDataStore::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; } diff --git a/src/DataStore/DataStore.h b/src/DataStore/DataStore.h index 0aa8a09..6c006b0 100644 --- a/src/DataStore/DataStore.h +++ b/src/DataStore/DataStore.h @@ -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 \ No newline at end of file diff --git a/src/DataStore/SietchDataStore.h b/src/DataStore/SietchDataStore.h index 8739340..c94c76f 100644 --- a/src/DataStore/SietchDataStore.h +++ b/src/DataStore/SietchDataStore.h @@ -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 \ No newline at end of file diff --git a/src/controller.cpp b/src/controller.cpp index 1228e55..ac6b603 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -10,10 +10,10 @@ #include "websockets.h" #include "DataStore/DataStore.h" -template<> +/*template<> DataStore* DataStore::instance = nullptr; template<> -bool DataStore::instanced = false; +bool DataStore::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::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++)