Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  */
15 #ifndef SGTOOLS_DATAPROXY_CAST_H
16 #define SGTOOLS_DATAPROXY_CAST_H
17 
18 
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>
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);
49 
50 
51 
52 template <typename DATA>
54  typedef typename std::remove_const<DATA>::type DATA_nc;
56 
57  return static_cast<DATA*>(DataProxy_cast (proxy, ClassID_traits<DATA>::ID(),
58  &typeid(DATA_nc)));
59 }
60 
61 
63 template<typename DATA>
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
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
Definition: DataProxy_cast.h:53
exceptions.h
Exceptions that can be thrown by SGTools.
get_generator_info.result
result
Definition: get_generator_info.py:21
SG::DataBucketTrait::init
static void init()
Initialization hook. A no-op by default.
Definition: StorableConversions.h:147
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:395
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
StorableConversions.h
convert to and from a SG storable
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
SG::throwExcBadDataProxyCast
void throwExcBadDataProxyCast(const DataProxy &proxy, const std::type_info &tid)
Throw an ExcBadDataProxyCast exception.
Definition: Control/SGTools/src/exceptions.cxx:57
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
DataProxy
DataProxy provides the registry services for StoreGate.
Definition: DataProxy.h:32
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::DataProxy
Definition: DataProxy.h:45