#ifndef FUNCBASE_H #define FUNCBASE_H #include #include "GlobalVariable.h" #include "spdlog/spdlog.h" class FromRedis; class ToEQMDataBase; struct FuncActionInfo; /** * @brief 功能基础类,包含读取Redis数据和写入EQM数据库的功能 * */ class FuncBase { public: FuncBase(); ~FuncBase(); /* 任务线程 */ void thread_task(); /* 设置功能信息 */ void setFuncActionInfo(FuncActionInfo* pFuncAct); void setFuncActionInfo(FuncActionInfo& FuncAct); /* 获取该实例的功能 */ AppFunction getApp(); /* 获取线程运行状态 */ bool getThreadRunning() const; protected: /* 真正执行任务的地方 */ virtual void task() = 0; /* 判断是否在检测时间内 */ bool isInDetectTime(const QDateTime& start, const QDateTime& end); protected: std::shared_ptr m_logger = nullptr; /* 读取Redis的实例 */ std::shared_ptr m_fromRedis = nullptr; /* 写入EQM数据库的实例 */ std::shared_ptr m_toEQMDataBase = nullptr; /* 线程信息 */ FuncActionInfo m_funcAct; std::atomic_bool m_bRunning = false; /* 线程运行状态 */ }; #endif // FUNCBASE_H