| The Gaudi Framework v32r1 (f65d50dc)

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