ATLAS Offline Software
DataBucketBase.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /**
6  * @file AthenaKernel/DataBucketBase.icc
7  * @author scott snyder
8  * @date Nov 2005
9  * @brief A non-templated base class for DataBucket, allows to access the
10  * transient object address as a void*
11  * Implementation file.
12  */
13 
14 #include "AthenaKernel/ClassID_traits.h"
15 #include <type_traits>
16 #include <typeinfo>
17 
18 
19 /**
20  * @brief Return the contents of the @c DataBucket,
21  * converted to type @a T. Note that only
22  * derived->base conversions are allowed here.
23  * @a T must have a valid Class ID for this to work.
24  * @param irt To be called if we make a new instance.
25  * @param isConst True if the object being converted is regarded as const.
26  */
27 template <class T>
28 T* DataBucketBase::cast (SG::IRegisterTransient* irt /*= 0*/,
29  bool isConst /*= true*/)
30 {
31  using T_nc = std::remove_const_t<T>;
32  const CLID clid = ClassID_traits<T_nc>::ID();
33  return reinterpret_cast<T*> (cast (clid, typeid(T_nc), irt, isConst));
34 }
35 
36 
37 /**
38  * @brief Return the contents of the @c DataBucket,
39  * converted to type given by @a clid. Note that only
40  * derived->base conversions are allowed here.
41  * @param clid The class ID to which to convert.
42  * @param tinfo The @a std::type_info of the type to which to convert.
43  * @param irt To be called if we make a new instance.
44  * @param isConst True if the object being converted is regarded as const.
45  *
46  * This allows the callee to choose whether to use clid or tinfo.
47  * By default, this uses type_info,.
48  */
49 inline
50 void* DataBucketBase::cast (CLID /*clid*/,
51  const std::type_info& tinfo,
52  SG::IRegisterTransient* irt /*= 0*/,
53  bool isConst /*= true*/)
54 {
55  return cast (tinfo, irt, isConst);
56 }