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.
14namespace AthenaPoolCnvSvc {
20template <class CNV, class TPCNV>
21TPCnvElt<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.
39template <class CNV, class TPCNV>
40std::unique_ptr<typename TPCnvElt<CNV, TPCNV>::Trans_t>
41TPCnvElt<CNV, TPCNV>::createTransient (CNV& parent,
43 const std::string& key,
46 if (!parent.compareClassGuid(token, m_guid))
47 return std::unique_ptr<typename TPCnvElt<CNV, TPCNV>::Trans_t>();
49 std::unique_ptr<Pers_t> old (parent.template poolReadObject<Pers_t>(token) );
50 return AthenaPoolCnvSvc::createTransient (m_cnv, old.get(), key, msg);
55 * @brief Read the persistent object and convert it to transient.
56 * @param parent The top-level pool converter object.
57 * @param trans The transient object to modify.
58 * @param key The SG key of the object being read.
59 * @param msg MsgStream for error reporting.
61 * Overwrites the provided transient object.
62 * If the type of the persistent object on the file does not match the
63 * type that this converter handles, returns false.
64 * Other errors are reported by raising exceptions.
66template <class CNV, class TPCNV>
68TPCnvElt<CNV, TPCNV>::persToTrans (CNV& parent, Trans_t* trans,
70 const std::string& /*key*/,
73 if (!parent.compareClassGuid(token, m_guid))
76 std::unique_ptr<Pers_t> old ( parent.template poolReadObject<Pers_t>(token) );
77 m_cnv.persToTrans (old.get(), trans, msg);
82//*************************************************************************
88 * Specialization for the case of no conversion.
90template <class CNV, class TRANS>
91TPCnvElt<CNV, T_TPCnvNull<TRANS> >::TPCnvElt()
92 // Remember the guid for our persistent type.
93 : m_guid (guidFromTypeinfo (typeid (Pers_t)))
99 * @brief Read the persistent object and convert it to transient.
100 * @param parent The top-level pool converter object.
101 * @param key The SG key of the object being read.
102 * @param msg MsgStream for error reporting.
104 * Specialization for the case of no conversion.
106 * Returns a newly-allocated object.
107 * If the type of the persistent object on the file does not match the
108 * type that this converter handles, return nullptr.
109 * Other errors are reported by raising exceptions.
111template <class CNV, class TRANS>
112std::unique_ptr<typename TPCnvElt<CNV, T_TPCnvNull<TRANS> >::Trans_t>
113TPCnvElt<CNV, T_TPCnvNull<TRANS> >::createTransient (CNV& parent,
115 const std::string& /*key*/,
119 if (parent.compareClassGuid(token, m_guid)) {
120 p = parent.template poolReadObject<Pers_t>(token);
122 return std::unique_ptr<typename TPCnvElt<CNV, T_TPCnvNull<TRANS> >::Trans_t>(p);
127 * @brief Read the persistent object and convert it to transient.
128 * @param parent The top-level pool converter object.
129 * @param trans The transient object to modify.
130 * @param key The SG key of the object being read.
131 * @param msg MsgStream for error reporting.
133 * Specialization for the case of no conversion.
135 * Overwrites the provided transient object.
136 * If the type of the persistent object on the file does not match the
137 * type that this converter handles, returns false.
138 * Other errors are reported by raising exceptions.
140template <class CNV, class TRANS>
142TPCnvElt<CNV, T_TPCnvNull<TRANS> >::persToTrans (CNV& parent,
145 const std::string& /*key*/,
148 if (!parent.compareClassGuid(token, m_guid))
151 std::unique_ptr<Pers_t> old ( parent.template poolReadObject<Pers_t>(token) );
157} // namespace AthenaPoolCnvSvc