2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 * @file AthenaKernel/MetaContDataBucket.icc
6 * @author scott snyder <snyder@bnl.gov>
8 * @brief Allow converting MetaCont<T> to T.
16 * @brief Return the contents of the @c DataBucket,
17 * converted to type given by @a clid. Note that only
18 * derived->base conversions are allowed here.
19 * @param clid The class ID to which to convert.
20 * @param irt To be called if we make a new instance.
21 * @param isConst True if the object being converted is regarded as const.
24 void* MetaContDataBucket<T>::cast (CLID clid,
25 IRegisterTransient* irt /*= 0*/,
26 bool isConst /*= true*/)
28 // First try normal conversion.
29 if (void* ret = DataBucket<T>::cast (clid, irt, isConst)) {
33 // Otherwise, try to retrieve the payload and cast it as requested.
34 typename T::Payload_t* payload = nullptr;
35 if (this->ptr()->find (getSID(), payload)) {
36 return SG::BaseInfo<typename T::Payload_t>::cast (payload, clid);
43 * @brief Return the contents of the @c DataBucket,
44 * converted to type given by @a std::type_info. Note that only
45 * derived->base conversions are allowed here.
46 * @param clid The @a std::type_info of the type to which to convert.
47 * @param irt To be called if we make a new instance.
48 * @param isConst True if the object being converted is regarded as const.
51 void* MetaContDataBucket<T>::cast (const std::type_info& tinfo,
52 IRegisterTransient* irt /*= 0*/,
53 bool isConst /*= true*/)
55 if (void* ret = DataBucket<T>::cast (tinfo, irt, isConst)) {
58 // Otherwise, try to retrieve the payload and cast it as requested.
59 typename T::Payload_t* payload = nullptr;
60 if (this->ptr()->find (getSID(), payload)) {
61 return SG::BaseInfo<typename T::Payload_t>::cast (payload, tinfo);
68 * @brief Return the contents of the @c DataBucket,
69 * converted to type given by @a clid. Note that only
70 * derived->base conversions are allowed here.
71 * @param clid The class ID to which to convert.
72 * @param tinfo The @a std::type_info of the type to which to convert.
73 * @param irt To be called if we make a new instance.
74 * @param isConst True if the object being converted is regarded as const.
76 * This allows the callee to choose whether to use clid or tinfo.
81 void* MetaContDataBucket<T>::cast (CLID clid,
82 const std::type_info& /*tinfo*/,
83 SG::IRegisterTransient* irt /*= 0*/,
84 bool isConst /*= true*/)
86 return MetaContDataBucket::cast (clid, irt, isConst);
91 * @brief Return the metadata source id for the current event store.
92 * Returns an empty string if there's no source ID set.
95 const SourceID MetaContDataBucket<T>::getSID() const
97 const EventContext& ctx = Gaudi::Hive::currentContext();
98 const IProxyDict* store =
99 Atlas::getExtendedEventContext(ctx).proxy();
100 return store->sourceID();