From 5dd012a8e3d886ae6e076fa4bcda4d2c78148e23 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:12:53 +0200 Subject: [PATCH] DPL: add more views on InputSpecs / OutputSpecs / DataProcessors Useful to reduce the amount of lines of code in various manipulation parts. --- .../Core/include/Framework/DataSpecViews.h | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/Framework/Core/include/Framework/DataSpecViews.h b/Framework/Core/include/Framework/DataSpecViews.h index 010d771b07941..0782cefd0f632 100644 --- a/Framework/Core/include/Framework/DataSpecViews.h +++ b/Framework/Core/include/Framework/DataSpecViews.h @@ -18,8 +18,50 @@ namespace o2::framework::views { static auto partial_match_filter(auto what) { - return std::views::filter([&what](auto const& t) -> bool { return DataSpecUtils::partialMatch(t, what); }); + return std::views::filter([what](auto const& t) -> bool { return DataSpecUtils::partialMatch(t, what); }); } + +static auto exclude_by_name(std::string name) +{ + return std::views::filter([name](auto const& t) -> bool { return t.name != name; }); +} + +static auto filter_not_matching(auto const& provided) +{ + 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); }); }); +} + } // namespace o2::framework::views +// +namespace o2::framework::sinks +{ +template +struct append_to { + Container& c; + // ends the pipeline, returns the container + template + friend Container& operator|(R&& r, append_to self) + { + std::ranges::copy(r, std::back_inserter(self.c)); + return self.c; + } +}; + +template +struct update_input_list { + Container& c; + // ends the pipeline, returns the container + template + friend Container& operator|(R&& r, update_input_list self) + { + for (auto& item : r) { + auto copy = item; + DataSpecUtils::updateInputList(self.c, std::move(copy)); + } + return self.c; + } +}; + +} // namespace o2::framework::sinks #endif // O2_FRAMEWORK_DATASPECVIEWS_H_