70 lines
2.2 KiB
C++
70 lines
2.2 KiB
C++
|
|
#ifndef BATTLEFIELD_CORE_EVENT_HPP
|
|||
|
|
#define BATTLEFIELD_CORE_EVENT_HPP
|
|||
|
|
|
|||
|
|
#include <string>
|
|||
|
|
#include <chrono>
|
|||
|
|
#include <vector>
|
|||
|
|
#include <cstdint>
|
|||
|
|
|
|||
|
|
namespace battlefield {
|
|||
|
|
|
|||
|
|
/// @brief 事件类型枚举
|
|||
|
|
enum class EventType : int32_t {
|
|||
|
|
UNKNOWN = 0, ///< 未知类型
|
|||
|
|
INTEL = 1, ///< 情报事件
|
|||
|
|
THREAT = 2, ///< 威胁事件
|
|||
|
|
MISSION = 3, ///< 任务事件
|
|||
|
|
LOGISTIC = 4 ///< 后勤事件
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/// @brief 事件状态枚举
|
|||
|
|
enum class EventStatus : int32_t {
|
|||
|
|
PENDING = 0, ///< 待处理
|
|||
|
|
PROCESSING = 1, ///< 处理中
|
|||
|
|
RESOLVED = 2, ///< 已解决
|
|||
|
|
ARCHIVED = 3 ///< 已归档
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/// @brief 战场事件数据结构,对应数据库表 T_EVENT
|
|||
|
|
struct Event {
|
|||
|
|
std::string id; ///< EVENT_ID
|
|||
|
|
EventType type; ///< EVENT_TYPE
|
|||
|
|
std::chrono::system_clock::time_point timestamp; ///< TIMESTAMP
|
|||
|
|
std::string location; ///< LOCATION
|
|||
|
|
int32_t priority{0}; ///< PRIORITY
|
|||
|
|
EventStatus status{EventStatus::PENDING}; ///< STATUS
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/// @brief 事件接收与处理模块(覆盖 SRS-F-01-001 ~ SRS-F-01-004)
|
|||
|
|
class EventProcessor {
|
|||
|
|
public:
|
|||
|
|
/// @brief 接收外部事件数据包(对应接口 IF-01)
|
|||
|
|
/// @param rawJson 原始 JSON 格式的事件数据
|
|||
|
|
/// @return 成功接收返回 true
|
|||
|
|
bool ReceiveEvent(const std::string& rawJson);
|
|||
|
|
|
|||
|
|
/// @brief 对事件数据进行过滤、转化和封装
|
|||
|
|
/// @param raw 原始字符串数据
|
|||
|
|
/// @return 标准化后的 Event 对象
|
|||
|
|
Event TransformEvent(const std::string& raw);
|
|||
|
|
|
|||
|
|
/// @brief 获取当前所有待处理事件列表
|
|||
|
|
/// @return 事件列表(按接收顺序)
|
|||
|
|
std::vector<Event> GetPendingEvents() const;
|
|||
|
|
|
|||
|
|
/// @brief 按优先级对待处理事件排序
|
|||
|
|
/// @param ascending true 为升序(低优先级在前),false 为降序
|
|||
|
|
void SortEventsByPriority(bool ascending = true);
|
|||
|
|
|
|||
|
|
/// @brief 获取事件总数
|
|||
|
|
/// @return 事件数量
|
|||
|
|
size_t GetEventCount() const { return events_.size(); }
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
std::vector<Event> events_; ///< 内部事件存储
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
} // namespace battlefield
|
|||
|
|
|
|||
|
|
#endif // BATTLEFIELD_CORE_EVENT_HPP
|