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>
49template <class P>
50inline P*
51T_AthenaPoolExtendingCnv< TRANS, PERS >::
52poolReadObject(const Token* token)
53{
54 // std::cout << " TPCNVINFO: redirecting poolReadObject() to original APcnv" << std::endl;
55 return baseAthenaPoolCnv()->template poolReadObject<P>(token);
56}
57
58
59
60template <class TRANS, class PERS>
61template <class P>
62void
63T_AthenaPoolExtendingCnv< TRANS, PERS >::
64poolReadObject( TopLevelTPCnvBase& tlp_converter, const Token* token )
65{
66 // set which Top level TP concerter will by used for reading
67 usingTPCnvForReading( tlp_converter );
68 // read the object
69 P* persObj = poolReadObject< P >( token );
70 // remember the object we just read
71 tlp_converter.setTLPersObject( persObj );
72}
73
74
75
76template <class TRANS, class PERS>
77std::unique_ptr<const Token>
78T_AthenaPoolExtendingCnv< TRANS, PERS >::writeObject(const std::string& key, const std::string& output)
79{
80 std::unique_ptr<Token> pTok;
81 PERS *persObj = reinterpret_cast<PERS*>( getTopLevelTPCnv()->getTLPersObjectAsVoid() );
82 if( persObj ) {
83 //MN - do not pass SG key - this will put the object in a separate container
84 if( !baseAthenaPoolCnv()->objectToPool( persObj, pTok, key, output ).isSuccess() ) {
85 throw std::runtime_error("Component persistent object write failed");
86 }
87 getTopLevelTPCnv()->clearTLPersObject();
88 std::size_t cpos = output.find(':');
89 std::size_t bpos = output.find('[');
90 if (cpos == std::string::npos) {
91 cpos = 0;
92 } else {
93 cpos++;
94 }
95 if (bpos != std::string::npos) bpos = bpos - cpos;
96 baseAthenaPoolCnv()->keepPoolObj(persObj , output.substr(cpos, bpos));
97 }
98 return pTok;
99}
100