ATLAS Offline Software
INav4MomAssocsCnv.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // INav4MomAssocsCnv.cxx
8 // Implementation file for class INav4MomAssocsCnv
9 // Author: S.Binet<binet@cern.ch>
11 
12 // STL includes
13 
14 // Framework includes
15 #include "GaudiKernel/MsgStream.h"
16 #include "StoreGate/StoreGateSvc.h"
17 
18 // EventCommonAthenaPool includes
19 #include "INav4MomAssocsCnv.h"
20 
24 
25 INav4MomAssocsCnv::INav4MomAssocsCnv( ISvcLocator* svcLocator ) :
26  T_AthenaPoolCustomCnv<INav4MomAssocs, INav4MomAssocs_PERS>(svcLocator, "INav4MomAssocsCnv"),
27  m_storeGate("StoreGateSvc", "INav4MomAssocsCnv")
28 {
29  if ( 0 == svcLocator ) {
30  throw std::runtime_error("NULL pointer to ISvcLocator !!");
31  }
32 
33  if ( m_storeGate.retrieve().isFailure() ) {
34  throw std::runtime_error("Could not fetch StoreGateSvc !!");
35  }
36 }
37 
41 
43 // Protected methods:
45 
46 
49 {
50  INav4MomAssocs_PERS *persObj = m_tpConverter_p3.createPersistent( transCont, msg() );
51 
52  return persObj;
53 }
54 
56 {
57  INav4MomAssocs *transObj = 0;
58 
59  static const pool::Guid tr_guid("DF941034-CCB2-4A1A-9A8C-5F3D5EAFD08C");
60  static const pool::Guid p1_guid("85027AE1-4FD4-4808-B151-5485634ACD5D");
61  static const pool::Guid p2_guid("8040BEAA-BC65-43B8-B468-A7157C89ACB3");
62  static const pool::Guid p3_guid("455AEE6B-9834-4E72-8F81-2532A52E3BE7");
63 
64  if( compareClassGuid(p3_guid) ) {
65  // using unique_ptr ensures deletion of the persistent object
66  std::unique_ptr<INav4MomAssocs_p3> persObj( poolReadObject<INav4MomAssocs_p3>() );
67  transObj = m_tpConverter_p3.createTransient( persObj.get(), msg() );
68  }
69  else if ( compareClassGuid(p2_guid) ) {
70  // using unique_ptr ensures deletion of the persistent object
71  std::unique_ptr<INav4MomAssocs_p2> persObj( poolReadObject<INav4MomAssocs_p2>() );
72  transObj = m_tpConverter_p2.createTransient( persObj.get(), msg() );
73  }
74  else if( compareClassGuid(p1_guid) ) {
75  // using unique_ptr ensures deletion of the persistent object
76  std::unique_ptr<INav4MomAssocs_p1> persObj( poolReadObject<INav4MomAssocs_p1>() );
77  INav4MomAssocsCnv_p1 cnv( m_storeGate.get() );
78  transObj = cnv.createTransient( persObj.get(), msg() );
79  }
80  else if( compareClassGuid(tr_guid) ) {
81  // regular object from before the T/P separation
82  return poolReadObject<INav4MomAssocs>();
83  }
84  else {
85  throw std::runtime_error("Unsupported persistent version of INav4MomAssocs");
86  }
87 
88  return transObj;
89 }
INav4MomAssocsCnv.h
TPPolyCnvBase::createTransient
virtual TRANS * createTransient(const PERS *persObj, MsgStream &log)
Create transient representation of a persistent object.
INav4MomAssocsCnv::createPersistent
virtual INav4MomAssocs_PERS * createPersistent(INav4MomAssocs *transCont)
Build the persistent representation from the transient one.
Definition: INav4MomAssocsCnv.cxx:48
TPAbstractPolyCnvBase::createPersistent
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
INav4MomAssocsCnv::INav4MomAssocsCnv
INav4MomAssocsCnv(ISvcLocator *svcloc)
Create the converter from the service locator.
Definition: INav4MomAssocsCnv.cxx:25
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
INav4MomAssocs_p3
Definition: INav4MomAssocs_p3.h:27
INav4MomAssocsCnv::m_tpConverter_p2
INav4MomAssocsCnv_p2 m_tpConverter_p2
Definition: INav4MomAssocsCnv.h:75
T_AthenaPoolCustomCnv
Compatibility for old converter classes that don't get passed the key.
Definition: T_AthenaPoolCustomCnv.h:132
INav4MomAssocsCnv::m_tpConverter_p3
INav4MomAssocsCnv_p3 m_tpConverter_p3
Definition: INav4MomAssocsCnv.h:74
INav4MomAssocsCnv::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Pointer to the StoreGateSvc.
Definition: INav4MomAssocsCnv.h:72
INav4MomAssocs
Definition: INav4MomAssocs.h:33
INav4MomAssocsCnv::createTransient
virtual INav4MomAssocs * createTransient()
Build the transient representation from a persistent one.
Definition: INav4MomAssocsCnv.cxx:55
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
INav4MomAssocsCnv_p1
Definition: INav4MomAssocsCnv_p1.h:36
T_AthenaPoolCustCnv< INav4MomAssocs, INav4MomAssocs_PERS >::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
StoreGateSvc.h