ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
SGTools
SGTools
DataProxy_cast.h
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
/*
3
* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
4
*/
13
14
15
#ifndef SGTOOLS_DATAPROXY_CAST_H
16
#define SGTOOLS_DATAPROXY_CAST_H
17
18
19
#include "
AthenaKernel/StorableConversions.h
"
20
#include "
SGTools/exceptions.h
"
21
#include <typeinfo>
22
23
24
namespace
SG
{
25
26
27
class
DataProxy
;
28
29
31
32
template
<
typename
DATA>
33
DATA*
DataProxy_cast
(
DataProxy
* proxy);
34
36
template
<
typename
DATA>
37
DATA
DataProxy_cast
(
const
DataProxy
& proxy);
38
48
void
*
DataProxy_cast
(
DataProxy
* proxy,
CLID
clid,
const
std::type_info* tinfo =
nullptr
);
50
51
52
template
<
typename
DATA>
53
DATA*
DataProxy_cast
(
SG::DataProxy
* proxy) {
54
typedef
typename
std::remove_const<DATA>::type DATA_nc;
55
DataBucketTrait<DATA_nc>::init
();
56
57
return
static_cast<
DATA*
>
(
DataProxy_cast
(proxy,
ClassID_traits<DATA>::ID
(),
58
&
typeid
(DATA_nc)));
59
}
60
61
63
template
<
typename
DATA>
64
DATA
DataProxy_cast
(
const
SG::DataProxy
& proxy)
65
{
66
const
DATA* result =
SG::DataProxy_cast<DATA>
(&proxy);
67
if
(!result)
SG::throwExcBadDataProxyCast
(proxy,
typeid
(DATA));
68
return
*result;
69
}
70
71
72
}
// namespace SG
73
74
75
#endif
// not SGTOOLS_DATAPROXY_CAST_H
exceptions.h
Exceptions that can be thrown by SGTools.
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
SG::DataProxy
Definition
DataProxy.h:45
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::throwExcBadDataProxyCast
void throwExcBadDataProxyCast(const DataProxy &proxy, const std::type_info &tid)
Throw an ExcBadDataProxyCast exception.
Definition
Control/SGTools/src/exceptions.cxx:57
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
Definition
DataProxy_cast.h:53
ClassID_traits::ID
static constexpr CLID ID()
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
SG::DataBucketTrait::init
static void init()
Initialization hook. A no-op by default.
Definition
StorableConversions.h:147
Generated on
for ATLAS Offline Software by
1.17.0