2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
7 * @file AthenaPoolCnvSvc/TPCnvElt.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief Helper for calling a TP converter from an Athena converter.
14 namespace AthenaPoolCnvSvc {
20 template <class CNV, class TPCNV>
21 TPCnvElt<CNV, TPCNV>::TPCnvElt()
22 // Remember the guid for our persistent type.
23 : m_guid (guidFromTypeinfo (typeid (Pers_t)))
29 * @brief Read the persistent object and convert it to transient.
30 * @param parent The top-level pool converter object.
31 * @param key The SG key of the object being read.
32 * @param msg MsgStream for error reporting.
34 * Returns a newly-allocated object.
35 * If the type of the persistent object on the file does not match the
36 * type that this converter handles, return nullptr.
37 * Other errors are reported by raising exceptions.
39 template <class CNV, class TPCNV>
40 std::unique_ptr<typename TPCnvElt<CNV, TPCNV>::Trans_t>
41 TPCnvElt<CNV, TPCNV>::createTransient (CNV& parent,
42 const std::string& key,
45 if (!parent.compareClassGuid (m_guid))
46 return std::unique_ptr<typename TPCnvElt<CNV, TPCNV>::Trans_t>();
48 std::unique_ptr<Pers_t> old (parent.template poolReadObject<Pers_t>() );
49 return AthenaPoolCnvSvc::createTransient (m_cnv, old.get(), key, msg);
54 * @brief Read the persistent object and convert it to transient.
55 * @param parent The top-level pool converter object.
56 * @param trans The transient object to modify.
57 * @param key The SG key of the object being read.
58 * @param msg MsgStream for error reporting.
60 * Overwrites the provided transient object.
61 * If the type of the persistent object on the file does not match the
62 * type that this converter handles, returns false.
63 * Other errors are reported by raising exceptions.
65 template <class CNV, class TPCNV>
67 TPCnvElt<CNV, TPCNV>::persToTrans (CNV& parent, Trans_t* trans,
68 const std::string& /*key*/,
71 if (!parent.compareClassGuid (m_guid))
74 std::unique_ptr<Pers_t> old ( parent.template poolReadObject<Pers_t>() );
75 m_cnv.persToTrans (old.get(), trans, msg);
80 //*************************************************************************
86 * Specialization for the case of no conversion.
88 template <class CNV, class TRANS>
89 TPCnvElt<CNV, T_TPCnvNull<TRANS> >::TPCnvElt()
90 // Remember the guid for our persistent type.
91 : m_guid (guidFromTypeinfo (typeid (Pers_t)))
97 * @brief Read the persistent object and convert it to transient.
98 * @param parent The top-level pool converter object.
99 * @param key The SG key of the object being read.
100 * @param msg MsgStream for error reporting.
102 * Specialization for the case of no conversion.
104 * Returns a newly-allocated object.
105 * If the type of the persistent object on the file does not match the
106 * type that this converter handles, return nullptr.
107 * Other errors are reported by raising exceptions.
109 template <class CNV, class TRANS>
110 std::unique_ptr<typename TPCnvElt<CNV, T_TPCnvNull<TRANS> >::Trans_t>
111 TPCnvElt<CNV, T_TPCnvNull<TRANS> >::createTransient (CNV& parent,
112 const std::string& /*key*/,
116 if (parent.compareClassGuid (m_guid)) {
117 p = parent.template poolReadObject<Pers_t>();
119 return std::unique_ptr<typename TPCnvElt<CNV, T_TPCnvNull<TRANS> >::Trans_t>(p);
124 * @brief Read the persistent object and convert it to transient.
125 * @param parent The top-level pool converter object.
126 * @param trans The transient object to modify.
127 * @param key The SG key of the object being read.
128 * @param msg MsgStream for error reporting.
130 * Specialization for the case of no conversion.
132 * Overwrites the provided transient object.
133 * If the type of the persistent object on the file does not match the
134 * type that this converter handles, returns false.
135 * Other errors are reported by raising exceptions.
137 template <class CNV, class TRANS>
139 TPCnvElt<CNV, T_TPCnvNull<TRANS> >::persToTrans (CNV& parent,
141 const std::string& /*key*/,
144 if (!parent.compareClassGuid (m_guid))
147 std::unique_ptr<Pers_t> old ( parent.template poolReadObject<Pers_t>() );
153 } // namespace AthenaPoolCnvSvc