ATLAS Offline Software
Loading...
Searching...
No Matches
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//______________________________________________________________________________
16ByteStreamCnvSvcBase::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//______________________________________________________________________________
32StatusCode ByteStreamCnvSvcBase::updateServiceState(IOpaqueAddress* pAddress) {
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//______________________________________________________________________________
42void 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
uint32_t CLID
The Class ID type.
virtual StatusCode initialize() override
Gaudi Service Implementation.
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
virtual StatusCode initialize() override
Required of all Gaudi Services.
virtual void handle(const Incident &) override
Implementation of IIncidentListener: Handle for EndEvent incidence.
ByteStreamCnvSvcBase(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress) override
Checks whether an IOpaqueAddress is a GenericAddress.
virtual ~ByteStreamCnvSvcBase()
Destructor.
Gaudi::Property< std::vector< std::string > > m_initCnvs