task_plan_2/include/core/plan.hpp

71 lines
2.3 KiB
C++
Raw Normal View History

2026-05-25 08:25:48 +00:00
#ifndef BATTLEFIELD_CORE_PLAN_HPP
#define BATTLEFIELD_CORE_PLAN_HPP
#include <string>
#include <vector>
#include <cstdint>
#include <map>
namespace battlefield {
/// @brief 子任务关系图谱节点,对应 T_PLAN_SUBTASK
struct PlanSubTask {
std::string id; ///< 子任务ID
std::string parentId; ///< 父任务ID空字符串表示根任务
std::string name; ///< 子任务名称
std::string description; ///< 描述
int32_t orderIndex{0}; ///< 执行顺序
std::string assignedUnit; ///< 执行单元
};
/// @brief 作战方案主数据结构,对应 T_PLAN
struct Plan {
std::string id; ///< 方案ID
std::string name; ///< 方案名称
std::string description; ///< 方案描述
std::vector<PlanSubTask> subTasks; ///< 子任务列表
double score{0.0}; ///< 方案评分
};
/// @brief 方案管理模块(覆盖 SRS-F-05-001 ~ SRS-F-05-004
class PlanManager {
public:
/// @brief 创建新方案
/// @param name 方案名称
/// @param description 方案描述
/// @return 创建的 Plan 对象
Plan CreatePlan(const std::string& name, const std::string& description);
/// @brief 获取所有方案列表
/// @return 方案列表
std::vector<Plan> GetPlanList() const;
/// @brief 按评分排序方案列表
/// @param ascending 是否升序
void SortPlansByScore(bool ascending = false);
/// @brief 对比两个方案的详细信息
/// @param planIdA 方案A的ID
/// @param planIdB 方案B的ID
/// @return 差异描述字符串
std::string ComparePlans(const std::string& planIdA, const std::string& planIdB);
/// @brief 重组方案(调整子任务顺序或分配)
/// @param planId 方案ID
/// @param newSubTasks 新的子任务列表
/// @return 是否成功重组
bool ReorganizePlan(const std::string& planId, const std::vector<PlanSubTask>& newSubTasks);
/// @brief 合并多个方案为一个融合方案
/// @param planIds 待融合的方案ID列表
/// @return 融合后的新方案
Plan MergePlans(const std::vector<std::string>& planIds);
private:
std::map<std::string, Plan> plans_; ///< 方案存储key为方案ID
};
} // namespace battlefield
#endif // BATTLEFIELD_CORE_PLAN_HPP