2026-05-20 08:00:11 +00:00
|
|
|
|
#ifndef ETMS_APP_HPP
|
|
|
|
|
|
#define ETMS_APP_HPP
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
2026-05-21 07:09:58 +00:00
|
|
|
|
#include <memory>
|
|
|
|
|
|
#include "event_manager.hpp"
|
|
|
|
|
|
#include "task_template_manager.hpp"
|
2026-05-20 08:00:11 +00:00
|
|
|
|
|
2026-05-20 09:17:29 +00:00
|
|
|
|
/**
|
2026-05-21 07:09:58 +00:00
|
|
|
|
* @brief ETMS 应用主类
|
2026-05-20 09:17:29 +00:00
|
|
|
|
*
|
2026-05-21 07:09:58 +00:00
|
|
|
|
* 负责初始化各核心管理器,提供应用生命周期控制。
|
|
|
|
|
|
* 封装事件管理与任务模板管理的顶层协调逻辑。
|
2026-05-20 09:17:29 +00:00
|
|
|
|
*/
|
2026-05-21 07:09:58 +00:00
|
|
|
|
class App {
|
2026-05-20 09:17:29 +00:00
|
|
|
|
public:
|
|
|
|
|
|
/**
|
2026-05-21 07:09:58 +00:00
|
|
|
|
* @brief 构造 App 实例
|
|
|
|
|
|
* @param appName 应用名称标识
|
2026-05-20 09:17:29 +00:00
|
|
|
|
*/
|
2026-05-21 07:09:58 +00:00
|
|
|
|
explicit App(const std::string& appName);
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
2026-05-21 07:09:58 +00:00
|
|
|
|
/// @brief 析构函数,释放内部资源
|
|
|
|
|
|
~App();
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
2026-05-21 07:09:58 +00:00
|
|
|
|
// 禁止拷贝
|
|
|
|
|
|
App(const App&) = delete;
|
|
|
|
|
|
App& operator=(const App&) = delete;
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
2026-05-21 07:09:58 +00:00
|
|
|
|
/// @brief 允许移动
|
|
|
|
|
|
App(App&&) noexcept;
|
|
|
|
|
|
App& operator=(App&&) noexcept;
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-21 07:09:58 +00:00
|
|
|
|
* @brief 初始化应用,创建事件管理器与任务模板管理器
|
|
|
|
|
|
* @return true 初始化成功,false 初始化失败
|
2026-05-20 09:17:29 +00:00
|
|
|
|
*/
|
2026-05-21 07:09:58 +00:00
|
|
|
|
bool initialize();
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-21 07:09:58 +00:00
|
|
|
|
* @brief 运行应用主循环(此处为示例演示)
|
2026-05-20 09:17:29 +00:00
|
|
|
|
*/
|
2026-05-21 07:09:58 +00:00
|
|
|
|
void run();
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-21 07:09:58 +00:00
|
|
|
|
* @brief 获取事件管理器引用
|
|
|
|
|
|
* @return EventManager&
|
2026-05-20 09:17:29 +00:00
|
|
|
|
*/
|
2026-05-21 07:09:58 +00:00
|
|
|
|
EventManager& getEventManager();
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-21 07:09:58 +00:00
|
|
|
|
* @brief 获取任务模板管理器引用
|
|
|
|
|
|
* @return TaskTemplateManager&
|
2026-05-20 09:17:29 +00:00
|
|
|
|
*/
|
2026-05-21 07:09:58 +00:00
|
|
|
|
TaskTemplateManager& getTaskTemplateManager();
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-21 07:09:58 +00:00
|
|
|
|
* @brief 打印应用状态摘要
|
2026-05-20 09:17:29 +00:00
|
|
|
|
*/
|
2026-05-21 07:09:58 +00:00
|
|
|
|
void printSummary() const;
|
2026-05-20 09:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
private:
|
2026-05-21 07:09:58 +00:00
|
|
|
|
std::string m_appName; ///< 应用名称
|
|
|
|
|
|
std::unique_ptr<EventManager> m_eventManager; ///< 事件管理器
|
|
|
|
|
|
std::unique_ptr<TaskTemplateManager> m_templateManager; ///< 任务模板管理器
|
|
|
|
|
|
bool m_initialized = false; ///< 初始化标志
|
2026-05-20 09:17:29 +00:00
|
|
|
|
};
|
2026-05-20 08:00:11 +00:00
|
|
|
|
|
|
|
|
|
|
#endif // ETMS_APP_HPP
|