Files
eUi/include/missionCommon/missionAlgoAdapter.inc
RCiRoot e3f7733316 V20260829-2.6.1
完成框架目录和模块重构;新增核心、单例、工具、加密及框架 SDK;统一任务、相机和 RPC 接口,并增加离线检测、相机标定、备份恢复、版本管理、崩溃守护和心跳监控功能。
2026-09-20 16:01:09 +08:00

86 lines
3.9 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.
// mission 编写辅助层——不是 ABI 契约。
//
// 作用:给一个 mission 生成"类型化的算法接口 + null 校验转发适配器",让检测算法以
// eui_frameworkSdk::IMissionAlgo 的形式导出、可被 createMissionAlgoV1 独立热重载。
//
// 用法(在 .cpp 或 .h 中):
// #include <eui_frameworkSdk/IMissionAlgo.h>
// #define ALGO_METHOD_LIST(X) \
// X(detectFront, detectFrontImpl, MyParams, MyAddress) \
// X(detectBack, detectBackImpl, MyParams, MyAddress)
// #include <missionCommon/missionAlgoAdapter.inc>
// 之后:
// - algoInterface 是纯虚接口(继承 IMissionAlgo,含上面每个方法);
// - algoAdapter 是可实例化的 final 适配器,转发到同名自由函数 detectFrontImpl(...);
// - 用 FRAMEWORK_SDK_EXPORT_MISSION_ALGO_V1(algoAdapter) 导出。
//
// 可选:include 前 #define ALGO_INTERFACE_NAME / ALGO_ADAPTER_NAME 覆盖生成的类名。
// 前置条件:include 之前必须已可见 eui_frameworkSdk/IMissionAlgo.h 与 <memory>。
//
// 本文件故意不使用包含保护:每个 mission 在定义 ALGO_METHOD_LIST 后包含一次。
#ifndef ALGO_METHOD_LIST
#error "Define ALGO_METHOD_LIST before including missionAlgoAdapter.inc."
#endif
#ifndef ALGO_INTERFACE_NAME
#define ALGO_INTERFACE_NAME algoInterface
#endif
#ifndef ALGO_ADAPTER_NAME
#define ALGO_ADAPTER_NAME algoAdapter
#endif
class ALGO_INTERFACE_NAME : public eui_frameworkSdk::IMissionAlgo
{
public:
~ALGO_INTERFACE_NAME() override = default;
bool initBasic(eui_frameworkSdk::IServiceManager& serviceManager) override
{
serviceManager_ = &serviceManager;
return initCustom();
}
#define MISSION_COMMON_DECLARE_ALGO_METHOD(InterfaceMethod, ImplementationMethod, ParamsType, AddressType) \
virtual bool InterfaceMethod( \
const std::shared_ptr<eui_frameworkSdk::IDetData>& data, \
ParamsType* detParams, \
AddressType address, \
eui_frameworkSdk::IServiceManager* missionContext) = 0;
ALGO_METHOD_LIST(MISSION_COMMON_DECLARE_ALGO_METHOD)
#undef MISSION_COMMON_DECLARE_ALGO_METHOD
protected:
virtual bool initCustom() { return true; }
eui_frameworkSdk::IServiceManager* serviceManager() const { return serviceManager_; }
eui_frameworkSdk::IServiceManager* serviceManager_ = nullptr;
};
class ALGO_ADAPTER_NAME final : public ALGO_INTERFACE_NAME
{
public:
#define MISSION_COMMON_DEFINE_ALGO_METHOD(InterfaceMethod, ImplementationMethod, ParamsType, AddressType) \
bool InterfaceMethod( \
const std::shared_ptr<eui_frameworkSdk::IDetData>& data, \
ParamsType* detParams, \
AddressType address, \
eui_frameworkSdk::IServiceManager* missionContext) override \
{ \
if (!data || !detParams || !missionContext) \
return false; \
\
return ImplementationMethod(data, detParams, address, missionContext); \
}
ALGO_METHOD_LIST(MISSION_COMMON_DEFINE_ALGO_METHOD)
#undef MISSION_COMMON_DEFINE_ALGO_METHOD
};
#undef ALGO_INTERFACE_NAME
#undef ALGO_ADAPTER_NAME