GlobalConfig.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef GLOBALCONFIG_H
  2. #define GLOBALCONFIG_H
  3. #include <QString>
  4. /* ====================================================================================
  5. * ************************** GlobalConfig成员函数 ******************************
  6. * ====================================================================================*/
  7. /**
  8. * @brief 读取配置文件
  9. *
  10. */
  11. class GlobalConfig
  12. {
  13. public:
  14. GlobalConfig();
  15. ~GlobalConfig() = default;
  16. /* 读取配置文件 */
  17. bool readConfig(const QString& strConfigFile);
  18. /* 打印读取到的值 */
  19. void printValue();
  20. int AppUpdateOnWorkTimeInterval;/* 更新在岗信息的时间间隔 */
  21. int AppPeopleOnWork; /* 离岗时间 */
  22. int Contraband; /* 违禁物品出现的时间 */
  23. int AppBadMan; /* 非法入侵 */
  24. int AppTired; /* 疲劳检测时间 */
  25. int AppPeopleCont; /* 区域人员统计 */
  26. int AppPlayPhone; /* 玩手机识别 */
  27. int AppMouse; /* 老鼠识别 */
  28. int AppMask; /* 戴口罩识别 */
  29. int CheckSet; /* 服务端多久检测一次配置 */
  30. int EventTimeValid; /* 事件时间有效期 */
  31. int ThreadSleepMS; /* 任务线程休眠时间,单位是ms */
  32. std::string Key; /* Key */
  33. std::string Secret; /* Secret */
  34. };
  35. extern GlobalConfig g_config;
  36. /* ====================================================================================
  37. * ************************ GlobalThreadInfo成员函数 *****************************
  38. * ====================================================================================*/
  39. #define GThreadInfo GlobalThreadInfo::getInstance()
  40. class GlobalThreadInfo
  41. {
  42. GlobalThreadInfo();
  43. ~GlobalThreadInfo() {}
  44. GlobalThreadInfo(const GlobalThreadInfo& other) = delete;
  45. GlobalThreadInfo& operator=(const GlobalThreadInfo& other) = delete;
  46. public:
  47. static GlobalThreadInfo& getInstance()
  48. {
  49. static GlobalThreadInfo instance;
  50. return instance;
  51. }
  52. /* 获取线程运行标志位 */
  53. inline bool getRunning() const;
  54. /* 设置线程运行标志位 */
  55. inline void setRunning(bool bRunning);
  56. private:
  57. std::atomic_bool m_bRunning; /* 线程运行状态 */
  58. };
  59. #endif /* GLOBALCONFIG_H */