SystemConfig.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __SYSTEMCONFIG_H__
  2. #define __SYSTEMCONFIG_H__
  3. #include "GlobalVariable.h"
  4. #include "SystemConfigStruct.h"
  5. #include <string>
  6. enum class eSystemConfigType
  7. {
  8. eSCT_BaseConfig = 0, // 基础配置
  9. eSCT_CompareAI, // AI对比
  10. eSCT_NoiseDetect, // 噪音检测
  11. eSCT_Database, // 数据库设置
  12. eSCT_DetectPeriod // 检测时段
  13. };
  14. #define Config_Base "ACAS_Base" // 基础配置
  15. #define Config_CompareAI "ACAS_CompareAI" // AI对比配置
  16. #define Config_NoiseDetect "ACAS_NoiseDetect" // 噪音检测配置
  17. #define Config_Database "ACAS_Database" // 数据库设置
  18. #define Config_DetectPeriod "ACAS_DetectPeriod" // 检测时段配置
  19. /**
  20. * @brief ACA系统的设置信息
  21. *
  22. */
  23. #define SysConfig SystemConfigInfo::instance()
  24. class SystemConfigInfo
  25. {
  26. SystemConfigInfo() = default;
  27. SystemConfigInfo(const SystemConfigInfo&) = delete;
  28. SystemConfigInfo& operator=(const SystemConfigInfo&) = delete;
  29. public:
  30. ~SystemConfigInfo() = default;
  31. static SystemConfigInfo& instance()
  32. {
  33. static SystemConfigInfo instance;
  34. return instance;
  35. }
  36. /* 系统设置类型 */
  37. const QMap<eSystemConfigType, std::string> mapSysConfigDesc = {
  38. {eSystemConfigType::eSCT_BaseConfig, "基础配置"},
  39. {eSystemConfigType::eSCT_CompareAI, "AI对比设置"},
  40. {eSystemConfigType::eSCT_NoiseDetect, "噪音检测参数"},
  41. {eSystemConfigType::eSCT_Database, "数据库设置信息"},
  42. {eSystemConfigType::eSCT_DetectPeriod, "检测时段信息"}
  43. };
  44. /* 获取未被修改的基础配置 */
  45. const BaseConfig_t& getBaseConfigSrc() const { return m_baseConfigSrc; }
  46. /* 设置基础配置 */
  47. void setBaseConfig(const BaseConfig_t& config);
  48. /* 将数据库的json转换成结构体 */
  49. bool getBaseConfigFromJson(const std::string& jsonStr);
  50. /* 将结构体转换成json */
  51. bool setBaseConfigToJson(const BaseConfig_t& baseConfig, std::string& strJson) const;
  52. public:
  53. private:
  54. /* 基础配置未被修改版本 */
  55. BaseConfig_t m_baseConfigSrc;
  56. };
  57. #endif // __SYSTEMCONFIG_H__