ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaKernel
src
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
11
#include "
AthenaKernel/StorableConversions.h
"
12
#include "
AthenaKernel/CLIDRegistry.h
"
13
#include "GaudiKernel/System.h"
14
15
#include "
AthenaKernel/getMessageSvc.h
"
16
#include "GaudiKernel/MsgStream.h"
17
18
19
namespace
SG
{
20
21
35
void
*
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
88
void
*
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
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
CLIDRegistry.h
a static registry of CLID->typeName entries.
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
StorableConversions.h
convert to and from a SG storable
quiet
bool quiet
Definition
TrigGlobEffCorrValidation.cxx:190
CLIDRegistry::CLIDToTypeinfo
static const std::type_info * CLIDToTypeinfo(CLID clid)
Translate between CLID and type_info.
Definition
CLIDRegistry.cxx:136
DataBucketBase
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
Definition
DataBucketBase.h:24
SG::IRegisterTransient
Interface for registering a transient object in t2p map.
Definition
IRegisterTransient.h:28
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::Storable_cast
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)
Definition
StorableConversions.h:37
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition
StorableConversions.h:169
Generated on
for ATLAS Offline Software by
1.17.0