FuncBase.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef FUNCBASE_H
  2. #define FUNCBASE_H
  3. #include <memory>
  4. #include "GlobalVariable.h"
  5. #include "spdlog/spdlog.h"
  6. class FromRedis;
  7. class ToEQMDataBase;
  8. struct FuncActionInfo;
  9. /**
  10. * @brief 功能基础类,包含读取Redis数据和写入EQM数据库的功能
  11. *
  12. */
  13. class FuncBase
  14. {
  15. public:
  16. FuncBase();
  17. ~FuncBase();
  18. /* 任务线程 */
  19. void thread_task();
  20. /* 设置功能信息 */
  21. void setFuncActionInfo(FuncActionInfo* pFuncAct);
  22. void setFuncActionInfo(FuncActionInfo& FuncAct);
  23. /* 获取该实例的功能 */
  24. AppFunction getApp();
  25. /* 获取线程运行状态 */
  26. bool getThreadRunning() const;
  27. protected:
  28. /* 真正执行任务的地方 */
  29. virtual void task() = 0;
  30. /* 判断是否在检测时间内 */
  31. bool isInDetectTime(const QDateTime& start, const QDateTime& end);
  32. protected:
  33. std::shared_ptr<spdlog::logger> m_logger = nullptr;
  34. /* 读取Redis的实例 */
  35. std::shared_ptr<FromRedis> m_fromRedis = nullptr;
  36. /* 写入EQM数据库的实例 */
  37. std::shared_ptr<ToEQMDataBase> m_toEQMDataBase = nullptr;
  38. /* 线程信息 */
  39. FuncActionInfo m_funcAct;
  40. std::atomic_bool m_bRunning = false; /* 线程运行状态 */
  41. };
  42. #endif // FUNCBASE_H