task_plan_execute_2/include/template_manager.hpp

100 lines
3.6 KiB
C++
Raw Permalink 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 TPS_TEMPLATE_MANAGER_HPP
#define TPS_TEMPLATE_MANAGER_HPP
#include "app.hpp"
#include <string>
#include <vector>
#include <map>
// ============================================================
// 模板管理模块SU-05 模板管理单元)
// ============================================================
/**
* 模板管理器。
* 负责任务模板的接收、存储、版本管理、可视化和自动推荐。
*/
class TemplateManager {
public:
TemplateManager() = default;
~TemplateManager() = default;
/**
* 接收推送的任务模板集合数据包。
*
* @requirement(name="接收推送的任务模板集合数据", id="SRS-F-04-001")
* 接收上级单位或云服务推送的任务模板集合数据包,
* 解析后进行增量或全量更新。
*
* @param payload 模板集合数据包JSON/XML 字符串)
* @param format 数据格式("json" / "xml"
* @return true 表示接收并更新成功
*/
bool receiveTemplates(const std::string& payload, const std::string& format);
/**
* 获取当前可用的任务模板列表(仅已启用且未过期的模板)。
*
* @return 可用模板列表
*/
std::vector<TaskTemplate> getTemplateList() const;
/**
* 获取指定模板的所有版本记录。
*
* @requirement(name="任务模板先验知识库版本选择", id="SRS-F-03-001")
* 提供版本下拉框,允许用户选择已发布且未过期的任务模板版本。
*
* @param templateId 模板ID
* @return 版本列表
*/
std::vector<TemplateVersion> getConfig(const std::string& templateId) const;
/**
* 更新先验知识库配置参数。
*
* @requirement(name="先验知识库配置调整", id="SRS-F-03-002")
* 支持用户调整模板库相关配置参数,系统验证其合法性后更新
* 本地或服务器端配置文件。
*
* @param key 配置键
* @param value 配置值
* @return true 表示验证通过并更新成功
*/
bool updateConfig(const std::string& key, const std::string& value);
/**
* 在自主执行模式下运行匹配算法,推荐最优模板。
*
* @requirement(name="自主执行模式下任务模板自动选择提示", id="SRS-F-04-006")
* 在自主模式下,系统运行匹配算法计算各模板适配度,
* 选出最高分模板并向用户发出提示。
*
* @param scenario 当前任务场景描述
* @return 推荐度最高的模板ID如果无匹配则返回空字符串
*/
std::string autoSelectTemplate(const std::string& scenario);
/**
* 在人环模式下用户手动选择模板。
*
* @requirement(name="人环模式下用户选择任务模板", id="SRS-F-04-005")
* 在人机协同模式下,用户可点击"选用此模板"按钮选择模板,
* 系统记录选择结果并锁定版本。
*
* @param templateId 选中的模板ID
* @param version 锁定的版本号
* @return true 表示选择成功
*/
bool selectTemplate(const std::string& templateId, const std::string& version);
private:
std::vector<TaskTemplate> templates_; ///< 模板库
std::map<std::string, std::vector<TemplateVersion>> versionMap_; ///< 模板ID -> 版本列表
std::map<std::string, std::string> configStore_; ///< 配置参数存储
std::string selectedTemplateId_; ///< 当前选中模板ID
std::string lockedVersion_; ///< 锁定版本
};
#endif // TPS_TEMPLATE_MANAGER_HPP