Go to the documentation of this file.
3 #define MC_RTC_SCHEMA(SchemaT, BaseT) \
5 using is_schema_t = std::true_type; \
8 inline static mc_rtc::schema::Operations ops_; \
10 inline static size_t schema_size() noexcept \
12 return ops_.values_count + BaseT::ops_.values_count; \
14 inline void write_impl(mc_rtc::MessagePackBuilder & builder) const \
16 BaseT::ops_.write(this, builder); \
17 ops_.write(this, builder); \
21 inline void save(mc_rtc::Configuration & out) const \
23 BaseT::ops_.save(this, out); \
24 ops_.save(this, out); \
26 inline mc_rtc::Configuration toConfiguration() const \
28 mc_rtc::Configuration out; \
32 inline void write(mc_rtc::MessagePackBuilder & builder) const \
34 builder.start_map(schema_size()); \
35 write_impl(builder); \
36 builder.finish_map(); \
38 inline std::string dump(bool pretty, bool yaml) const \
40 mc_rtc::Configuration out; \
42 return out.dump(pretty, yaml); \
44 inline void load(const mc_rtc::Configuration & in) \
46 BaseT::ops_.load(this, in); \
47 ops_.load(this, in); \
49 inline static SchemaT fromConfiguration(const mc_rtc::Configuration & in) \
55 inline void buildForm(mc_rtc::schema::Operations::FormElements & form) const \
57 BaseT::ops_.buildForm(this, form); \
58 ops_.buildForm(this, form); \
60 static inline void formToStd(const mc_rtc::Configuration & in, mc_rtc::Configuration & out) \
62 BaseT::ops_.formToStd(in, out); \
63 ops_.formToStd(in, out); \
65 template<typename Callback = std::function<void()>> \
66 inline void addToGUI( \
67 mc_rtc ::gui::StateBuilder & gui, const std::vector<std::string> & category, const std::string & name, \
68 Callback callback = []() {}) \
70 auto form = mc_rtc::gui::Form(name, \
71 [this, callback](const mc_rtc::Configuration & in) \
73 mc_rtc::Configuration cfg; \
80 gui.addElement(category, form); \
82 inline bool operator==(const SchemaT & rhs) const \
84 return BaseT::ops_.areEqual(this, &rhs) && ops_.areEqual(this, &rhs); \
86 inline bool operator!=(const SchemaT & rhs) const \
88 return !(*this == rhs); \
91 #define MC_RTC_NEW_SCHEMA(SchemaT) MC_RTC_SCHEMA(SchemaT, mc_rtc::schema::details::EmptySchema)
94 #define MC_RTC_SCHEMA_MEMBER(T, TYPE, NAME, DESCRIPTION, REQUIRED, DEFAULT, ...) \
96 TYPE NAME = mc_rtc::schema::details::get_default( \
97 DEFAULT, std::integral_constant<mc_rtc::schema::ValueFlag, REQUIRED>{}, ##__VA_ARGS__); \
100 inline static const bool NAME##_registered_ = \
101 T::ops_.registerValue(mc_rtc::schema::details::MemberPointerWrapper<&T::NAME>{}, #NAME, DESCRIPTION, \
102 std::integral_constant<mc_rtc::schema::ValueFlag, REQUIRED>{}, ##__VA_ARGS__); \
107 #define MC_RTC_SCHEMA_REQUIRED_MEMBER(T, TYPE, NAME, DESCRIPTION, DEFAULT, ...) \
108 MC_RTC_PP_ID(MC_RTC_SCHEMA_MEMBER(T, TYPE, NAME, DESCRIPTION, mc_rtc::schema::ValueFlag::All, DEFAULT, ##__VA_ARGS__))
111 #define MC_RTC_SCHEMA_OPTIONAL_MEMBER(T, TYPE, NAME, DESCRIPTION, DEFAULT, ...) \
112 MC_RTC_PP_ID(MC_RTC_SCHEMA_MEMBER(T, TYPE, NAME, DESCRIPTION, mc_rtc::schema::ValueFlag::Interactive, DEFAULT, \
116 #define MC_RTC_SCHEMA_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, REQUIRED, ...) \
117 MC_RTC_PP_ID(MC_RTC_SCHEMA_MEMBER(T, TYPE, NAME, DESCRIPTION, REQUIRED, mc_rtc::Default<TYPE>::value, ##__VA_ARGS__))
120 #define MC_RTC_SCHEMA_REQUIRED_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, ...) \
121 MC_RTC_PP_ID(MC_RTC_SCHEMA_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, mc_rtc::schema::ValueFlag::All, ##__VA_ARGS__))
124 #define MC_RTC_SCHEMA_OPTIONAL_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, ...) \
126 MC_RTC_SCHEMA_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, mc_rtc::schema::ValueFlag::Interactive, ##__VA_ARGS__))