ATLAS Offline Software
ByteStreamCnvSvcBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "GaudiKernel/IOpaqueAddress.h"
9 #include "GaudiKernel/GenericAddress.h"
10 #include "GaudiKernel/IConverter.h"
11 #include "GaudiKernel/ServiceHandle.h"
12 #include "GaudiKernel/IIncidentSvc.h"
13 #include "GaudiKernel/IClassIDSvc.h"
14 
15 //______________________________________________________________________________
16 ByteStreamCnvSvcBase::ByteStreamCnvSvcBase(const std::string& name, ISvcLocator* pSvcLocator)
17  : base_class(name, pSvcLocator, ByteStreamAddress::storageType()) {}
18 //______________________________________________________________________________
21 //______________________________________________________________________________
25 
26  ServiceHandle<IIncidentSvc> incsvc("IncidentSvc", this->name());
27  ATH_CHECK(incsvc.retrieve());
28  incsvc->addListener(this, "BeginRun", 0, false, true); // true for singleshot
29  return StatusCode::SUCCESS;
30 }
31 //______________________________________________________________________________
33  if (pAddress != nullptr) {
34  GenericAddress* pAddr = dynamic_cast<GenericAddress*>(pAddress);
35  if (pAddr != nullptr) {
36  return StatusCode::SUCCESS;
37  }
38  }
39  return StatusCode::FAILURE;
40 }
41 //______________________________________________________________________________
42 void ByteStreamCnvSvcBase::handle(const Incident& /*incident*/) {
43  ServiceHandle<IClassIDSvc> clidSvc("ClassIDSvc", name());
44  if (!clidSvc.retrieve().isSuccess()) {
45  ATH_MSG_ERROR("Cannot get ClassIDSvc.");
46  return;
47  }
48  // Initialize the converters
49  for (const std::string& cnv : m_initCnvs.value()) {
50  ATH_MSG_DEBUG("Accessing Converter for " << cnv);
51  CLID id;
52  if (!clidSvc->getIDOfTypeName(cnv, id).isSuccess()) {
53  ATH_MSG_WARNING("Cannot get CLID for " << cnv);
54  } else {
55  IConverter* cnv = converter(id);
56  if (cnv == nullptr) {
57  ATH_MSG_WARNING("Cannot get converter for " << cnv);
58  }
59  }
60  }
61 }
ByteStreamCnvSvcBase::ByteStreamCnvSvcBase
ByteStreamCnvSvcBase(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition: ByteStreamCnvSvcBase.cxx:16
ByteStreamCnvSvcBase::handle
virtual void handle(const Incident &) override
Implementation of IIncidentListener: Handle for EndEvent incidence.
Definition: ByteStreamCnvSvcBase.cxx:42
ByteStreamCnvSvcBase::~ByteStreamCnvSvcBase
virtual ~ByteStreamCnvSvcBase()
Destructor.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ByteStreamCnvSvcBase.h
AthCnvSvc::initialize
virtual StatusCode initialize() override
Gaudi Service Implementation.
Definition: AthCnvSvc.cxx:104
ByteStreamCnvSvcBase::updateServiceState
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress) override
Checks whether an IOpaqueAddress is a GenericAddress.
Definition: ByteStreamCnvSvcBase.cxx:32
ByteStreamCnvSvcBase::m_initCnvs
Gaudi::Property< std::vector< std::string > > m_initCnvs
Definition: ByteStreamCnvSvcBase.h:34
ByteStreamCnvSvcBase::initialize
virtual StatusCode initialize() override
Required of all Gaudi Services.
Definition: ByteStreamCnvSvcBase.cxx:23
ServiceHandle< IIncidentSvc >