• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
24
博客园    首页    新随笔    联系   管理    订阅  订阅

C++(learning)

 

模板宏

例子,用于创建 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)

 

posted @ 2024-02-06 11:33  wxk1213  阅读(16)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3