Skip to content

Commit 6c35d65

Browse files
authored
DPL: add more views on InputSpecs / OutputSpecs / DataProcessors (#14588)
Useful to reduce the amount of lines of code in various manipulation parts.
1 parent dce7e0e commit 6c35d65

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

Framework/Core/include/Framework/DataSpecViews.h

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,50 @@ namespace o2::framework::views
1818
{
1919
static auto partial_match_filter(auto what)
2020
{
21-
return std::views::filter([&what](auto const& t) -> bool { return DataSpecUtils::partialMatch(t, what); });
21+
return std::views::filter([what](auto const& t) -> bool { return DataSpecUtils::partialMatch(t, what); });
2222
}
23+
24+
static auto exclude_by_name(std::string name)
25+
{
26+
return std::views::filter([name](auto const& t) -> bool { return t.name != name; });
27+
}
28+
29+
static auto filter_not_matching(auto const& provided)
30+
{
31+
return std::views::filter([&provided](auto const& input) { return std::none_of(provided.begin(), provided.end(), [&input](auto const& output) { return DataSpecUtils::match(input, output); }); });
32+
}
33+
2334
} // namespace o2::framework::views
35+
//
36+
namespace o2::framework::sinks
37+
{
38+
template <class Container>
39+
struct append_to {
40+
Container& c;
41+
// ends the pipeline, returns the container
42+
template <std::ranges::input_range R>
43+
friend Container& operator|(R&& r, append_to self)
44+
{
45+
std::ranges::copy(r, std::back_inserter(self.c));
46+
return self.c;
47+
}
48+
};
49+
50+
template <class Container>
51+
struct update_input_list {
52+
Container& c;
53+
// ends the pipeline, returns the container
54+
template <std::ranges::input_range R>
55+
friend Container& operator|(R&& r, update_input_list self)
56+
{
57+
for (auto& item : r) {
58+
auto copy = item;
59+
DataSpecUtils::updateInputList(self.c, std::move(copy));
60+
}
61+
return self.c;
62+
}
63+
};
64+
65+
} // namespace o2::framework::sinks
2466

2567
#endif // O2_FRAMEWORK_DATASPECVIEWS_H_

0 commit comments

Comments
 (0)