2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
6 /** @file T_AthenaPoolExtendingCnv.icc
7 * @brief his file contains method definitions for the templated T_AthenaPoolExtendingCnv class.
8 * @author Marcin.Nowak@cern.ch
13 template <class TRANS, class PERS>
14 T_AthenaPoolExtendingCnv< TRANS, PERS >::T_AthenaPoolExtendingCnv(ISvcLocator* svcloc) :
15 T_AthenaPoolCustomCnv<TRANS, PERS>( svcloc ),
16 m_originalExtendingCnv( 0 )
21 template <class TRANS, class PERS>
22 inline const std::string
23 T_AthenaPoolExtendingCnv< TRANS, PERS >::name() const
25 return std::to_string(this->objType());
29 template <class TRANS, class PERS>
31 T_AthenaPoolExtendingCnv< TRANS, PERS >::
32 wasClonedFrom( AthenaConverterTLPExtension *converter )
34 if( !converter->needsCloning() ) {
35 // converter doesn't have any reference to an original converter - must be the original itself
36 m_originalExtendingCnv = dynamic_cast< BaseType* >(converter);
38 // in case of cloning a clone, get the real original converter
39 auto* extcnv = dynamic_cast< T_AthenaPoolExtendingCnv< TRANS, PERS >* >(converter);
40 if (!extcnv) std::abort();
41 m_originalExtendingCnv = extcnv->baseAthenaPoolCnv();
43 // std::cout << " TPCNVINFO: Registering clone source " << (void*)m_originalExtendingCnv << std::endl;
48 template <class TRANS, class PERS>
50 T_AthenaPoolExtendingCnv< TRANS, PERS >::setToken(const std::string& token)
52 // set token in base, so local compareClassGuid() will work
53 BaseType::setToken( token );
54 // set token in the original converter so poolReadObject() will work
55 baseAthenaPoolCnv()->T_AthenaPoolExtendingCnv::BaseType::setToken( token );
60 template <class TRANS, class PERS>
63 T_AthenaPoolExtendingCnv< TRANS, PERS >::
66 // std::cout << " TPCNVINFO: redirecting poolReadObject() to original APcnv" << std::endl;
67 return baseAthenaPoolCnv()->template poolReadObject<P>();
72 template <class TRANS, class PERS>
75 T_AthenaPoolExtendingCnv< TRANS, PERS >::
76 poolReadObject( TopLevelTPCnvBase& tlp_converter )
78 // set which Top level TP concerter will by used for reading
79 usingTPCnvForReading( tlp_converter );
81 P* persObj = poolReadObject< P >();
82 // remember the object we just read
83 tlp_converter.setTLPersObject( persObj );
88 template <class TRANS, class PERS>
89 std::unique_ptr<const Token>
90 T_AthenaPoolExtendingCnv< TRANS, PERS >::writeObject(const std::string& key, const std::string& output)
92 std::unique_ptr<Token> pTok;
93 PERS *persObj = reinterpret_cast<PERS*>( getTopLevelTPCnv()->getTLPersObjectAsVoid() );
95 //MN - do not pass SG key - this will put the object in a separate container
96 if( !baseAthenaPoolCnv()->objectToPool( persObj, pTok, key, output ).isSuccess() ) {
97 throw std::runtime_error("Component persistent object write failed");
99 getTopLevelTPCnv()->clearTLPersObject();
100 std::size_t cpos = output.find(':');
101 std::size_t bpos = output.find('[');
102 if (cpos == std::string::npos) {
107 if (bpos != std::string::npos) bpos = bpos - cpos;
108 baseAthenaPoolCnv()->keepPoolObj(persObj , output.substr(cpos, bpos));