Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HiveAlgV.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "HiveAlgV.h"
6 #include <vector>
7 
8 HiveAlgV::HiveAlgV( const std::string& name,
9  ISvcLocator* pSvcLocator ) :
10  ::HiveAlgBase( name, pSvcLocator )
11 {}
12 
13 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 HiveAlgV::~HiveAlgV() = default;
15 
16 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18  ATH_MSG_DEBUG("initialize " << name());
19 
20  ATH_CHECK( m_rhv.initialize() );
21  ATH_CHECK( m_whv.initialize() );
22 
23  ATH_MSG_INFO(m_rhv.keys() << " : " << m_rhv.size());
24  ATH_MSG_INFO(m_whv.keys() << " : " << m_whv.size());
25 
26  // initialize base class
27  return HiveAlgBase::initialize ();
28 }
29 
30 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
32 
33  ATH_MSG_DEBUG("execute " << name());
34 
35  sleep();
36 
37  if (m_writeFirst) {
38  ATH_CHECK(write());
39  ATH_CHECK(read());
40  } else {
41  ATH_CHECK(read());
42  ATH_CHECK(write());
43  }
44 
45  return StatusCode::SUCCESS;
46 }
47 
48 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
50 HiveAlgV::read() const {
51  StatusCode sc { StatusCode::SUCCESS };
52  std::vector< SG::ReadHandle<HiveDataObj> > rhv = m_rhv.makeHandles();
53  for (auto &hnd : rhv) {
54  if (!hnd.isValid()) {
55  ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << hnd.key());
56  sc = StatusCode::FAILURE;
57  } else {
58  ATH_MSG_INFO(" read: " << hnd.key() << " = " << hnd->val() );
59  }
60  }
61  return sc;
62 }
63 
64 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
67  std::vector< SG::WriteHandle<HiveDataObj> > whv = m_whv.makeHandles();
68  for (auto &hnd : whv) {
69  ATH_CHECK(hnd.record(std::make_unique<HiveDataObj>( 10101 )));
70  ATH_MSG_INFO(" write: " << hnd.key() << " = " << hnd->val() );
71  }
72  return StatusCode::SUCCESS;
73 }
74 
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HiveAlgV::write
StatusCode write()
Definition: HiveAlgV.cxx:66
HiveAlgBase::sleep
unsigned int sleep()
Definition: HiveAlgBase.cxx:40
HiveAlgBase::initialize
virtual StatusCode initialize() override
Definition: HiveAlgBase.cxx:23
HiveAlgV::initialize
virtual StatusCode initialize() override
Definition: HiveAlgV.cxx:17
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
HiveAlgV::m_whv
SG::WriteHandleKeyArray< HiveDataObj > m_whv
Definition: HiveAlgV.h:44
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HiveAlgV::execute
virtual StatusCode execute() override
Definition: HiveAlgV.cxx:31
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HiveAlgV::~HiveAlgV
~HiveAlgV()
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HiveAlgBase
Definition: HiveAlgBase.h:26
HiveAlgV.h
Simple Algorithm that reads an array of HiveDataObjs, and then writes an array of them.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
HiveAlgV::m_writeFirst
Gaudi::Property< bool > m_writeFirst
Definition: HiveAlgV.h:37
HiveAlgV::m_rhv
SG::ReadHandleKeyArray< HiveDataObj > m_rhv
Definition: HiveAlgV.h:40
HiveAlgV::read
StatusCode read() const
Definition: HiveAlgV.cxx:50
HiveAlgV::HiveAlgV
HiveAlgV(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HiveAlgV.cxx:8