ATLAS Offline Software
Loading...
Searching...
No Matches
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
8HiveAlgV::HiveAlgV( const std::string& name,
9 ISvcLocator* pSvcLocator ) :
10 ::HiveAlgBase( name, pSvcLocator )
11{}
12
13/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14HiveAlgV::~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
28}
29
30/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
31StatusCode HiveAlgV::execute() {
32
33 ATH_MSG_DEBUG("execute " << name());
34
35 sleep();
36
37 if (m_writeFirst) {
39 ATH_CHECK(read());
40 } else {
41 ATH_CHECK(read());
43 }
44
45 return StatusCode::SUCCESS;
46}
47
48/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
49StatusCode
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/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
65StatusCode
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Simple Algorithm that reads an array of HiveDataObjs, and then writes an array of them.
static Double_t sc
unsigned int sleep()
HiveAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
StatusCode read() const
Definition HiveAlgV.cxx:50
SG::ReadHandleKeyArray< HiveDataObj > m_rhv
Definition HiveAlgV.h:40
SG::WriteHandleKeyArray< HiveDataObj > m_whv
Definition HiveAlgV.h:44
virtual StatusCode initialize() override
Definition HiveAlgV.cxx:17
HiveAlgV(const std::string &name, ISvcLocator *pSvcLocator)
Definition HiveAlgV.cxx:8
StatusCode write()
Definition HiveAlgV.cxx:66
Gaudi::Property< bool > m_writeFirst
Definition HiveAlgV.h:37
virtual StatusCode execute() override
Definition HiveAlgV.cxx:31