Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Producer.h
Go to the documentation of this file.
1 #ifndef GAUDI_FUNCTIONAL_PRODUCER_H
2 #define GAUDI_FUNCTIONAL_PRODUCER_H
3 
6 #include "GaudiKernel/apply.h"
7 #include <utility>
8 
9 namespace Gaudi {
10  namespace Functional {
11 
12  template <typename Signature, typename Traits_ = Traits::useDefaults>
13  class Producer;
14 
15  template <typename... Out, typename Traits_>
16  class Producer<std::tuple<Out...>(), Traits_> : public details::DataHandleMixin<std::tuple<Out...>, void, Traits_> {
17  public:
18  using details::DataHandleMixin<std::tuple<Out...>, void, Traits_>::DataHandleMixin;
19 
20  // derived classes are NOT allowed to implement execute ...
21  StatusCode execute() override final {
22  try {
24  [&]( auto&... ohandle ) {
26  [&ohandle...]( auto&&... data ) {
27 #if __cplusplus < 201703L
28  (void)std::initializer_list<int>{
29  ( details::put( ohandle, std::forward<decltype( data )>( data ) ), 0 )...};
30 #else
31  ( details::put( ohandle, std::forward<decltype( data )>( data ) ), ... );
32 #endif
33  },
34  details::as_const( *this )() );
35  },
36  this->m_outputs );
37  } catch ( GaudiException& e ) {
38  ( e.code() ? this->warning() : this->error() ) << e.message() << endmsg;
39  return e.code();
40  }
41  return StatusCode::SUCCESS;
42  }
43 
44  // ... instead, they must implement the following operator
45  virtual std::tuple<Out...> operator()() const = 0;
46  };
47 
48  template <typename Out, typename Traits_>
49  class Producer<Out(), Traits_> : public details::DataHandleMixin<std::tuple<Out>, void, Traits_> {
50  public:
51  using details::DataHandleMixin<std::tuple<Out>, void, Traits_>::DataHandleMixin;
52  // derived classes are NOT allowed to implement execute ...
53  StatusCode execute() override final {
54  try {
55  details::put( std::get<0>( this->m_outputs ), details::as_const( *this )() );
56  } catch ( GaudiException& e ) {
57  ( e.code() ? this->warning() : this->error() ) << e.message() << endmsg;
58  return e.code();
59  }
60  return StatusCode::SUCCESS;
61  }
62 
63  // ... instead, they must implement the following operator
64  virtual Out operator()() const = 0;
65  };
66  } // namespace Functional
67 } // namespace Gaudi
68 
69 #endif
virtual const std::string & message() const
error message to be printed
Define general base for Gaudi exception.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
STL namespace.
class MergingTransformer< Out(const vector_of_const_< In > void
decltype(auto) constexpr apply(F &&f, Tuple &&t) noexcept(noexcept( detail::apply_impl(std::forward< F >(f), std::forward< Tuple >(t), std::make_index_sequence< std::tuple_size< std::remove_reference_t< Tuple >>::value >{})))
Definition: apply.h:27
virtual const StatusCode & code() const
StatusCode for Exception.
StatusCode execute() override final
Definition: Producer.h:53
class MergingTransformer< Out(const vector_of_const_< In > Traits_
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
constexpr std::add_const_t< T > & as_const(T &t) noexcept
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
T forward(T...args)
Helper functions to set/get the application return code.
Definition: __init__.py:1
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)