The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
Algorithms.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#include "FloatTool.h"
15
16namespace Gaudi {
17 namespace TestSuite {
18 using BaseClass_t = Gaudi::Functional::Traits::BaseClass_t<::Algorithm>;
19
20 struct THDataProducer : Gaudi::Functional::Producer<int(), BaseClass_t> {
21
22 THDataProducer( const std::string& name, ISvcLocator* svcLoc )
23 : Producer( name, svcLoc, KeyValue( "OutputLocation", "/Event/MyInt" ) ) {}
24
25 int operator()() const override {
26 info() << "executing IntDataProducer, storing 7 into " << outputLocation() << endmsg;
27 return 7;
28 }
29 };
30
31 DECLARE_COMPONENT( THDataProducer )
32
33 struct THDataProducer2 : Gaudi::Functional::Producer<float(), BaseClass_t> {
34
35 THDataProducer2( const std::string& name, ISvcLocator* svcLoc )
36 : Producer( name, svcLoc, KeyValue( "OutputLocation", "/Event/MyFloat" ) ) {}
37
38 float operator()() const override {
39 info() << "executing IntDataProducer, storing 7.0 into " << outputLocation() << endmsg;
40 return 7.0;
41 }
42 };
43
44 DECLARE_COMPONENT( THDataProducer2 )
45
46 struct THDataConsumer : Gaudi::Functional::Consumer<void( const int& ), BaseClass_t> {
47
48 THDataConsumer( const std::string& name, ISvcLocator* svcLoc )
49 : Consumer( name, svcLoc, KeyValue( "InputLocation", "/Event/MyInt" ) ) {}
50
51 void operator()( const int& input ) const override {
52 info() << "executing IntDataConsumer, checking " << input << " from " << inputLocation() << " and "
53 << m_floatTool->getFloat() << " from FloatTool are matching" << endmsg;
54 }
55
56 ToolHandle<FloatTool> m_floatTool{ this, "FloatTool", "Gaudi::TestSuite::FloatTool" };
57 };
58
59 DECLARE_COMPONENT( THDataConsumer )
60 } // namespace TestSuite
61} // namespace Gaudi
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Handle to be used in lieu of naked pointers to tools.
Definition ToolHandle.h:132
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Definition Producer.h:37
Gaudi::Functional::Traits::BaseClass_t< Gaudi::Algorithm > BaseClass_t
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
THDataConsumer(const std::string &name, ISvcLocator *svcLoc)
ToolHandle< FloatTool > m_floatTool
void operator()(const int &input) const override
float operator()() const override
THDataProducer2(const std::string &name, ISvcLocator *svcLoc)
int operator()() const override
THDataProducer(const std::string &name, ISvcLocator *svcLoc)