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 filter_string_params_starts_with(std::string match)
47{
48 return std::views::filter([match](auto const& param) {
49 return (param.type == VariantType::String) && (param.name.starts_with(match));
50 });
51}
52
53static auto input_to_output_specs()
54{
55 return std::views::transform([](auto const& input) {
56 auto concrete = DataSpecUtils::asConcreteDataMatcher(input);
57 return OutputSpec{concrete.origin, concrete.description, concrete.subSpec, input.lifetime, input.metadata};
58 });
59}
60
61static auto params_to_input_specs()
62{
63 return std::views::transform([](auto const& param) {
64 return DataSpecUtils::fromMetadataString(param.defaultValue.template get<std::string>());
65 });
66}
67} // namespace o2::framework::views
68//
70{
71template <class Container>
72struct append_to {
73 Container& c;
74 // ends the pipeline, returns the container
75 template <std::ranges::input_range R>
76 friend Container& operator|(R&& r, append_to self)
77 {
78 std::ranges::copy(r, std::back_inserter(self.c));
79 return self.c;
80 }
81};
82
83template <class Container>
85 Container& c;
86 // ends the pipeline, returns the container
87 template <std::ranges::input_range R>
88 friend Container& operator|(R&& r, update_input_list self)
89 {
90 for (auto const& item : r) {
91 auto copy = item;
92 DataSpecUtils::updateInputList(self.c, std::move(copy));
93 }
94 return self.c;
95 }
96};
97
98template <class Container>
100 Container& c;
101 // ends the pipeline, returns the container
102 template <std::ranges::input_range R>
103 friend Container& operator|(R&& r, update_output_list self)
104 {
105 for (auto const& item : r) {
106 auto copy = item;
107 DataSpecUtils::updateOutputList(self.c, std::move(copy));
108 }
109 return self.c;
110 }
111};
112
113} // namespace o2::framework::sinks
114
115#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)