-
-
Notifications
You must be signed in to change notification settings - Fork 188
/
SettingsManager.h
53 lines (43 loc) · 1.78 KB
/
SettingsManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*---------------------------------------------------------*\
| SettingsManager.h |
| |
| OpenRGB Settings Manager maintains a list of application|
| settings in JSON format. Other components may register |
| settings with this class and store/load values. |
| |
| Adam Honse (CalcProgrammer1) 04 Nov 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-only |
\*---------------------------------------------------------*/
#pragma once
#include "json.hpp"
#include <mutex>
#include "filesystem.h"
using json = nlohmann::json;
class SettingsManagerInterface
{
public:
virtual json GetSettings(std::string settings_key) = 0;
virtual void SetSettings(std::string settings_key, json new_settings) = 0;
virtual void LoadSettings(const filesystem::path& filename) = 0;
virtual void SaveSettings() = 0;
protected:
virtual ~SettingsManagerInterface() {};
};
class SettingsManager: public SettingsManagerInterface
{
public:
SettingsManager();
~SettingsManager();
json GetSettings(std::string settings_key) override;
void SetSettings(std::string settings_key, json new_settings) override;
void LoadSettings(const filesystem::path& filename) override;
void SaveSettings() override;
private:
json settings_data;
json settings_prototype;
filesystem::path settings_filename;
std::mutex mutex;
bool config_found;
};