ATLAS Offline Software
ByteStreamCnvSvcBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 {
19  declareProperty("InitCnvs", m_initCnvs);
20 }
21 //______________________________________________________________________________
24 }
25 //______________________________________________________________________________
28  if (!::AthCnvSvc::initialize().isSuccess()) {
29  ATH_MSG_FATAL("Cannot initialize AthCnvSvc base class.");
30  return(StatusCode::FAILURE);
31  }
32 
33  ServiceHandle<IIncidentSvc> incsvc("IncidentSvc", this->name());
34  if (!incsvc.retrieve().isSuccess()) {
35  ATH_MSG_FATAL("Cannot get IncidentSvc.");
36  return(StatusCode::FAILURE);
37  }
38  incsvc->addListener(this, "BeginRun", 0, false, true); // true for singleshot
39  return(StatusCode::SUCCESS);
40 }
41 //______________________________________________________________________________
43  if (pAddress != 0) {
44  GenericAddress* pAddr = dynamic_cast<GenericAddress*>(pAddress);
45  if (pAddr != 0) {
46  return(StatusCode::SUCCESS);
47  }
48  }
49  return(StatusCode::FAILURE);
50 }
51 //______________________________________________________________________________
52 void ByteStreamCnvSvcBase::handle(const Incident& /*incident*/) {
53  ServiceHandle<IClassIDSvc> clidSvc("ClassIDSvc", name());
54  if (!clidSvc.retrieve().isSuccess()) {
55  ATH_MSG_ERROR("Cannot get ClassIDSvc.");
56  return;
57  }
58  // Initialize the converters
59  for (const std::string& cnv : m_initCnvs) {
60  ATH_MSG_DEBUG("Accessing Converter for " << cnv);
61  CLID id;
62  if (!clidSvc->getIDOfTypeName(cnv, id).isSuccess()) {
63  ATH_MSG_WARNING("Cannot get CLID for " << cnv);
64  } else {
65  IConverter* cnv = converter(id);
66  if (cnv == 0) {
67  ATH_MSG_WARNING("Cannot get converter for " << cnv);
68  }
69  }
70  }
71  return;
72 }
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:52
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ByteStreamCnvSvcBase::~ByteStreamCnvSvcBase
virtual ~ByteStreamCnvSvcBase()
Destructor.
Definition: ByteStreamCnvSvcBase.cxx:23
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
ByteStreamCnvSvcBase::m_initCnvs
std::vector< std::string > m_initCnvs
Definition: ByteStreamCnvSvcBase.h:34
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
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:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:42
ByteStreamCnvSvcBase::initialize
virtual StatusCode initialize() override
Required of all Gaudi Services.
Definition: ByteStreamCnvSvcBase.cxx:27
ServiceHandle< IIncidentSvc >