2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5 * @file AthenaPoolCnvSvc/T_AthenaPoolAuxContainerCnv.icc
6 * @author scott snyder <snyder@bnl.gov>
8 * @brief Athena pool converter for aux store classes.
12 #include "AthenaPoolCnvSvc/exceptions.h"
13 #include "AthContainers/tools/copyThinned.h"
14 #include "AthenaKernel/getThinningCache.h"
19 * @param svcLoc Gaudi service locator.
21 template <class AUXSTORE, class ... TPCNVS>
22 T_AthenaPoolAuxContainerCnv<AUXSTORE, TPCNVS...>::T_AthenaPoolAuxContainerCnv( ISvcLocator* svcLoc )
24 m_guid (AthenaPoolCnvSvc::guidFromTypeinfo (typeid (AUXSTORE)))
30 * @brief Convert a transient object to persistent form.
31 * @param trans The transient object to convert.
32 * @param key The SG key of the object being written.
34 * Returns a newly-allocated persistent object.
36 template <class AUXSTORE, class ... TPCNVS>
38 T_AthenaPoolAuxContainerCnv<AUXSTORE, TPCNVS...>::createPersistentWithKey( AUXSTORE* trans,
39 const std::string& key)
41 AthenaPoolCnvSvc::debugCreatePersistent (ClassID_traits<AUXSTORE>::ID());
42 std::string key2 = key;
43 if (key2.size() >= 4 && key2.substr (key2.size()-4, 4) == "Aux.")
45 key2.erase (key2.size()-4, 4);
48 const SG::ThinningInfo* info = SG::getThinningInfo (key2);
49 return SG::copyThinned (*trans, info).release();
51 catch( const std::exception &ex ) {
52 AthenaPoolCnvSvc::throwExcCaughtException (__PRETTY_FUNCTION__,
53 "thinning aux container",
62 * @brief Read the persistent object and convert it to transient.
63 * @param key The SG key of the object being written.
65 * Returns a newly-allocated transient object.
66 * Errors are reported by raising exceptions.
68 template <class AUXSTORE, class ... TPCNVS>
70 T_AthenaPoolAuxContainerCnv<AUXSTORE, TPCNVS...>::createTransientWithKey (const std::string& key)
72 AthenaPoolCnvSvc::debugCreateTransient (ClassID_traits<AUXSTORE>::ID());
73 if ( this->compareClassGuid( m_guid ) ) {
74 // It's the latest version, read it directly:
75 return this->template poolReadObject< AUXSTORE >();
79 std::unique_ptr<AUXSTORE> c = m_tpcnvs.createTransient (*this, key, this->msg());
83 // Didn't recognize the GUID.
84 AthenaPoolCnvSvc::throwExcUnsupportedVersion (typeid(AUXSTORE),
85 this->m_i_poolToken->classID());