ATLAS Offline Software
ByteStreamAddressProviderSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Include files
9 
11 #include "GaudiKernel/TypeNameString.h"
12 #include "GaudiKernel/IClassIDSvc.h"
13 
14 #include "eformat/SourceIdentifier.h"
15 
17 ByteStreamAddressProviderSvc::ByteStreamAddressProviderSvc(const std::string& name, ISvcLocator* pSvcLocator) :
18  base_class(name, pSvcLocator),
19  m_clidSvc("ClassIDSvc", name),
20  m_storeID(StoreID::EVENT_STORE) {
21  declareProperty("StoreID", m_storeID);
22 }
23 //________________________________________________________________________________
25  ATH_MSG_INFO("Initializing");
26 
27  // Retrieve ClassIDSvc
28  ATH_CHECK( m_clidSvc.retrieve() );
29 
30  if (m_storeID < 0 || m_storeID > StoreID::UNKNOWN) {
31  ATH_MSG_FATAL("Invalid StoreID " << m_storeID);
32  return(StatusCode::FAILURE);
33  }
34  ATH_MSG_INFO("-- Will fill Store with id = " << m_storeID);
35  return(StatusCode::SUCCESS);
36 }
37 //________________________________________________________________________________
39  ATH_MSG_DEBUG("in preLoadAddress");
40  if (id != m_storeID) {
41  ATH_MSG_DEBUG("StoreID = " << id << " does not match required id (" << m_storeID << ") skip");
42  return(StatusCode::SUCCESS);
43  }
44 
45  for (const std::string& typeName : m_typeNames) {
46  Gaudi::Utils::TypeNameString item(typeName);
47  const std::string& t = item.type();
48  const std::string& nm = item.name();
49  CLID classid;
50  if (!m_clidSvc->getIDOfTypeName(t, classid).isSuccess()) {
51  ATH_MSG_WARNING("Cannot create TAD for (type, name)" << " no CLID for " << t << " " << nm);
52  } else {
54  tlist.push_back(tad);
55  ATH_MSG_DEBUG("Created TAD for (type, clid, name)" << t << " " << classid << " " << nm);
56  // save the clid and key.
57  m_clidKey[classid].insert(nm);
58  }
59  }
60  return(StatusCode::SUCCESS);
61 }
62 //________________________________________________________________________________
65  const EventContext& ctx) {
66  if (id != m_storeID) {
67  return(StatusCode::FAILURE);
68  }
69  CLID clid = tad->clID();
70  std::string nm = tad->name();
71  std::map<CLID, std::set<std::string> >::const_iterator it = m_clidKey.find(clid);
72  if (it == m_clidKey.end() || (*it).second.count(nm) == 0) {
73  return(StatusCode::FAILURE);
74  }
75  ATH_MSG_DEBUG("Creating address for " << clid << " " << nm);
76  ByteStreamAddress* add = new ByteStreamAddress(clid, nm, "");
77  add->setEventContext(ctx);
78  tad->setAddress(add);
79  return(StatusCode::SUCCESS);
80 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
python.StoreID.EVENT_STORE
int EVENT_STORE
Definition: StoreID.py:10
ByteStreamAddressProviderSvc::preLoadAddresses
virtual StatusCode preLoadAddresses(StoreID::type id, tadList &tlist) override
Definition: ByteStreamAddressProviderSvc.cxx:38
query_example.tlist
tlist
Definition: query_example.py:25
skel.it
it
Definition: skel.GENtoEVGEN.py:396
ByteStreamAddressProviderSvc::ByteStreamAddressProviderSvc
ByteStreamAddressProviderSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: ByteStreamAddressProviderSvc.cxx:17
SG::TransientAddress
Definition: TransientAddress.h:32
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
python.DetectStreamerInfoChanges.classid
classid
Definition: DetectStreamerInfoChanges.py:54
SG::TransientAddress::name
const std::string & name() const
Get the primary (hashed) SG key.
Definition: TransientAddress.h:208
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
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
SG::TransientAddress::clID
CLID clID() const
Retrieve string key:
Definition: TransientAddress.h:201
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
StoreID
defines an enum used by address providers to decide what kind of StoreGateSvc they are providing addr...
Definition: StoreID.h:18
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ByteStreamAddressProviderSvc::updateAddress
virtual StatusCode updateAddress(StoreID::type id, SG::TransientAddress *tad, const EventContext &ctx) override
update an existing transient Address
Definition: ByteStreamAddressProviderSvc.cxx:63
item
Definition: ItemListSvc.h:43
SG::TransientAddress::setAddress
void setAddress(IOpaqueAddress *pAddress)
Retrieve primary clid.
Definition: TransientAddress.cxx:172
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
StoreID::type
type
Definition: StoreID.h:24
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ByteStreamAddressProviderSvc.h
TransientAddress.h
StoreID::UNKNOWN
@ UNKNOWN
Definition: StoreID.h:32
ByteStreamAddressProviderSvc::m_typeNames
Gaudi::Property< std::vector< std::string > > m_typeNames
Definition: ByteStreamAddressProviderSvc.h:41
ByteStreamAddressProviderSvc::initialize
virtual StatusCode initialize() override
Definition: ByteStreamAddressProviderSvc.cxx:24
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
ByteStreamAddressProviderSvc::m_storeID
int m_storeID
Definition: ByteStreamAddressProviderSvc.h:49
ByteStreamAddressProviderSvc::m_clidSvc
ServiceHandle< IClassIDSvc > m_clidSvc
Definition: ByteStreamAddressProviderSvc.h:45
IROBDataProviderSvc.h
ByteStreamAddressProviderSvc::m_clidKey
std::map< unsigned int, std::set< std::string > > m_clidKey
Definition: ByteStreamAddressProviderSvc.h:47