ATLAS Offline Software
Loading...
Searching...
No Matches
HiveAlgB.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "HiveAlgB.h"
6#include <thread>
7#include <chrono>
8#include <memory>
9
10HiveAlgB::HiveAlgB( const std::string& name,
11 ISvcLocator* pSvcLocator ) :
12 HiveAlgBase( name, pSvcLocator ),
13 m_di(0) {}
14
15HiveAlgB::~HiveAlgB() = default;
16
17/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18
20 ATH_MSG_DEBUG("initialize " << name());
21
22 ATH_MSG_INFO("context: " << Gaudi::Hive::currentContext() << " for "
23 << this );
24
25 ATH_MSG_INFO(" m_di was: " << m_di << " setting to -1 ");
26 m_di = -1;
27
28 // dump out contents of context specific data
29 dump();
30
31 ATH_CHECK( m_wrh1.initialize() );
32
33 // initialize base class
35
36}
37
38/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
39
40StatusCode HiveAlgB::finalize() {
41 ATH_MSG_INFO("context: " << Gaudi::Hive::currentContext());
42 ATH_MSG_DEBUG("finalize " << name());
43
44 // dump out contents of context specific data
45 dump();
46
47 return StatusCode::SUCCESS;
48}
49
50/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
51
52StatusCode HiveAlgB::execute(const EventContext& ctx) const {
53
54 ATH_MSG_DEBUG("execute " << name());
55
56 ATH_MSG_INFO("context: " << ctx << " for " << this);
57
58 int s = sleep();
59
60 ATH_MSG_INFO("m_di was: " << m_di << " setting to " << s);
61 m_di = s;
62
64 ATH_CHECK(wrh1.record(std::make_unique< HiveDataObj >(20000)));
65
66 ATH_MSG_INFO(" write: " << wrh1.key() << " = " << wrh1->val() );
67
68 return StatusCode::SUCCESS;
69
70}
71
72/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
73
74void
76
77 std::ostringstream ost;
78
79 // use a lambda to access all constituents of context specific data
80 m_di.for_all([&ost] (size_t s, const int i)
81 { ost << " s: " << s << " v: " << i << std::endl; } );
82
83 ATH_MSG_INFO("dumping m_di: \n" << ost.str());
84
85}
86
87
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Simple Algorithm that writes a single HiveDataObj to the store.
SG::WriteHandleKey< HiveDataObj > m_wrh1
Definition HiveAlgB.h:42
HiveAlgB(const std::string &name, ISvcLocator *pSvcLocator)
Definition HiveAlgB.cxx:10
virtual StatusCode initialize() override
Definition HiveAlgB.cxx:19
virtual StatusCode execute(const EventContext &ctx) const override
Definition HiveAlgB.cxx:52
virtual StatusCode finalize() override
Definition HiveAlgB.cxx:40
void dump()
Definition HiveAlgB.cxx:75
unsigned int sleep() const
HiveAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.