The Gaudi Framework  v32r2 (46d42edc)
Consumer.h
Go to the documentation of this file.
1 #ifndef GAUDI_FUNCTIONAL_CONSUMER_H
2 #define GAUDI_FUNCTIONAL_CONSUMER_H
3 
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> : DataHandleMixin<void, filter_evtcontext<In...>, Traits_> {
17  using DataHandleMixin<void, filter_evtcontext<In...>, Traits_>::DataHandleMixin;
18 
19  // derived classes are NOT allowed to implement execute ...
20  StatusCode execute() override final {
21  try {
22  filter_evtcontext_t<In...>::apply( *this, this->m_inputs );
23  return StatusCode::SUCCESS;
24  } catch ( GaudiException& e ) {
25  ( e.code() ? this->warning() : this->error() ) << e.message() << endmsg;
26  return e.code();
27  }
28  }
29 
30  // ... instead, they must implement the following operator
31  virtual void operator()( const In&... ) const = 0;
32  };
33 
34  template <typename... In, typename Traits_>
35  struct Consumer<void( const In&... ), Traits_, false> : DataHandleMixin<void, filter_evtcontext<In...>, Traits_> {
36  using DataHandleMixin<void, filter_evtcontext<In...>, Traits_>::DataHandleMixin;
37 
38  // derived classes are NOT allowed to implement execute ...
39  StatusCode execute( const EventContext& ctx ) const override final {
40  try {
41  filter_evtcontext_t<In...>::apply( *this, ctx, this->m_inputs );
42  return StatusCode::SUCCESS;
43  } catch ( GaudiException& e ) {
44  ( e.code() ? this->warning() : this->error() ) << e.message() << endmsg;
45  return e.code();
46  }
47  }
48 
49  // ... instead, they must implement the following operator
50  virtual void operator()( const In&... ) const = 0;
51  };
52 
53  } // namespace details
54 
55  template <typename Signature, typename Traits_ = Traits::useDefaults>
57 
58 } // namespace Gaudi::Functional
59 
60 #endif
Define general base for Gaudi exception.
virtual const std::string & message() const
error message to be printed
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
typename filter_evtcontext_t< In... >::type filter_evtcontext
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual const StatusCode & code() const
StatusCode for Exception.
StatusCode execute(const EventContext &ctx) const override final
Definition: Consumer.h:39
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192