ATLAS Offline Software
Loading...
Searching...
No Matches
T_AthenaPoolLegacyCnv.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ATHENAPOOLCNVSVC_T_ATHENAPOOLLEGACYCNV_H
6#define ATHENAPOOLCNVSVC_T_ATHENAPOOLLEGACYCNV_H
7
13
15
22template<class TRANS, class PERS, class LEGACY>
23class T_AthenaPoolLegacyCnv : public T_AthenaPoolCustomCnv< TRANS, PERS >
24{
27
28 // define an internal AthenaPool converter that will create the old representation LEGACY
29 class LegacyCnv : public BaseLegacyCnv
30 {
32 public:
35 LegacyCnv( ISvcLocator* svcloc, T_AthenaPoolLegacyCnv *owner )
36 : BaseLegacyCnv( svcloc ), m_ownerCnv( owner )
37 {}
38
39 // forward createPersistent() request to the main converter, where the user
40 // provides createLegacy() method to do that
41 virtual LEGACY* createPersistent( TRANS* transCont ) override final {
42 return m_ownerCnv->createLegacy( transCont );
43 }
44 // unused virtual method that still needs to be defined
45 virtual TRANS* createTransient() override final { return nullptr; };
46 };
47
48 // this is the converter that knows how to produce and manage LEGACY representations
49 std::unique_ptr<LegacyCnv> m_oldAPCnv;
50
51public:
52 T_AthenaPoolLegacyCnv( ISvcLocator* svcloc ) : BaseCnv(svcloc) { }
53
54protected:
56 virtual StatusCode DataObjectToPool(IOpaqueAddress* pAddr, DataObject* pObj) override final {
57 if( writingLegacy() ) {
58 if( !m_oldAPCnv ) {
59 m_oldAPCnv = std::make_unique<LegacyCnv>( this->serviceLocator() , this );
60 StatusCode sc = m_oldAPCnv->initialize();
61 if( !sc.isSuccess() ) {
62 ATH_MSG_ERROR("Failed to initialize old converter");
63 return sc;
64 }
65 }
66 return m_oldAPCnv->DataObjectToPool( pAddr, pObj );
67 }
68 return BaseCnv::DataObjectToPool( pAddr, pObj );
69 }
70
72 virtual TRANS* createTransient () override = 0;
73 virtual PERS* createPersistent( TRANS* ) override = 0;
74
76 virtual LEGACY* createLegacy( TRANS* ) = 0;
80 virtual bool writingLegacy() = 0;
81};
82
83
84#endif
#define ATH_MSG_ERROR(x)
static Double_t sc
RpcSectorLogicContainer_p1 PERS
his file contains the class definition for the templated T_AthenaPoolCustomCnv class.
virtual StatusCode DataObjectToPool(IOpaqueAddress *pAddr, DataObject *pObj)=0
Write an object into POOL.
virtual StatusCode DataObjectToPool(IOpaqueAddress *pAddr, DataObject *pObj) override
Compatibility for old converter classes that don't get passed the key.
LegacyCnv(ISvcLocator *svcloc, T_AthenaPoolLegacyCnv *owner)
virtual LEGACY * createPersistent(TRANS *transCont) override final
virtual TRANS * createTransient() override final
virtual LEGACY * createLegacy(TRANS *)=0
additional user-supplied method that creates LEGACY representation
std::unique_ptr< LegacyCnv > m_oldAPCnv
virtual bool writingLegacy()=0
user-supplied method that makes this converter write PERS if False or LEGACY if True in the current A...
T_AthenaPoolCustomCnv< TRANS, LEGACY > BaseLegacyCnv
virtual StatusCode DataObjectToPool(IOpaqueAddress *pAddr, DataObject *pObj) override final
DataObjectToPool() that dispatches to the right converter based on writingLegacy()
virtual TRANS * createTransient() override=0
standard user-supplied methods to create TRANS and PERS representations
T_AthenaPoolCustomCnv< TRANS, PERS > BaseCnv
T_AthenaPoolLegacyCnv(ISvcLocator *svcloc)
virtual PERS * createPersistent(TRANS *) override=0