SDRPlusPlus/core/src/config.h

48 wiersze
903 B
C
Czysty Zwykły widok Historia

2020-08-16 01:39:05 +00:00
#pragma once
#include <json.hpp>
#include <fstream>
#include <spdlog/spdlog.h>
#include <filesystem>
#include <sstream>
#include <iomanip>
#include <thread>
#include <chrono>
2020-09-24 17:36:57 +00:00
#include <string>
2020-08-16 01:39:05 +00:00
using nlohmann::json;
2020-09-24 17:38:05 +00:00
#define DEV_BUILD
2020-09-24 17:36:57 +00:00
#ifndef ROOT_DIR
#ifdef DEV_BUILD
#define ROOT_DIR "../root_dev"
#elif _WIN32
#define ROOT_DIR "."
#else
#define ROOT_DIR "/etc/sdrpp"
#endif
#endif
class ConfigManager {
public:
ConfigManager();
void setPath(std::string file);
void load(json default, bool lock = true);
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
};