ATLAS Offline Software
Loading...
Searching...
No Matches
T_AthenaPoolTPCnvCnv.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id$
6/**
7 * @file AthenaPoolCnvSvc/T_AthenaPoolTPCnvCnv.icc
8 * @author scott snyder <snyder@bnl.gov>
9 * @date Jan, 2016
10 * @brief Athena pool converter for a class using TP separation.
11 */
12
13
14/**
15 * @brief Constructor.
16 * @param svcLoc Gaudi service locator.
17 */
18template <class TRANS, class TPCNV_CUR, class ... TPCNVS>
19T_AthenaPoolTPCnvCnv<TRANS, TPCNV_CUR, TPCNVS...>::T_AthenaPoolTPCnvCnv( ISvcLocator* svcLoc )
20 : Base( svcLoc ),
21 m_guid (AthenaPoolCnvSvc::guidFromTypeinfo (typeid (Pers_t)))
22{
23}
24
25
26/**
27 * @brief Convert a transient object to persistent form.
28 * @param key The SG key of the object being written.
29 * @param trans The transient object to convert.
30 *
31 * Returns a newly-allocated persistent object.
32 */
33template <class TRANS, class TPCNV_CUR, class ... TPCNVS>
34typename T_AthenaPoolTPCnvCnv<TRANS, TPCNV_CUR, TPCNVS...>::Pers_t*
35T_AthenaPoolTPCnvCnv<TRANS, TPCNV_CUR, TPCNVS...>::createPersistentWithKey( TRANS* trans,
36 const std::string& key)
37{
38 AthenaPoolCnvSvc::debugCreatePersistent (ClassID_traits<TRANS>::ID());
39 return AthenaPoolCnvSvc::createPersistent (m_tpcnv_cur, trans, key, this->msg()).release();
40}
41
42
43/**
44 * @brief Read the persistent object and convert it to transient.
45 * @param key The SG key of the object being read.
46 *
47 * Returns a newly-allocated transient object.
48 * Errors are reported by raising exceptions.
49 */
50template <class TRANS, class TPCNV_CUR, class ... TPCNVS>
51TRANS*
52T_AthenaPoolTPCnvCnv<TRANS, TPCNV_CUR, TPCNVS...>::createTransientWithKey (const std::string& key)
53{
54 AthenaPoolCnvSvc::debugCreateTransient (ClassID_traits<TRANS>::ID());
55 if ( this->compareClassGuid( m_guid ) ) {
56 // It's the latest version.
57 std::unique_ptr<Pers_t> persObj( this->template poolReadObject<Pers_t>() );
58 return AthenaPoolCnvSvc::createTransient (m_tpcnv_cur, persObj.get(), key, this->msg()).release();
59 }
60
61 // Try a converter.
62 std::unique_ptr<TRANS> c = m_tpcnvs.createTransient (*this, key, this->msg());
63 if (c)
64 return c.release();
65
66 // Didn't recognize the GUID.
67 AthenaPoolCnvSvc::throwExcUnsupportedVersion (typeid(TRANS),
68 this->m_i_poolToken->classID());
69 return 0;
70}