One Framework 0.1.0
RoboMaster嵌入式框架“一键”解决方案,为你的“创意”服务。
载入中...
搜索中...
未找到
UnitRegistry类 参考

单元注册类 更多...

#include <UnitRegistry.hpp>

UnitRegistry 的协作图:

Public 类型

using UnitRegistrationFunction = void (*)()
 单元注册函数类型
 
using UnitFactoryFunction = std::unique_ptr<Unit> (*)()
 单元工厂函数类型
 

静态 Public 成员函数

template<typename UnitType>
static void registerUnit ()
 注册单个单元类型
 
static std::unordered_map< std::string_view, std::unique_ptr< Unit > > & initialize ()
 初始化所有注册的单元
 
static std::optional< Unit * > findUnit (std::string_view name)
 通过名称查找单元信息
 
static void tryStartUnit (std::string_view name)
 
static void tryStopUnit (std::string_view name)
 
static void tryRestartUnit (std::string_view name)
 
static void updateAllUnitStats ()
 更新所有单元的资源使用统计
 

详细描述

单元注册类

UnitRegistry负责管理框架中所有Unit类型的注册、创建和状态追踪。 它提供了一种机制,允许Unit类型在编译时注册,并在运行时动态创建实例。 同时,它还跟踪运行中Unit的状态和资源使用情况。

成员类型定义说明

◆ UnitFactoryFunction

using UnitFactoryFunction = std::unique_ptr<Unit> (*)()

单元工厂函数类型

用于创建Unit实例的函数指针类型

◆ UnitRegistrationFunction

using UnitRegistrationFunction = void (*)()

单元注册函数类型

用于在启动时注册Unit类型的函数指针类型

成员函数说明

◆ findUnit()

std::optional< Unit * > findUnit ( std::string_view name)
static

通过名称查找单元信息

参数
name要查找的单元名称
返回
std::optional<Unit*> 找到时返回指向Unit的指针,否则返回空optional

◆ initialize()

std::unordered_map< std::string_view, std::unique_ptr< Unit > > & initialize ( )
static

初始化所有注册的单元

清理注册表,并调用所有已注册的注册函数,以便注册所有Unit类型。 此方法在系统启动时调用一次。

清理注册表,并调用所有已注册的注册函数,以便注册所有Unit类型

◆ registerUnit()

template<typename UnitType>
static void registerUnit ( )
inlinestatic

注册单个单元类型

将指定的Unit类型添加到注册表中,包括它的元数据和创建方法。 此方法通常通过REGISTER_UNIT宏自动调用。

模板参数
UnitType满足UnitDeriveConcept的Unit派生类型

◆ tryRestartUnit()

void tryRestartUnit ( std::string_view name)
static

◆ tryStartUnit()

void tryStartUnit ( std::string_view name)
static

◆ tryStopUnit()

void tryStopUnit ( std::string_view name)
static

◆ updateAllUnitStats()

void updateAllUnitStats ( )
static

更新所有单元的资源使用统计

调用Zephyr线程分析器获取所有线程的资源使用情况


该类的文档由以下文件生成: