25 static _consteval
auto name() {
return "/describe"; }
26 static _consteval
auto usage() {
return "osc-address-pattern"; }
27 static _consteval
auto description() {
return "Convey metadata about entities that match the given address pattern"; }
30 void describe_entity_type(
auto& log, T& entity)
32 if constexpr (
Bang<T>) log.println(
"bang");
38 log.print(
"array of ");
39 else log.print(
"occasional ");
44 log.print(
"array of ");
45 else log.print(
"persistent ");
47 if constexpr (std::integral<element_t<T>>)
49 else if constexpr (std::floating_point<element_t<T>>)
53 else log.println(
"unknown value type");
55 else if constexpr (
Component<T>) log.println(
"component");
56 else log.println(
"unknown");
60 void describe_entity_value(
auto& log, T& entity)
64 if (flag_state_of(entity)) log.println(
"(! bang !)");
65 else log.println(
"()");
69 if (flag_state_of(entity)) log.println(
"(! ", value_of(entity),
" !)");
70 else log.println(
"(", value_of(entity),
")");
74 if constexpr (tagged_write_only<T>) log.println(
"WRITE ONLY");
76 log.println(
"\"", value_of(entity),
"\"");
77 else log.println(value_of(entity));
81 template<
typename T,
typename Components>
82 void describe_entity(
auto& log,
auto preface, T& entity,
auto ... indents)
84 static_assert(has_name<T>);
85 log.println(indents..., preface, (
const char *)osc_path_v<T, Components>);
86 log.println(indents...,
" name: \"", entity.name(),
"\"");
87 log.print(indents...,
" type: ");
88 describe_entity_type(log, entity);
91 log.print(indents...,
" range: ");
92 auto range = get_range<T>();
93 log.println(range.min,
" to ", range.max,
" (init: ", range.init,
")");
97 log.print(indents...,
" value: ");
98 describe_entity_value(log, entity);
102 auto describe_group = [&](
auto& group,
auto groupname)
104 boost::pfr::for_each_field(group, [&]<
typename Y>(Y& endpoint)
106 describe_entity<Y, Components>(log, groupname, endpoint,
" ", indents...);
109 if constexpr (has_inputs<T>) describe_group(inputs_of(entity),
"input: ");
110 if constexpr (has_outputs<T>) describe_group(outputs_of(entity),
"output: ");
114 template<
typename Components>
115 int main(
int argc,
char** argv,
auto& log, Components& components)
117 if (argc < 2)
return 2;
118 for_each_node(components, [&]<
typename T>(T& node,
auto)
120 if constexpr (has_name<T>)
122 describe_entity<T, Components>(log,
"entity: ", node);
bool osc_match_pattern(const char *pattern, const char *address)
Match an OSC address pattern against the given address.
Definition sygbp-osc_match_pattern.cpp:12