#pragma once #include #include #include #include "AIStatus.h" #include "nlohmann/json.hpp" class ConfigModule { public: int init(const std::string &filePath); int getPipelineUpdateResource(const int &pipelineId, const bool isEnable, std::vector &needCreateRsource, std::vector &needDeleteResource); int getAllPipelineIdNameStatus(std::vector> &uidPipilineIdNameStatusMap) const; int setPipelineUpdateConfig(const int &pipelineId, bool isEnable); int getPipelineModelConfig(const int &pipelineId, const int &modeUid, const std::string &key, float &value) const; int setPipelineModelConfig(const int &pipelineId, const int &modeUid, const std::string &key, const float &value); /** * @brief 初始化资源的二维整数向量。 * * 该二维向量存储 pipeline 存储初始化资源的顺序。外层向量表示不同 pipeline 的初始化资源的顺序,内层向量该pipeline每个 uid 对应资源初始化顺序。 * * 示例 : * - pipeline = [[1,2],[1,3]] 则存入的init_resource_数据为 [[1,2],[3]] */ std::vector> initResourceOrder; /** * @brief 推理资源的元组向量。 * * 该向量存储 pipeline 推理资源的顺序。每个元组包含一个 pipeline的uid 和 其对应推理资源的uid。 * * * 示例 : * - infer_resource_ = [[91,[1,2]],[92,[1,3]]],该向量表示要运行两个pipeline 第一个的uid是91,用的资源是1->2,以此类推 */ std::vector>> uidInferResourceMap; /** * @brief UID 对应资源类型的无序映射。 * * 该无序映射用于存储每个 UID 对应的资源类型,其中 UID 是整数,资源类型是是pre_process或model。 * * 示例 : * - UID 1 对应资源类型 "pre_process" * - UID 2 对应资源类型 "model" */ // std::unordered_map resource_type_; std::unordered_map uidResourceTypeMap; /** * @brief 存储配置数据的 JSON 对象。 * * 该 JSON 对象用于存储配置数据,使用 nlohmann::json 类型。 * */ nlohmann::json configData; private: /** * @brief 管道 UID 到名称的无序映射。 * * 该无序映射用于存储管道 UID 到名称的映射关系,其中 UID 是整数,名称是字符串。 * * 示例 : * - 管道 UID 为 1 对应名称 "pet_detect" * - 管道 UID 为 2 对应名称 "fire_detect" */ std::unordered_map uidPipilineNameMap; /** * @brief 存储配置文件路径的字符串。 * * 该字符串用于存储配置文件的路径。 * * 示例 : * - "/path/to/config/file.json" */ std::string configFilePath; /** * @brief 存储管道信息的元组向量。 * * 该向量包含每个管道的信息,每个元组包含以下字段 : * - ID :整数,管道的唯一标识符。 * - Name :字符串,管道的名称。 * - Steps :整数向量,表示管道的步骤信息。 * - Enabled :布尔值,表示管道是否启用。 * * 示例 : * - (91, "fire_detect", [1, 2, 3], true) * - (92, "pet_detect", [4, 5], false) */ std::vector, bool>> uidPipilineInfo; /** * @brief 更新配置文件。 * * 该函数用于更新配置文件内容。 * * @return 返回更新操作的状态码,如果成功返回0,否则返回错误码。 * - AIStatus::ErrorCode::JSON_O_UPDATE: 打开配置文件失败。 */ int updateCfgFile(); int updateAICFG(); };