| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Producer.h
Go to the documentation of this file.
1 #ifndef GAUDI_FUNCTIONAL_PRODUCER_H
2 #define GAUDI_FUNCTIONAL_PRODUCER_H
3
4 #include "GaudiAlg/FunctionalDetails.h"
5 #include "GaudiAlg/FunctionalUtilities.h"
6 #include <utility>
7
8 namespace Gaudi
9 {
10 namespace Functional
11 {
12
13 template <typename Signature, typename Traits_ = Traits::useDefaults>
14 class Producer;
15
16 template <typename... Out, typename Traits_>
17 class Producer<std::tuple<Out...>(), Traits_> : public details::DataHandleMixin<std::tuple<Out...>, void, Traits_>
18 {
19 public:
20 using details::DataHandleMixin<std::tuple<Out...>, void, Traits_>::DataHandleMixin;
21
22 // derived classes are NOT allowed to implement execute ...
23 StatusCode execute() override final { return invoke( std::index_sequence_for<Out...>{} ); }
24
25 // ... instead, they must implement the following operator
26 virtual std::tuple<Out...> operator()() const = 0;
27
28 private:
29 template <std::size_t... O>
30 StatusCode invoke( std::index_sequence<O...> )
31 {
32 using details::as_const;
33 using details::put;
34 try {
35 std::initializer_list<int>{
36 ( put( std::get<O>( this->m_outputs ), std::get<O>( as_const( *this )() ) ), 0 )...};
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
45 template <typename Out, typename Traits_>
46 class Producer<Out(), Traits_> : public details::DataHandleMixin<std::tuple<Out>, void, Traits_>
47 {
48 public:
49 using details::DataHandleMixin<std::tuple<Out>, void, Traits_>::DataHandleMixin;
50 // derived classes are NOT allowed to implement execute ...
51 StatusCode execute() override final
52 {
53 using details::as_const;
54 using details::put;
55 try {
56 put( std::get<0>( this->m_outputs ), as_const( *this )() );
57 } catch ( GaudiException& e ) {
58 this->error() << "Error during transform: " << e.message() << " returning " << e.code() << endmsg;
59 return e.code();
60 }
61 return StatusCode::SUCCESS;
62 }
63
64 // ... instead, they must implement the following operator
65 virtual Out operator()() const = 0;
66 };
67 }
68 }
69
70 #endif
GaudiException::message
virtual const std::string & message() const
error message to be printed
Definition: GaudiException.h:99
StatusCode::SUCCESS
Definition: StatusCode.h:31
Gaudi::Functional::details::as_const
constexpr std::add_const< T >::type & as_const(T &t) noexcept
Definition: FunctionalDetails.h:104
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
std
STL namespace.
Gaudi::Functional::void
class MergingTransformer< Out(const vector_of_const_< In > void
Definition: MergingTransformer.h:23
std::size_t
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:119
Gaudi::Functional::Producer< Out(), Traits_ >::execute
StatusCode execute() override final
Definition: Producer.h:51
Gaudi::Functional::details::DataHandleMixin
Definition: FunctionalDetails.h:438
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
FunctionalUtilities.h
std::tuple
Gaudi::Functional::Producer< std::tuple< Out... >(), Traits_ >::execute
StatusCode execute() override final
Definition: Producer.h:23
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
Gaudi::Functional::Producer< std::tuple< Out... >(), Traits_ >::invoke
StatusCode invoke(std::index_sequence< O... >)
Definition: Producer.h:30
Gaudi::Functional::Traits_
struct[[deprecated("use MergingTransformer instead")]] Traits_
Definition: ListTransformer.h:14
Gaudi::invoke
auto invoke(F &&f, ArgTypes &&...args) noexcept(noexcept(detail2::INVOKE(std::forward< F >(f), std::forward< ArgTypes >(args)...))) -> decltype(detail2::INVOKE(std::forward< F >(f), std::forward< ArgTypes >(args)...))
Definition: invoke.h:83
Gaudi::Functional::Producer
Definition: Producer.h:14
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
std::initializer_list
Gaudi::Functional::details::put
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)
Definition: FunctionalDetails.h:116
FunctionalDetails.h