2 Copyright (C) 2002-2017 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 std::ostringstream ostr;
26 ostr << this->objType();
31 template <class TRANS, class PERS>
33 T_AthenaPoolExtendingCnv< TRANS, PERS >::
34 wasClonedFrom( AthenaConverterTLPExtension *converter )
36 if( !converter->needsCloning() ) {
37 // converter doesn't have any reference to an original converter - must be the original itself
38 m_originalExtendingCnv = dynamic_cast< BaseType* >(converter);
40 // in case of cloning a clone, get the real original converter
41 auto* extcnv = dynamic_cast< T_AthenaPoolExtendingCnv< TRANS, PERS >* >(converter);
42 if (!extcnv) std::abort();
43 m_originalExtendingCnv = extcnv->baseAthenaPoolCnv();
45 // std::cout << " TPCNVINFO: Registering clone source " << (void*)m_originalExtendingCnv << std::endl;
50 template <class TRANS, class PERS>
52 T_AthenaPoolExtendingCnv< TRANS, PERS >::setToken(const std::string& token)
54 // set token in base, so local compareClassGuid() will work
55 BaseType::setToken( token );
56 // set token in the original converter so poolReadObject() will work
57 baseAthenaPoolCnv()->T_AthenaPoolExtendingCnv::BaseType::setToken( token );
62 template <class TRANS, class PERS>
65 T_AthenaPoolExtendingCnv< TRANS, PERS >::
68 // std::cout << " TPCNVINFO: redirecting poolReadObject() to original APcnv" << std::endl;
69 return baseAthenaPoolCnv()->template poolReadObject<P>();
74 template <class TRANS, class PERS>
77 T_AthenaPoolExtendingCnv< TRANS, PERS >::
78 poolReadObject( TopLevelTPCnvBase& tlp_converter )
80 // set which Top level TP concerter will by used for reading
81 usingTPCnvForReading( tlp_converter );
83 P* persObj = poolReadObject< P >();
84 // remember the object we just read
85 tlp_converter.setTLPersObject( persObj );
90 template <class TRANS, class PERS>
92 T_AthenaPoolExtendingCnv< TRANS, PERS >::writeObject(const std::string& key, const std::string& output)
95 PERS *persObj = reinterpret_cast<PERS*>( getTopLevelTPCnv()->getTLPersObjectAsVoid() );
97 //MN - do not pass SG key - this will put the object in a separate container
98 if( !baseAthenaPoolCnv()->objectToPool( persObj, pTok, key, output ).isSuccess() ) {
99 throw std::runtime_error("Component persistent object write failed");
101 getTopLevelTPCnv()->clearTLPersObject();
102 std::size_t cpos = output.find(':');
103 std::size_t bpos = output.find('[');
104 if (cpos == std::string::npos) {
109 if (bpos != std::string::npos) bpos = bpos - cpos;
110 baseAthenaPoolCnv()->keepPoolObj(persObj , output.substr(cpos, bpos));