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 \
11 { return ops_.values_count + BaseT::ops_.values_count; } \
12 inline void write_impl(mc_rtc::MessagePackBuilder & builder) const \
14 BaseT::ops_.write(this, builder); \
15 ops_.write(this, builder); \
19 inline void save(mc_rtc::Configuration & out) const \
21 BaseT::ops_.save(this, out); \
22 ops_.save(this, out); \
24 inline mc_rtc::Configuration toConfiguration() const \
26 mc_rtc::Configuration out; \
30 inline void write(mc_rtc::MessagePackBuilder & builder) const \
32 builder.start_map(schema_size()); \
33 write_impl(builder); \
34 builder.finish_map(); \
36 inline std::string dump(bool pretty, bool yaml) const \
38 mc_rtc::Configuration out; \
40 return out.dump(pretty, yaml); \
42 inline void load(const mc_rtc::Configuration & in) \
44 BaseT::ops_.load(this, in); \
45 ops_.load(this, in); \
47 inline static SchemaT fromConfiguration(const mc_rtc::Configuration & in) \
53 inline void buildForm(mc_rtc::schema::Operations::FormElements & form) const \
55 BaseT::ops_.buildForm(this, form); \
56 ops_.buildForm(this, form); \
58 static inline void formToStd(const mc_rtc::Configuration & in, mc_rtc::Configuration & out) \
60 BaseT::ops_.formToStd(in, out); \
61 ops_.formToStd(in, out); \
63 template<typename Callback = std::function<void()>> \
64 inline void addToGUI( \
65 mc_rtc::gui::StateBuilder & gui, const std::vector<std::string> & category, const std::string & name, \
66 Callback callback = []() {}) \
68 auto form = mc_rtc::gui::Form(name, \
69 [this, callback](const mc_rtc::Configuration & in) \
71 mc_rtc::Configuration cfg; \
78 gui.addElement(category, form); \
80 inline bool operator==(const SchemaT & rhs) const \
81 { return BaseT::ops_.areEqual(this, &rhs) && ops_.areEqual(this, &rhs); } \
82 inline bool operator!=(const SchemaT & rhs) const \
83 { return !(*this == rhs); }
85 #define MC_RTC_NEW_SCHEMA(SchemaT) MC_RTC_SCHEMA(SchemaT, mc_rtc::schema::details::EmptySchema)
88 #define MC_RTC_SCHEMA_MEMBER(T, TYPE, NAME, DESCRIPTION, REQUIRED, DEFAULT, ...) \
90 TYPE NAME = mc_rtc::schema::details::get_default( \
91 DEFAULT, std::integral_constant<mc_rtc::schema::ValueFlag, REQUIRED>{}, ##__VA_ARGS__); \
94 inline static const bool NAME##_registered_ = \
95 T::ops_.registerValue(mc_rtc::schema::details::MemberPointerWrapper<&T::NAME>{}, #NAME, DESCRIPTION, \
96 std::integral_constant<mc_rtc::schema::ValueFlag, REQUIRED>{}, ##__VA_ARGS__); \
101 #define MC_RTC_SCHEMA_REQUIRED_MEMBER(T, TYPE, NAME, DESCRIPTION, DEFAULT, ...) \
102 MC_RTC_PP_ID(MC_RTC_SCHEMA_MEMBER(T, TYPE, NAME, DESCRIPTION, mc_rtc::schema::ValueFlag::All, DEFAULT, ##__VA_ARGS__))
105 #define MC_RTC_SCHEMA_OPTIONAL_MEMBER(T, TYPE, NAME, DESCRIPTION, DEFAULT, ...) \
106 MC_RTC_PP_ID(MC_RTC_SCHEMA_MEMBER(T, TYPE, NAME, DESCRIPTION, mc_rtc::schema::ValueFlag::Interactive, \
107 DEFAULT, ##__VA_ARGS__))
110 #define MC_RTC_SCHEMA_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, REQUIRED, ...) \
111 MC_RTC_PP_ID(MC_RTC_SCHEMA_MEMBER(T, TYPE, NAME, DESCRIPTION, REQUIRED, mc_rtc::Default<TYPE>::value, ##__VA_ARGS__))
114 #define MC_RTC_SCHEMA_REQUIRED_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, ...) \
115 MC_RTC_PP_ID(MC_RTC_SCHEMA_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, mc_rtc::schema::ValueFlag::All, ##__VA_ARGS__))
118 #define MC_RTC_SCHEMA_OPTIONAL_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, ...) \
120 MC_RTC_SCHEMA_DEFAULT_MEMBER(T, TYPE, NAME, DESCRIPTION, mc_rtc::schema::ValueFlag::Interactive, ##__VA_ARGS__))