ATLAS Offline Software
Loading...
Searching...
No Matches
T_AthenaPoolExtendingCnv.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6/** @file T_AthenaPoolExtendingCnv.icc
7 * @brief his file contains method definitions for the templated T_AthenaPoolExtendingCnv class.
8 * @author Marcin.Nowak@cern.ch
9 **/
10
11
12
13template <class TRANS, class PERS>
14T_AthenaPoolExtendingCnv< TRANS, PERS >::T_AthenaPoolExtendingCnv(ISvcLocator* svcloc) :
15 T_AthenaPoolCustomCnv<TRANS, PERS>( svcloc ),
16 m_originalExtendingCnv( 0 )
17{}
18
19
20#include <sstream>
21template <class TRANS, class PERS>
22inline const std::string
23T_AthenaPoolExtendingCnv< TRANS, PERS >::name() const
24{
25 return std::to_string(this->objType());
26}
27
28
29template <class TRANS, class PERS>
30inline void
31T_AthenaPoolExtendingCnv< TRANS, PERS >::
32wasClonedFrom( AthenaConverterTLPExtension *converter )
33{
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);
37 } else {
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();
42 }
43// std::cout << " TPCNVINFO: Registering clone source " << (void*)m_originalExtendingCnv << std::endl;
44}
45
46
47
48template <class TRANS, class PERS>
49inline void
50T_AthenaPoolExtendingCnv< TRANS, PERS >::setToken(const std::string& token)
51{
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 );
56}
57
58
59
60template <class TRANS, class PERS>
61template <class P>
62inline P*
63T_AthenaPoolExtendingCnv< TRANS, PERS >::
64poolReadObject()
65{
66 // std::cout << " TPCNVINFO: redirecting poolReadObject() to original APcnv" << std::endl;
67 return baseAthenaPoolCnv()->template poolReadObject<P>();
68}
69
70
71
72template <class TRANS, class PERS>
73template <class P>
74void
75T_AthenaPoolExtendingCnv< TRANS, PERS >::
76poolReadObject( TopLevelTPCnvBase& tlp_converter )
77{
78 // set which Top level TP concerter will by used for reading
79 usingTPCnvForReading( tlp_converter );
80 // read the object
81 P* persObj = poolReadObject< P >();
82 // remember the object we just read
83 tlp_converter.setTLPersObject( persObj );
84}
85
86
87
88template <class TRANS, class PERS>
89std::unique_ptr<const Token>
90T_AthenaPoolExtendingCnv< TRANS, PERS >::writeObject(const std::string& key, const std::string& output)
91{
92 std::unique_ptr<Token> pTok;
93 PERS *persObj = reinterpret_cast<PERS*>( getTopLevelTPCnv()->getTLPersObjectAsVoid() );
94 if( persObj ) {
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");
98 }
99 getTopLevelTPCnv()->clearTLPersObject();
100 std::size_t cpos = output.find(':');
101 std::size_t bpos = output.find('[');
102 if (cpos == std::string::npos) {
103 cpos = 0;
104 } else {
105 cpos++;
106 }
107 if (bpos != std::string::npos) bpos = bpos - cpos;
108 baseAthenaPoolCnv()->keepPoolObj(persObj , output.substr(cpos, bpos));
109 }
110 return pTok;
111}
112