ATLAS Offline Software
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 
14 #include "T_AthenaPoolCustomCnv.h"
15 
22 template<class TRANS, class PERS, class LEGACY>
23 class 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 
51 public:
52  T_AthenaPoolLegacyCnv( ISvcLocator* svcloc ) : BaseCnv(svcloc) { }
53 
54 protected:
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
T_AthenaPoolLegacyCnv::BaseCnv
T_AthenaPoolCustomCnv< TRANS, PERS > BaseCnv
Definition: T_AthenaPoolLegacyCnv.h:25
T_AthenaPoolLegacyCnv::LegacyCnv
Definition: T_AthenaPoolLegacyCnv.h:30
T_AthenaPoolLegacyCnv::LegacyCnv::createTransient
virtual TRANS * createTransient() override final
Definition: T_AthenaPoolLegacyCnv.h:45
T_AthenaPoolLegacyCnv::LegacyCnv::m_ownerCnv
T_AthenaPoolLegacyCnv * m_ownerCnv
Definition: T_AthenaPoolLegacyCnv.h:31
T_AthenaPoolLegacyCnv::LegacyCnv::createPersistent
virtual LEGACY * createPersistent(TRANS *transCont) override final
Definition: T_AthenaPoolLegacyCnv.h:41
T_AthenaPoolLegacyCnv::T_AthenaPoolLegacyCnv
T_AthenaPoolLegacyCnv(ISvcLocator *svcloc)
Definition: T_AthenaPoolLegacyCnv.h:52
T_AthenaPoolCustomCnvWithKey::DataObjectToPool
virtual StatusCode DataObjectToPool(IOpaqueAddress *pAddr, DataObject *pObj) override
Write an object into POOL.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
T_AthenaPoolCustomCnv
Compatibility for old converter classes that don't get passed the key.
Definition: T_AthenaPoolCustomCnv.h:132
T_AthenaPoolLegacyCnv::LegacyCnv::LegacyCnv
LegacyCnv(ISvcLocator *svcloc, T_AthenaPoolLegacyCnv *owner)
Definition: T_AthenaPoolLegacyCnv.h:35
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
T_AthenaPoolCustomCnv.h
his file contains the class definition for the templated T_AthenaPoolCustomCnv class.
T_AthenaPoolLegacyCnv::writingLegacy
virtual bool writingLegacy()=0
user-supplied method that makes this converter write PERS if False or LEGACY if True in the current A...
RpcSectorLogicContainer_p1
Class to represent.
Definition: RpcSectorLogicContainer_p1.h:19
T_AthenaPoolLegacyCnv::m_oldAPCnv
std::unique_ptr< LegacyCnv > m_oldAPCnv
Definition: T_AthenaPoolLegacyCnv.h:49
T_AthenaPoolLegacyCnv::DataObjectToPool
virtual StatusCode DataObjectToPool(IOpaqueAddress *pAddr, DataObject *pObj) override final
DataObjectToPool() that dispatches to the right converter based on writingLegacy()
Definition: T_AthenaPoolLegacyCnv.h:56
T_AthenaPoolLegacyCnv::BaseLegacyCnv
T_AthenaPoolCustomCnv< TRANS, LEGACY > BaseLegacyCnv
Definition: T_AthenaPoolLegacyCnv.h:26
T_AthenaPoolLegacyCnv::createPersistent
virtual PERS * createPersistent(TRANS *) override=0
T_AthenaPoolCustCnv::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
T_AthenaPoolLegacyCnv::createTransient
virtual TRANS * createTransient() override=0
standard user-supplied methods to create TRANS and PERS representations
T_AthenaPoolLegacyCnv::createLegacy
virtual LEGACY * createLegacy(TRANS *)=0
additional user-supplied method that creates LEGACY representation
T_AthenaPoolLegacyCnv
This templated class extends T_AthenaPoolCustomCnv with the ability to write odditional persistent re...
Definition: T_AthenaPoolLegacyCnv.h:24