基础API

system.hpp

void System::Start(RobotParam... param)

实现

template <typename RobotType, typename... RobotParam>
void System::Start(RobotParam... param)

功能

Message、Term、Database、Timer等系统组件创建,Robot类初始化

示例

void robot_init() { System::Start<Robot::Blink, Robot::Blink::Param>(param); }

system_ext.h

System::TypeErasure

功能

类型擦除

实现

template <typename ResultType, typename ArgType, typename... Args>
class TypeErasure{
 public:
    TypeErasure(ResultType (*fun)(ArgType, Args... args), ArgType arg);
    static ResultType Port(void* addr, Args... args);
}

用法

class Test{
...
};

int thread_fn(Test* test){
...
}

Test test;

TypeErasure<void*, void*> type_era(thread_fn, &test);

int (*fun_ptr)(void* arg) = type_era.Port;

fun_ptr(&type_era); //等效于thread_fn(&test)