Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:29

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #pragma once
0012 
0013 #include "details.h"
0014 #include "utilities.h"
0015 #include <GaudiKernel/FunctionalFilterDecision.h>
0016 #include <utility>
0017 
0018 namespace Gaudi::Functional {
0019 
0020   namespace details {
0021 
0022     template <typename Signature, typename Traits_, bool isLegacy>
0023     struct Consumer;
0024 
0025     template <typename... In, typename Traits_>
0026     struct Consumer<void( const In&... ), Traits_, true>
0027         : DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_> {
0028       using DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_>::DataHandleMixin;
0029 
0030       // derived classes are NOT allowed to implement execute ...
0031       StatusCode execute() override final {
0032         try {
0033           filter_evtcontext_t<In...>::apply( *this, this->m_inputs );
0034           return FilterDecision::PASSED;
0035         } catch ( GaudiException& e ) {
0036           if ( e.code().isFailure() ) this->error() << e.tag() << " : " << e.message() << endmsg;
0037           return e.code();
0038         }
0039       }
0040 
0041       // ... instead, they must implement the following operator
0042       virtual void operator()( const In&... ) const = 0;
0043     };
0044 
0045     template <typename... In, typename Traits_>
0046     struct Consumer<void( const In&... ), Traits_, false>
0047         : DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_> {
0048       using DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_>::DataHandleMixin;
0049 
0050       // derived classes are NOT allowed to implement execute ...
0051       StatusCode execute( const EventContext& ctx ) const override final {
0052         try {
0053           filter_evtcontext_t<In...>::apply( *this, ctx, this->m_inputs );
0054           return FilterDecision::PASSED;
0055         } catch ( GaudiException& e ) {
0056           if ( e.code().isFailure() ) this->error() << e.tag() << " : " << e.message() << endmsg;
0057           return e.code();
0058         }
0059       }
0060 
0061       // ... instead, they must implement the following operator
0062       virtual void operator()( const In&... ) const = 0;
0063     };
0064 
0065   } // namespace details
0066 
0067   template <typename Signature, typename Traits_ = Traits::useDefaults>
0068   using Consumer = details::Consumer<Signature, Traits_, details::isLegacy<Traits_>>;
0069 
0070 } // namespace Gaudi::Functional