// Copyright 2019-2024 The Hush developers // Released under the GPLv3 #ifndef DATASTORE_H #define DATASTORE_H #include #include template class DataStore { private: static bool instanced; static DataStore* instance; std::map data; DataStore() { } public: static DataStore* getInstance() { if(!DataStore::instanced) { DataStore::instanced = true; DataStore::instance = new DataStore(); } return DataStore::instance; } void clear(); void setData(QString key, T value); QString getData(QString key); ~DataStore() { DataStore::instanced = false; } }; template void DataStore::clear() { this->data.clear(); } template void DataStore::setData(QString key, T value) { this->data[key] = value; } template QString DataStore::getData(QString key) { return this->data[key]; } #endif