Project
Loading...
Searching...
No Matches
CompletionPolicyHelpers.h
Go to the documentation of this file.
1// Copyright 2019-2020 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_COMPLETIONPOLICYHELPERS_H_
12#define O2_FRAMEWORK_COMPLETIONPOLICYHELPERS_H_
13
16#include "Headers/DataHeader.h"
17
18#include <functional>
19#include <string>
20#include <type_traits>
21
22namespace o2::framework
23{
24
30 static CompletionPolicy consumeWhenAll(CompletionPolicy::Matcher matcher = [](auto const&) -> bool { return true; })
31 {
32 return consumeWhenAll("consume-all", matcher);
33 }
34
38 static CompletionPolicy consumeWhenAllOrdered(CompletionPolicy::Matcher matcher = [](auto const&) -> bool { return true; })
39 {
40 return consumeWhenAllOrdered("consume-all-ordered", matcher);
41 }
42 static CompletionPolicy consumeWhenAllOrdered(std::string matchName);
43
47 static CompletionPolicy consumeWhenAny(CompletionPolicy::Matcher matcher = [](auto const&) -> bool { return true; })
48 {
49 return consumeWhenAny("consume-any", matcher);
50 }
51 static CompletionPolicy consumeWhenAny(std::string matchName);
52
56 static CompletionPolicy consumeWhenAnyWithAllConditions(CompletionPolicy::Matcher matcher = [](auto const&) -> bool { return true; })
57 {
58 return consumeWhenAnyWithAllConditions("consume-any-all-conditions", matcher);
59 }
60 static CompletionPolicy consumeWhenAnyWithAllConditions(std::string matchName);
61
66
71 static CompletionPolicy processWhenAny(CompletionPolicy::Matcher matcher = [](auto const&) -> bool { return true; })
72 {
73 return processWhenAny("process-any", matcher);
74 }
78 static CompletionPolicy defineByNameOrigin(std::string const& name, std::string const& origin, CompletionPolicy::CompletionOp op);
80 template <typename T, typename U>
81 static auto getHeader(U const& input)
82 {
83 // DataHeader interface requires to specify header pointer type, need to check if the template parameter
84 // is already pointer type, and add pointer if not
85 using return_type = typename std::conditional<std::is_pointer<T>::value, T, typename std::add_pointer<T>::type>::type;
86 return o2::header::get<return_type>(input.header);
87 }
88};
89
90} // namespace o2::framework
91
92#endif // O2_FRAMEWORK_COMPLETIONPOLICYHELPERS_H_
uint32_t op
GLuint const GLchar * name
Definition glcorearb.h:781
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
Helper class which holds commonly used policies.
static CompletionPolicy processWhenAny(const char *name, CompletionPolicy::Matcher matcher)
static CompletionPolicy consumeWhenAny(CompletionPolicy::Matcher matcher=[](auto const &) -> bool { return true;})
Default matcher applies for all devices.
static CompletionPolicy consumeWhenAllOrdered(const char *name, CompletionPolicy::Matcher matcher)
as consumeWhenAll, but ensures that records are processed with incremental timeSlice (DataHeader::sta...
static CompletionPolicy defineByName(std::string const &name, CompletionPolicy::CompletionOp op)
static CompletionPolicy consumeExistingWhenAny(const char *name, CompletionPolicy::Matcher matcher)
static CompletionPolicy consumeWhenAll(const char *name, CompletionPolicy::Matcher matcher)
Default Completion policy. When all the parts of a record have arrived, consume them.
static CompletionPolicy consumeWhenAnyWithAllConditions(const char *name, CompletionPolicy::Matcher matcher)
When any of the parts of the record have been received, consume them.
static CompletionPolicy consumeWhenAll(CompletionPolicy::Matcher matcher=[](auto const &) -> bool { return true;})
Default matcher applies for all devices.
static CompletionPolicy consumeWhenAnyWithAllConditions(CompletionPolicy::Matcher matcher=[](auto const &) -> bool { return true;})
Default matcher applies for all devices.
static CompletionPolicy defineByNameOrigin(std::string const &name, std::string const &origin, CompletionPolicy::CompletionOp op)
static CompletionPolicy consumeWhenAny(const char *name, CompletionPolicy::Matcher matcher)
When any of the parts of the record have been received, consume them.
static CompletionPolicy consumeWhenAllOrdered(CompletionPolicy::Matcher matcher=[](auto const &) -> bool { return true;})
Default matcher applies for all devices.
static CompletionPolicy processWhenAny(CompletionPolicy::Matcher matcher=[](auto const &) -> bool { return true;})
Default matcher applies for all devices.
static auto getHeader(U const &input)
Get a specific header from the input.
CompletionOp
Action to take with the InputRecord:
std::function< bool(DeviceSpec const &device)> Matcher