Files
OpenRGB/SettingsManager.h
Adam Honse c3fc33d61e [WIP] SDK Version 6 Updates
* SDK Protocol
    * Server sends its name to client
    * ProfileManager
      * Rename existing profile commands
      * Add Upload Profile, Download Profile, and Get Active Profile commands
    * SettingsManager
      * Add Get, Set, and Save Settings commands
  * NetworkServer
    * Formatting cleanup
    * Use per-controller threads for handling NetworkServer controller-specific packets to avoid delays from controller mutexes
  * NetworkClient
    * Formatting cleanup
2025-12-19 22:33:52 -06:00

56 lines
1.9 KiB
C++

/*---------------------------------------------------------*\
| 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-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <nlohmann/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 SetSettingsFromJsonString(std::string settings_json_str) = 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 SetSettingsFromJsonString(std::string settings_json_str) 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;
};