File indexing completed on 2025-01-30 10:07:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #pragma once
0012
0013 #include "details.h"
0014 #include "utilities.h"
0015 #include <GaudiKernel/FunctionalFilterDecision.h>
0016 #include <type_traits>
0017 #include <utility>
0018
0019 namespace Gaudi::Functional {
0020
0021 namespace details {
0022
0023 template <typename T, typename Traits_, bool isLegacy>
0024 struct FilterPredicate;
0025
0026 template <typename... In, typename Traits_>
0027 struct FilterPredicate<bool( const In&... ), Traits_, true>
0028 : DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_> {
0029 using DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_>::DataHandleMixin;
0030
0031
0032 StatusCode execute() override final {
0033 try {
0034 return filter_evtcontext_t<In...>::apply( *this, this->m_inputs ) ? FilterDecision::PASSED
0035 : FilterDecision::FAILED;
0036 } catch ( GaudiException& e ) {
0037 if ( e.code().isFailure() ) this->error() << e.tag() << " : " << e.message() << endmsg;
0038 return e.code();
0039 }
0040 }
0041
0042
0043 virtual bool operator()( const In&... ) const = 0;
0044 };
0045
0046 template <typename... In, typename Traits_>
0047 struct FilterPredicate<bool( const In&... ), Traits_, false>
0048 : DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_> {
0049 using DataHandleMixin<std::tuple<>, filter_evtcontext<In...>, Traits_>::DataHandleMixin;
0050
0051
0052 StatusCode execute( const EventContext& ctx ) const override final {
0053 try {
0054 return filter_evtcontext_t<In...>::apply( *this, ctx, this->m_inputs ) ? FilterDecision::PASSED
0055 : FilterDecision::FAILED;
0056 } catch ( GaudiException& e ) {
0057 if ( e.code().isFailure() ) this->error() << e.tag() << " : " << e.message() << endmsg;
0058 return e.code();
0059 }
0060 }
0061
0062
0063 virtual bool operator()( const In&... ) const = 0;
0064 };
0065
0066 }
0067
0068 template <typename Signature, typename Traits_ = Traits::useDefaults>
0069 using FilterPredicate = details::FilterPredicate<Signature, Traits_, details::isLegacy<Traits_>>;
0070
0071 }