One Framework 0.1.0
RoboMaster嵌入式框架“一键”解决方案,为你的“创意”服务。
载入中...
搜索中...
未找到
UnitRegistry.hpp 文件参考
#include <memory>
#include <optional>
#include <unordered_map>
#include <vector>
#include "Unit.hpp"
UnitRegistry.hpp 的引用(Include)关系图:
此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

结构体

class  UnitRegistry
 单元注册类 更多...
 

命名空间

namespace  OF
 

宏定义

#define OF_CONCAT_INTERNAL(x, y)
 
#define OF_CONCAT(x, y)
 
#define DEFINE_UNIT_TYPE(TypeId)
 定义单元类型ID
 
#define AUTO_UNIT_TYPE(TypeName)
 自动生成单元类型ID
 
#define REGISTER_UNIT(UnitClass)
 注册单元类宏
 

函数

constexpr uint32_t typeNameHash (const char *str)
 计算类型名称的哈希值
 

宏定义说明

◆ AUTO_UNIT_TYPE

#define AUTO_UNIT_TYPE ( TypeName)
值:
static constexpr uint32_t TYPE_ID = typeNameHash(#TypeName); \
uint32_t getTypeId() const override { return TYPE_ID; }

自动生成单元类型ID

此宏基于类型名称自动生成类型ID和getTypeId方法

参数
TypeName类型名称

◆ DEFINE_UNIT_TYPE

#define DEFINE_UNIT_TYPE ( TypeId)
值:
static constexpr uint32_t TYPE_ID = TypeId; \
uint32_t getTypeId() const override { return TYPE_ID; }

定义单元类型ID

此宏用于在Unit派生类中定义类型ID和getTypeId方法

参数
TypeId类型的唯一标识符

◆ OF_CONCAT

#define OF_CONCAT ( x,
y )
值:
#define OF_CONCAT_INTERNAL(x, y)
定义 UnitRegistry.hpp:17

◆ OF_CONCAT_INTERNAL

#define OF_CONCAT_INTERNAL ( x,
y )
值:
x##y

◆ REGISTER_UNIT

#define REGISTER_UNIT ( UnitClass)
值:
extern "C" { \
OF::UnitRegistry::UnitFactoryFunction \
_unit_factory_##UnitClass __attribute__((section(".unit_registry"),used)) = \
[]() -> std::unique_ptr<OF::Unit> { return std::make_unique<UnitClass>(); }; \
}

注册单元类宏

此宏自动将Unit派生类注册到UnitRegistry

参数
UnitClass要注册的Unit派生类名称