31 lines
753 B
C++
31 lines
753 B
C++
#pragma once
|
|
#include <json.hpp>
|
|
#include <string>
|
|
#include <mutex>
|
|
using json = nlohmann::json;
|
|
|
|
|
|
class DeviceConfig
|
|
{
|
|
private:
|
|
const std::string ParamPath ="/usr/local/huago/deviceconfig.json";
|
|
const std::string lock_enable = "lockenable";
|
|
const std::string token_code = "tokencode";
|
|
public:
|
|
struct DeviceParam
|
|
{
|
|
bool is_lock;
|
|
std::string token;
|
|
};
|
|
DeviceConfig(/* args */);
|
|
~DeviceConfig();
|
|
DeviceConfig::DeviceParam GetParam();
|
|
void SaveParam(DeviceConfig::DeviceParam param);
|
|
private:
|
|
json struct2json(DeviceConfig::DeviceParam param);
|
|
DeviceConfig::DeviceParam json2struct(json js);
|
|
void savejson(json js);
|
|
json getjson();
|
|
json getdefaultjson();
|
|
std::mutex m_lock;
|
|
}; |