Calls a described function with the arguments an element's attributes give by parameter name.
Arguments are the leading parameters, as in C++: a trailing run may be left to the function's own defaults, which the sidecar's call applies because it calls by name, and a later parameter cannot be given while an earlier one is skipped.
98 {
100 using Result = typename Traits::Result;
101 using Values = typename Traits::Values;
103 constexpr size_t count = Traits::count;
104 constexpr size_t required = Description::required;
105 static_assert(Description::parameters.size() == count, "the sidecar does not describe this function");
106
107 const bool known = Access::for_each_attribute(call, [&](std::string_view name, std::string_view) {
109 || std::ranges::find(Description::parameters, name) != Description::parameters.end()) {
110 return true;
111 }
113 "<" + std::string(Access::name(call)) + "> has an unsupported attribute " + std::string(name)
114 + " for " + std::string(Description::name));
115 return false;
116 });
117 if (!known)
118 return std::nullopt;
119
120 Values values {};
121 std::array<bool, count> given {};
122 bool decoded = true;
123 [&]<size_t... I>(std::index_sequence<I...>) {
125 }(std::make_index_sequence<count> {});
126 if (!decoded)
127 return std::nullopt;
128
129 size_t provided = 0;
130 while (provided < count && given[provided])
131 ++provided;
132 for (
size_t i = provided + 1; i <
count; ++i) {
133 if (given[i]) {
135 std::string(Description::parameters[i]) + " is given without "
136 + std::string(Description::parameters[provided]));
137 return std::nullopt;
138 }
139 }
140 if (provided < required) {
142 std::string(Description::name) + " needs " + std::string(Description::parameters[provided]));
143 return std::nullopt;
144 }
145
146 std::optional<Result> result;
147 [&]<
size_t...
N>(std::index_sequence<
N...>) {
148 ((provided == required +
N
149 ? (result.emplace(Description::template call<required + N>(values)), true)
150 : false)
151 || ...);
152 }(std::make_index_sequence<
count - required + 1> {});
153 return result;
154 }
void error(Component component, Context context, std::source_location location, std::string_view message)
Log an error message and optionally throw an exception.
std::vector< double > count(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Sample count per window (as double for pipeline uniformity).
std::string located_message(uint64_t location, std::string_view message)
A diagnostic message prefixed with the location of the element it concerns.
The parameter names of a described function, which C++ cannot supply itself.