| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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 <utility>
5 #include "GaudiAlg/FunctionalDetails.h"
6 #include "GaudiAlg/FunctionalUtilities.h"
7
8 namespace Gaudi { namespace Functional {
9
10 template <typename Signature, typename Traits_ = Traits::useDefaults> class Producer;
11
12 template <typename... Out, typename Traits_>
13 class Producer<std::tuple<Out...>(), Traits_>
14 : public details::DataHandleMixin<std::tuple<Out...>,void,Traits_> {
15 public:
16 using details::DataHandleMixin<std::tuple<Out...>,void,Traits_>::DataHandleMixin;
17
18 // derived classes are NOT allowed to implement execute ...
19 StatusCode execute() override final
20 { return invoke(std::index_sequence_for<Out...>{}); }
21
22 // ... instead, they must implement the following operator
23 virtual std::tuple<Out...> operator()() const = 0;
24
25 private:
26 template <std::size_t... O>
27 StatusCode invoke(std::index_sequence<O...>) {
28 using details::as_const; using details::put;
29 try {
30 std::initializer_list<int> {
31 (put(std::get<O>(this->m_outputs),std::get<O>( as_const(*this)() )),0)...
32 };
33 } catch ( GaudiException& e ) {
34 (e.code() ? this->warning() : this->error() )
35 << e.message() << endmsg;
36 return e.code();
37 }
38 return StatusCode::SUCCESS;
39 }
40 };
41
42 template <typename Out, typename Traits_>
43 class Producer<Out(),Traits_>
44 : public details::DataHandleMixin<std::tuple<Out>,void,Traits_> {
45 public:
46 using details::DataHandleMixin<std::tuple<Out>,void,Traits_>::DataHandleMixin;
47 // derived classes are NOT allowed to implement execute ...
48 StatusCode execute() override final {
49 using details::as_const; using details::put;
50 try {
51 put(std::get<0>(this->m_outputs),as_const(*this)() );
52 } catch ( GaudiException& e ) {
53 this->error() << "Error during transform: " << e.message() << " returning " << e.code() << endmsg;
54 return e.code();
55 }
56 return StatusCode::SUCCESS;
57 }
58
59 // ... instead, they must implement the following operator
60 virtual Out operator()() const = 0;
61 };
62 }}
63
64 #endif
GaudiException::message
virtual const std::string & message() const
error message to be printed
Definition: GaudiException.h:111
StatusCode::SUCCESS
Definition: StatusCode.h:30
Gaudi::Functional::details::as_const
constexpr std::add_const< T >::type & as_const(T &t) noexcept
Definition: FunctionalDetails.h:77
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
std
STL namespace.
Gaudi::Functional::void
class MergingTransformer< Out(const vector_of_const_< In > void
Definition: MergingTransformer.h:19
std::size_t
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:127
Gaudi::Functional::Producer< Out(), Traits_ >::execute
StatusCode execute() override final
Definition: Producer.h:48
Gaudi::Functional::details::DataHandleMixin
Definition: FunctionalDetails.h:317
Gaudi::Functional::Traits_
class MergingTransformer< Out(const vector_of_const_< In > Traits_
Definition: MergingTransformer.h:19
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
FunctionalUtilities.h
std::tuple
Gaudi::Functional::Producer< std::tuple< Out... >(), Traits_ >::execute
StatusCode execute() override final
Definition: Producer.h:19
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:27
Gaudi::Functional::Producer
Definition: Producer.h:10
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:244
std::initializer_list
Gaudi::Functional::details::put
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)
Definition: FunctionalDetails.h:87
FunctionalDetails.h