| The Gaudi Framework v32r1 (f65d50dc)

FilterPredicate.h
Go to the documentation of this file.
1 #ifndef FILTER_PREDICATE_H
2 #define FILTER_PREDICATE_H
3
4 #include "GaudiAlg/FunctionalDetails.h"
5 #include "GaudiAlg/FunctionalUtilities.h"
6 #include <type_traits>
7 #include <utility>
8
9 namespace Gaudi ::Functional {
10
11 namespace details {
12
13 template <typename T, typename Traits_, bool isLegacy>
14 struct FilterPredicate;
15
16 template <typename... In, typename Traits_>
17 struct FilterPredicate<bool( const In&... ), Traits_, true>
18 : details::DataHandleMixin<void, std::tuple<In...>, Traits_> {
19 using details::DataHandleMixin<void, std::tuple<In...>, Traits_>::DataHandleMixin;
20
21 // derived classes are NOT allowed to implement execute ...
22 StatusCode execute() override final {
23 try {
24 this->setFilterPassed( details::filter_evtcontext_t<In...>::apply( *this, this->m_inputs ) );
25 return StatusCode::SUCCESS;
26 } catch ( GaudiException& e ) {
27 ( e.code() ? this->warning() : this->error() ) << e.message() << endmsg;
28 return e.code();
29 }
30 }
31
32 // ... instead, they must implement the following operator
33 virtual bool operator()( const In&... ) const = 0;
34 };
35
36 template <typename... In, typename Traits_>
37 struct FilterPredicate<bool( const In&... ), Traits_, false>
38 : details::DataHandleMixin<void, std::tuple<In...>, Traits_> {
39 using details::DataHandleMixin<void, std::tuple<In...>, Traits_>::DataHandleMixin;
40
41 // derived classes are NOT allowed to implement execute ...
42 StatusCode execute( const EventContext& ctx ) const override final {
43 try {
44 this->execState( ctx ).setFilterPassed(
45 details::filter_evtcontext_t<In...>::apply( *this, ctx, this->m_inputs ) );
46 return StatusCode::SUCCESS;
47 } catch ( GaudiException& e ) {
48 ( e.code() ? this->warning() : this->error() ) << e.message() << endmsg;
49 return e.code();
50 }
51 }
52
53 // ... instead, they must implement the following operator
54 virtual bool operator()( const In&... ) const = 0;
55 };
56
57 } // namespace details
58
59 template <typename Signature, typename Traits_ = Traits::useDefaults>
60 using FilterPredicate = details::FilterPredicate<Signature, Traits_, details::isLegacy<Traits_>>;
61
62 } // namespace Gaudi::Functional
63
64 #endif
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
GaudiException::message
virtual const std::string & message() const
error message to be printed
Definition: GaudiException.h:58
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi ::Functional::details::FilterPredicate< bool(const In &...), Traits_, false >::execute
StatusCode execute(const EventContext &ctx) const override final
Definition: FilterPredicate.h:42
Gaudi ::Functional::details::FilterPredicate< bool(const In &...), Traits_, true >::execute
StatusCode execute() override final
Definition: FilterPredicate.h:22
EventContext
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
details
Definition: AnyDataWrapper.h:10
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
FunctionalUtilities.h
std::tuple
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:76
Gaudi ::Functional::details::FilterPredicate
Definition: FilterPredicate.h:14
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
FunctionalDetails.h