The Gaudi Framework  master (48d4dc99)
Loading...
Searching...
No Matches
SplittingTransformer.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"
16#include <optional>
17#include <string>
18#include <vector>
19
20namespace Gaudi::Functional {
21
22 template <typename Container>
23 using vector_of_ = std::vector<Container>;
24 template <typename Container>
25 using vector_of_optional_ = std::vector<std::optional<Container>>;
26
27 namespace details {
28
29 template <typename Signature, typename Traits_>
31
32 template <typename Out, typename... In, typename Traits_>
33 class SplittingTransformer<vector_of_<Out>( const In&... ), Traits_>
34 : public details::DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_> {
36
37 template <typename T>
40
41 public:
42 constexpr static std::size_t N = base_class::N_in;
43 using KeyValue = typename base_class::KeyValue;
44 using KeyValues = typename base_class::KeyValues;
45
46 SplittingTransformer( std::string name, ISvcLocator* locator, const RepeatValues_<KeyValue, N>& inputs,
47 const KeyValues& outputs )
48 : base_class{ std::move( name ), locator, inputs }, m_outs{ this, outputs } {}
49
50 SplittingTransformer( std::string name, ISvcLocator* locator, const KeyValue& input, const KeyValues& output )
51 requires( N == 1 )
52 : SplittingTransformer( std::move( name ), locator, std::forward_as_tuple( input ), output ) {}
53
54 // accessor to output Locations
55 const std::string& outputLocation( unsigned int n ) const { return m_outs.at( n ).key(); }
56 unsigned int outputLocationSize() const { return m_outs.size(); }
57
58 // derived classes can NOT implement execute
59 StatusCode execute( const EventContext& ctx ) const override final {
60 return details::execute( *this, [&] {
61 // TODO:FIXME: how does operator() know the number and order of expected outputs?
62 m_outs.put( details::filter_evtcontext_t<In...>::apply( *this, ctx, this->m_inputs ) );
64 } );
65 }
66
67 // TODO/FIXME: how does the callee know in which order to produce the outputs?
68 // (note: 'missing' items can be specified by making Out an std::optional<Out>,
69 // and only those entries which contain an Out are stored)
70 virtual vector_of_<Out> operator()( const In&... ) const = 0;
71 };
72
73 } // namespace details
74
75 template <typename Signature, typename Traits_ = Traits::useDefaults>
77
78} // namespace Gaudi::Functional
This class represents an entry point to all the event specific data.
details::DataHandleMixin< std::tuple<>, filter_evtcontext< In... >, Traits_ > base_class
SplittingTransformer(std::string name, ISvcLocator *locator, const RepeatValues_< KeyValue, N > &inputs, const KeyValues &outputs)
details::OutputHandle_t< Traits_, details::remove_optional_t< T > > OutputHandle
SplittingTransformer(std::string name, ISvcLocator *locator, const KeyValue &input, const KeyValues &output)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
typename detail2::OutputHandle< T, Tr, DataObjectWriteHandle >::type OutputHandle_t
Definition details.h:491
decltype(get_values_helper< Value >(std::make_index_sequence< N >())) RepeatValues_
Definition details.h:98
StatusCode execute(CommonMessagingBase const &alg, F &&f)
Definition details.h:429
typename filter_evtcontext_t< In... >::type filter_evtcontext
Definition details.h:549
details::SplittingTransformer< Signature, Traits_ > SplittingTransformer
std::vector< Container > vector_of_
std::vector< std::optional< Container > > vector_of_optional_
STL namespace.
static auto apply(const Algorithm &algo, const EventContext &ctx, Handles &handles)
Definition details.h:529