tx-gxx-linux/device/gxx-linux/scanner/deviceconfig.h

31 lines
753 B
C
Raw Permalink Normal View History

2023-04-08 00:56:20 +00:00
#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;
};