ATLAS Offline Software
HiveAlgV.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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  ATH_MSG_DEBUG("finalize " << name());
33  return StatusCode::SUCCESS;
34 }
35 
36 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
38 
39  ATH_MSG_DEBUG("execute " << name());
40 
41  sleep();
42 
43  if (m_writeFirst) {
44  ATH_CHECK(write());
45  ATH_CHECK(read());
46  } else {
47  ATH_CHECK(read());
48  ATH_CHECK(write());
49  }
50 
51  return StatusCode::SUCCESS;
52 }
53 
54 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
56 HiveAlgV::read() const {
57  StatusCode sc { StatusCode::SUCCESS };
58  std::vector< SG::ReadHandle<HiveDataObj> > rhv = m_rhv.makeHandles();
59  for (auto &hnd : rhv) {
60  if (!hnd.isValid()) {
61  ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << hnd.key());
62  sc = StatusCode::FAILURE;
63  } else {
64  ATH_MSG_INFO(" read: " << hnd.key() << " = " << hnd->val() );
65  }
66  }
67  return sc;
68 }
69 
70 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
73  std::vector< SG::WriteHandle<HiveDataObj> > whv = m_whv.makeHandles();
74  for (auto &hnd : whv) {
75  ATH_CHECK(hnd.record(std::make_unique<HiveDataObj>( 10101 )));
76  ATH_MSG_INFO(" write: " << hnd.key() << " = " << hnd->val() );
77  }
78  return StatusCode::SUCCESS;
79 }
80 
HiveAlgV::finalize
virtual StatusCode finalize() override
Definition: HiveAlgV.cxx:31
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HiveAlgV::write
StatusCode write()
Definition: HiveAlgV.cxx:72
HiveAlgBase::sleep
unsigned int sleep()
Definition: HiveAlgBase.cxx:42
HiveAlgBase::initialize
virtual StatusCode initialize() override
Definition: HiveAlgBase.cxx:25
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:45
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HiveAlgV::execute
virtual StatusCode execute() override
Definition: HiveAlgV.cxx:37
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()
Definition: HiveAlgV.cxx:14
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:195
HiveAlgV::m_writeFirst
Gaudi::Property< bool > m_writeFirst
Definition: HiveAlgV.h:38
HiveAlgV::m_rhv
SG::ReadHandleKeyArray< HiveDataObj > m_rhv
Definition: HiveAlgV.h:41
HiveAlgV::read
StatusCode read() const
Definition: HiveAlgV.cxx:56
HiveAlgV::HiveAlgV
HiveAlgV(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HiveAlgV.cxx:8