模板宏
例子,用于创建 get()、set()
#define WELD_ATTACH_INFO_SETGET(T, FUN, VAR) \
inline T get##FUN() const { return VAR; } \
inline void set##FUN(T t) { VAR = t; }
WELD_THRESHOLD_SETGET(int, InitId, init_id_)
方便引用
#ifndef USE_PLANDATA
#define USE_PLANDATA(d) \
auto &info = d.info; \
auto &wm = d.wm; \
auto &rm = d.rm
#endif
指针
指针流程控制
//.h
inline StepPtr setNextStep(const StepPtr& p) {
next_ = p;
return next_;
}
bool build(const planData& d) {
readConfigs(d);
if (!compute(d)) {
PRINT_ERROR << " Error Step: " <<typeid(*this).name() << std::endl;
return false;
}
else {
PRINT_INFO << " Finish Step: " << typeid(*this).name() << std::endl;
}
if (next_) {
next_->build(d);
}
return true;
}
//.cpp
read_welds
->setNextStep(divide_whole_reigon)
->setNextStep(divide_robots_regions)
//->setNextStep(redistribute_by_task)
->setNextStep(group_inner_sort)
->setNextStep(plan_robots_regions)
->setNextStep(update_weld_info)
->setNextStep(output_plan_result);
// 执行规划
return read_welds->build(d_);
方便定义
#ifndef CLASSPTR
#define CLASSPTR(C) \
class C; \
using C##Ptr = std::shared_ptr<C>;
#endif // !CLASSPTR
CLASSPTR(RobotsRegions)
标签:return,CLASSPTR,setNextStep,C++,learning,FUN,define,build From: https://www.cnblogs.com/wxk1213/p/18009463