2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
6 * @file AthenaKernel/DataBucketBase.icc
9 * @brief A non-templated base class for DataBucket, allows to access the
10 * transient object address as a void*
11 * Implementation file.
14 #include "AthenaKernel/ClassID_traits.h"
15 #include <type_traits>
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.
28 T* DataBucketBase::cast (SG::IRegisterTransient* irt /*= 0*/,
29 bool isConst /*= true*/)
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));
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.
46 * This allows the callee to choose whether to use clid or tinfo.
47 * By default, this uses type_info,.
50 void* DataBucketBase::cast (CLID /*clid*/,
51 const std::type_info& tinfo,
52 SG::IRegisterTransient* irt /*= 0*/,
53 bool isConst /*= true*/)
55 return cast (tinfo, irt, isConst);