PolicyProfile::Observer 类

客户端的观察程序接口,用于获取配置文件相关事件的通知。 所有错误都继承自 mip::Error。 客户端不应在调用观察者的线程上重新调用引擎。

总结

成员 说明
public virtual void OnLoadSuccess(const std::shared_ptr<PolicyProfile>& profile, const std::shared_ptr<void>& context) 成功加载配置文件时调用。
public virtual void OnLoadFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) 加载配置文件时调用导致错误。
public virtual void OnListEnginesSuccess(const std::vector<std::string>& engineIds, const std::shared_ptr<void>& context) 成功生成引擎列表时调用。
public virtual void OnListEnginesFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) 列出引擎导致错误时调用。
public virtual void OnUnloadEngineSuccess(const std::shared_ptr<void>& context) 成功卸载引擎时调用。
public virtual void OnUnloadEngineFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) 卸载引擎导致错误时调用。
public virtual void OnAddEngineSuccess(const std::shared_ptr<PolicyEngine>& engine, const std::shared_ptr<void>& context) 成功添加新引擎时调用。
public virtual void OnAddEngineStarting(bool requiresPolicyFetch) 在创建引擎之前调用,用于描述是否必须从服务器提取引擎的策略数据,或者是否可以从本地缓存数据创建策略数据。
public virtual void OnAddEngineFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) 添加新引擎时调用,导致错误。
public virtual void OnDeleteEngineSuccess(const std::shared_ptr<void>& context) 成功删除引擎时调用。
public virtual void OnDeleteEngineFailure(const std::exception_ptr& error, const std::shared_ptr<void>& context) 删除引擎时调用,导致错误。
public virtual void OnPolicyChanged(const std::string& engineId) 当具有给定 ID 的引擎的策略发生更改或加载的自定义敏感度类型发生更改时调用。

成员

OnLoadSuccess 函数

成功加载配置文件时调用。

参数:

  • 配置文件:用于启动操作的当前配置文件。

  • context:传递给 LoadAsync 操作的上下文。

OnLoadFailure 函数

加载配置文件时调用导致错误。

参数:

  • 错误:导致加载操作失败的错误。

  • context:传递给 LoadAsync 操作的上下文。

OnListEnginesSuccess 函数

成功生成引擎列表时调用。

参数:

  • engineIds:可用的引擎 ID 列表。

  • context:传递给 ListEnginesAsync 操作的上下文。

OnListEnginesFailure 函数

列出引擎导致错误时调用。

参数:

  • 错误:导致列表引擎操作失败的错误。

  • context:传递给 ListEnginesAsync 操作的上下文。

OnUnloadEngineSuccess 函数

成功卸载引擎时调用。

参数:

  • context:传递给 UnloadEngineAsync 操作的上下文。

OnUnloadEngineFailure 函数

卸载引擎导致错误时调用。

参数:

  • 错误:导致卸载引擎操作失败的错误。

  • context:传递给 UnloadEngineAsync 操作的上下文。

OnAddEngineSuccess 函数

成功添加新引擎时调用。

参数:

  • engine:新增引擎

  • context:传递给 AddEngineAsync 操作的上下文

OnAddEngineStarting 函数

在创建引擎之前调用,用于描述是否必须从服务器提取引擎的策略数据,或者是否可以从本地缓存数据创建策略数据。

参数:

  • requiresPolicyFetch:描述是必须通过 HTTP 提取引擎数据,还是从缓存加载引擎数据

应用程序可以使用此可选回调来指示 AddEngineAsync 操作是否需要 HTTP 操作(及其关联的延迟)来完成。

OnAddEngineFailure 函数

添加新引擎时调用,导致错误。

参数:

  • 错误:导致添加引擎操作失败的错误。

  • context:传递给 AddEngineAsync 操作的上下文。

OnDeleteEngineSuccess 函数

成功删除引擎时调用。

参数:

  • context:传递给 DeleteEngineAsync 操作的上下文。

OnDeleteEngineFailure 函数

删除引擎时调用,导致错误。

参数:

  • 错误:导致删除引擎操作失败的错误。

  • context:传递给 DeleteEngineAsync 操作的上下文。

OnPolicyChanged 函数

当具有给定 ID 的引擎的策略发生更改或加载的自定义敏感度类型发生更改时调用。

参数:

  • engineId:引擎

若要加载新策略,需要使用给定的引擎 ID 再次调用 AddEngineAsync。