task_plan_2/include/core/template.hpp

56 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef BATTLEFIELD_CORE_TEMPLATE_HPP
#define BATTLEFIELD_CORE_TEMPLATE_HPP
#include <string>
#include <vector>
#include <cstdint>
namespace battlefield {
/// @brief 任务模板数据结构,对应 T_TEMPLATE含版本管理字段 VERSION_ID
struct TaskTemplate {
std::string versionId; ///< VERSION_ID版本号
std::string name; ///< 模板名称
std::string description; ///< 模板描述
std::string content; ///< 模板内容JSON格式
std::string dateIndex; ///< 日期索引
bool isActive{true}; ///< 是否当前激活版本
};
/// @brief 模板管理模块(覆盖 SRS-F-03 / SRS-F-04 相关需求)
class TemplateManager {
public:
/// @brief 加载任务模板集合(模拟从文件系统读取 JSON 模板文件)
/// @param directory 模板文件目录
/// @return 成功加载的模板数量
size_t LoadTemplates(const std::string& directory);
/// @brief 获取所有模板列表
/// @return 模板列表
std::vector<TaskTemplate> GetTemplateList() const;
/// @brief 按名称排序模板列表
/// @param ascending 是否升序
void SortTemplatesByName(bool ascending = true);
/// @brief 选择指定版本的模板(人环模式)
/// @param versionId 版本ID
/// @return 选中的模板,若不存在返回空
TaskTemplate SelectTemplate(const std::string& versionId);
/// @brief 自动推荐最优模板(自主模式)
/// @return 推荐的模板
TaskTemplate RecommendTemplate();
/// @brief 获取模板总数
/// @return 模板数量
size_t GetTemplateCount() const { return templates_.size(); }
private:
std::vector<TaskTemplate> templates_; ///< 模板集合
};
} // namespace battlefield
#endif // BATTLEFIELD_CORE_TEMPLATE_HPP