更新时间:2021-03-18 GMT+08:00
分享

AIContext

在使用异步调用模型管家Process接口时,用于保存process上下文,AIContext中保存string类型键值对。该数据类型在ai_types.h中定义。
class AIContext
{
public:
    /*
    * @brief 获取参数
    * @param [in] key  参数对应的key
    * @return sring key对应的值,如果不存在,则返回空字符串
    */
    const std::string GetPara(const std::string &key) const;

    /*
    * @brief 设置参数
    * @param [in] key    参数对应的key
    * @param [in] value  参数对应的value
    */
    void AddPara(const std::string &key, const std::string &value);

    /*
    * @brief 删除参数
    * @param [in] key 待删除参数对应的key
    */
    void DeletePara(const std::string &key);

    /*
    * @brief 获取所有参数
    * @param [out] keys 所有已设置的参数key
    */
    void GetAllKeys(std::vector<std::string> &keys);

#if defined( __ANDROID__) || defined(ANDROID)
        std::string  Serialize();

        AIStatus  Deserialize(std::string str);
#endif

private:
    std::map<std::string, std::string> paras_; /** 参数的名值对定义 */
};
分享:

    相关文档

    相关产品