The Gaudi Framework  master (e98cfcff)
Loading...
Searching...
No Matches
Transformer.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
13#include "details.h"
14#include "utilities.h"
15#include <tuple>
16
17// Adapt an Algorithm (by default, Gaudi::Algorithm) so that derived classes
18// a) do not need to access the event store, and have to explicitly
19// state their data dependencies
20// b) are encouraged not to have state which depends on the events
21// (eg. histograms, counters will have to be mutable)
22
23namespace Gaudi ::Functional {
24
25 namespace details {
26
27 template <typename Signature, typename Traits_, bool isLegacy>
29
30 template <typename Signature, typename Traits_, bool isLegacy>
32
33 // general N -> 1 algorithms
34 template <typename Out, typename... In, typename Traits_>
35 struct Transformer<Out( const In&... ), Traits_, true>
36 : DataHandleMixin<type_list<Out>, type_list<In...>, Traits_> {
37 using DataHandleMixin<type_list<Out>, type_list<In...>, Traits_>::DataHandleMixin;
38
39 // derived classes can NOT implement execute
40 StatusCode execute() override final {
41 return execute_single_output( *this, this->getContext(), this->m_outputs );
42 }
43
44 // instead they MUST implement this operator
45 virtual Out operator()( const In&... ) const = 0;
46 };
47
48 template <typename Out, typename... In, typename Traits_>
49 struct Transformer<Out( const In&... ), Traits_, false>
50 : DataHandleMixin<type_list<Out>, type_list<In...>, Traits_> {
51 using DataHandleMixin<type_list<Out>, type_list<In...>, Traits_>::DataHandleMixin;
52
53 // derived classes can NOT implement execute
54 StatusCode execute( const EventContext& ctx ) const override final {
55 return execute_single_output( *this, ctx, this->m_outputs );
56 }
57
58 // instead they MUST implement this operator
59 virtual Out operator()( const In&... ) const = 0;
60 };
61
62 //
63 // general N -> M algorithms
64 //
65 template <typename... Out, typename... In, typename Traits_>
66 struct MultiTransformer<std::tuple<Out...>( const In&... ), Traits_, true>
67 : DataHandleMixin<type_list<Out...>, type_list<In...>, Traits_> {
68 using DataHandleMixin<type_list<Out...>, type_list<In...>, Traits_>::DataHandleMixin;
69
70 // derived classes can NOT implement execute
71 StatusCode execute() override final { return execute_outputs( *this, this->getContext(), this->m_outputs ); }
72
73 // instead they MUST implement this operator
74 virtual std::tuple<Out...> operator()( const In&... ) const = 0;
75 };
76
77 template <typename... Out, typename... In, typename Traits_>
78 struct MultiTransformer<std::tuple<Out...>( const In&... ), Traits_, false>
79 : DataHandleMixin<type_list<Out...>, type_list<In...>, Traits_> {
80 using DataHandleMixin<type_list<Out...>, type_list<In...>, Traits_>::DataHandleMixin;
81
82 // derived classes can NOT implement execute
83 StatusCode execute( const EventContext& ctx ) const override final {
84 return execute_outputs( *this, ctx, this->m_outputs );
85 }
86
87 // instead they MUST implement this operator
88 virtual std::tuple<Out...> operator()( const In&... ) const = 0;
89 };
90
91 //
92 // general N -> M algorithms with filter functionality
93 //
94 template <typename Signature, typename Traits_>
96
97 template <typename... Out, typename... In, typename Traits_>
98 struct MultiTransformerFilter<std::tuple<Out...>( const In&... ), Traits_>
99 : DataHandleMixin<type_list<Out...>, type_list<In...>, Traits_> {
100 using DataHandleMixin<type_list<Out...>, type_list<In...>, Traits_>::DataHandleMixin;
101
102 // derived classes can NOT implement execute
103 StatusCode execute( const EventContext& ctx ) const override final {
104 return execute_filtered_outputs( *this, ctx, this->m_outputs );
105 }
106
107 // instead they MUST implement this operator
108 virtual std::tuple<bool, Out...> operator()( const In&... ) const = 0;
109 };
110 } // namespace details
111
112 template <typename Signature, typename Traits_ = Traits::useDefaults>
114
115 template <typename Signature, typename Traits_ = Traits::useDefaults>
117
118 template <typename Signature, typename Traits_ = Traits::useDefaults>
120
121} // namespace Gaudi::Functional
This class represents an entry point to all the event specific data.
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
details::MultiTransformer< Signature, Traits_, details::isLegacy< Traits_ > > MultiTransformer
details::Transformer< Signature, Traits_, details::isLegacy< Traits_ > > Transformer
details::MultiTransformerFilter< Signature, Traits_ > MultiTransformerFilter
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
STL namespace.
StatusCode execute(const EventContext &ctx) const override final
Definition Transformer.h:54