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(" m_di was: " << m_di << " setting to -1 ");
23 m_di = -1;
24
25 // dump out contents of context specific data
26 dump();
27
28 ATH_CHECK( m_wrh1.initialize() );
29
30 // initialize base class
32
33}
34
35/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
36
37StatusCode HiveAlgB::finalize() {
38 ATH_MSG_DEBUG("finalize " << name());
39
40 // dump out contents of context specific data
41 dump();
42
43 return StatusCode::SUCCESS;
44}
45
46/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
47
48StatusCode HiveAlgB::execute(const EventContext& ctx) const {
49
50 ATH_MSG_DEBUG("execute " << name());
51
52 ATH_MSG_INFO("context: " << ctx << " for " << this);
53
54 int s = sleep(ctx);
55
56 ATH_MSG_INFO("m_di was: " << m_di << " setting to " << s);
57 m_di = s;
58
60 ATH_CHECK(wrh1.record(std::make_unique< HiveDataObj >(20000)));
61
62 ATH_MSG_INFO(" write: " << wrh1.key() << " = " << wrh1->val() );
63
64 return StatusCode::SUCCESS;
65
66}
67
68/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
69
70void
72
73 std::ostringstream ost;
74
75 // use a lambda to access all constituents of context specific data
76 m_di.for_all([&ost] (size_t s, const int i)
77 { ost << " s: " << s << " v: " << i << std::endl; } );
78
79 ATH_MSG_INFO("dumping m_di: \n" << ost.str());
80
81}
82
83
#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:48
virtual StatusCode finalize() override
Definition HiveAlgB.cxx:37
void dump()
Definition HiveAlgB.cxx:71
HiveAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
unsigned int sleep(const EventContext &ctx) const
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.