Project
Loading...
Searching...
No Matches
DataSpecViews.h
Go to the documentation of this file.
1// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_DATASPECVIEWS_H_
12#define O2_FRAMEWORK_DATASPECVIEWS_H_
13
15#include <ranges>
16
18{
19static auto partial_match_filter(auto what)
20{
21 return std::views::filter([what](auto const& t) -> bool { return DataSpecUtils::partialMatch(t, what); });
22}
23
24static auto exclude_by_name(std::string name)
25{
26 return std::views::filter([name](auto const& t) -> bool { return t.name != name; });
27}
28
29static 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
34static auto filter_matching(auto const& provided)
35{
36 return std::views::filter([&provided](auto const& input) { return std::any_of(provided.begin(), provided.end(), [&input](auto const& output) { return DataSpecUtils::match(input, output); }); });
37}
38
39static auto filter_string_params_with(std::string match)
40{
41 return std::views::filter([match](auto const& param) {
42 return (param.type == VariantType::String) && (param.name.find(match) != std::string::npos);
43 });
44}
45
46static auto input_to_output_specs()
47{
48 return std::views::transform([](auto const& input) {
49 auto concrete = DataSpecUtils::asConcreteDataMatcher(input);
50 return OutputSpec{concrete.origin, concrete.description, concrete.subSpec, input.lifetime, input.metadata};
51 });
52}
53
54static auto params_to_input_specs()
55{
56 return std::views::transform([](auto const& param) {
57 return DataSpecUtils::fromMetadataString(param.defaultValue.template get<std::string>());
58 });
59}
60} // namespace o2::framework::views
61//
63{
64template <class Container>
65struct append_to {
66 Container& c;
67 // ends the pipeline, returns the container
68 template <std::ranges::input_range R>
69 friend Container& operator|(R&& r, append_to self)
70 {
71 std::ranges::copy(r, std::back_inserter(self.c));
72 return self.c;
73 }
74};
75
76template <class Container>
78 Container& c;
79 // ends the pipeline, returns the container
80 template <std::ranges::input_range R>
81 friend Container& operator|(R&& r, update_input_list self)
82 {
83 for (auto const& item : r) {
84 auto copy = item;
85 DataSpecUtils::updateInputList(self.c, std::move(copy));
86 }
87 return self.c;
88 }
89};
90
91template <class Container>
93 Container& c;
94 // ends the pipeline, returns the container
95 template <std::ranges::input_range R>
96 friend Container& operator|(R&& r, update_output_list self)
97 {
98 for (auto const& item : r) {
99 auto copy = item;
100 DataSpecUtils::updateOutputList(self.c, std::move(copy));
101 }
102 return self.c;
103 }
104};
105
106} // namespace o2::framework::sinks
107
108#endif // O2_FRAMEWORK_DATASPECVIEWS_H_
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
bool match(const std::vector< std::string > &queries, const char *pattern)
Definition dcs-ccdb.cxx:229
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean r
Definition glcorearb.h:1233
GLenum GLfloat param
Definition glcorearb.h:271
template std::string ConfigParamRegistry::get< std::string >(const char *key) const
static bool partialMatch(InputSpec const &spec, o2::header::DataOrigin const &origin)
static InputSpec fromMetadataString(std::string s)
Create an InputSpec from metadata string.
static void updateOutputList(std::vector< OutputSpec > &list, OutputSpec &&input)
Updates list of OutputSpecs by merging metadata (or adding output).
static ConcreteDataMatcher asConcreteDataMatcher(InputSpec const &input)
static void updateInputList(std::vector< InputSpec > &list, InputSpec &&input)
Updates list of InputSpecs by merging metadata.
friend Container & operator|(R &&r, append_to self)
friend Container & operator|(R &&r, update_input_list self)
friend Container & operator|(R &&r, update_output_list self)