ATLAS Offline Software
Loading...
Searching...
No Matches
StorableConversions.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10
13#include "GaudiKernel/System.h"
14
16#include "GaudiKernel/MsgStream.h"
17
18
19namespace SG {
20
21
35void* fromStorable(DataObject* pDObj, CLID clid,
36 const std::type_info* tinfo /*= nullptr*/,
37 bool quiet [[maybe_unused]] /*= false*/,
38 IRegisterTransient*irt/*= 0*/,
39 bool isConst /*= true*/)
40{
41 //check inputs
42 if (0 == pDObj) {
43 MsgStream gLog(Athena::getMessageSvc(), "SG::fromStorable");
44 gLog << MSG::WARNING << "null input pointer " << endmsg;
45 return nullptr;
46 }
47
48 // get T* from DataBucket:
49 // All objects in the event store nowadays are instances
50 // of DataBucket, so just do a static_cast.
51 DataBucketBase* b = static_cast<DataBucketBase*>(pDObj);
52 // Use BaseInfo information to convert pointers.
53
54 void* ret = nullptr;
55 if (tinfo)
56 ret = b->cast (clid, *tinfo, irt, isConst);
57 else
58 ret = b->cast (clid, irt, isConst);
59 if (!quiet && !ret) {
60 const std::type_info* tid = CLIDRegistry::CLIDToTypeinfo (clid);
61 MsgStream gLog(Athena::getMessageSvc(), "SG::fromStorable");
62 gLog << MSG::WARNING
63 << "can't convert stored DataObject " << pDObj
64 << " to type ("
65 << (tid ? System::typeinfoName (*tid) : "[unknown]")
66 << ")\n Unless you are following a symlink,"
67 << " it probably means you have a duplicate "
68 << "CLID = " << pDObj->clID()
69 << endmsg;
70 }
71 return ret;
72}
73
74
88void* Storable_cast(DataObject* pDObj, CLID clid,
89 const std::type_info* tinfo /*= nullptr*/,
90 bool quiet /*= false*/,
91 IRegisterTransient* irt /*= 0*/,
92 bool isConst /*= true*/)
93{
94 return fromStorable (pDObj, clid, tinfo, quiet, irt, isConst);
95}
96
97
98} // namespace SG
#define endmsg
a static registry of CLID->typeName entries.
uint32_t CLID
The Class ID type.
convert to and from a SG storable
static const std::type_info * CLIDToTypeinfo(CLID clid)
Translate between CLID and type_info.
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
Interface for registering a transient object in t2p map.
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
Forward declaration.
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)