SDRPlusPlus/core/src/config.h

32 wiersze
636 B
C
Czysty Zwykły widok Historia

2020-08-16 01:39:05 +00:00
#pragma once
#include <json.hpp>
#include <thread>
2020-09-24 17:36:57 +00:00
#include <string>
#include <mutex>
2020-08-16 01:39:05 +00:00
using nlohmann::json;
2020-09-24 17:36:57 +00:00
class ConfigManager {
public:
ConfigManager();
2020-12-08 03:36:37 +00:00
~ConfigManager();
2020-09-24 17:36:57 +00:00
void setPath(std::string file);
2020-09-24 17:50:22 +00:00
void load(json def, bool lock = true);
2020-09-24 17:36:57 +00:00
void save(bool lock = true);
void enableAutoSave();
void disableAutoSave();
void aquire();
void release(bool changed = false);
json conf;
private:
static void autoSaveWorker(ConfigManager* _this);
std::string path = "";
bool changed = false;
bool autoSaveEnabled = false;
std::thread autoSaveThread;
std::mutex mtx;
2020-08-16 01:39:05 +00:00
};