ATLAS Offline Software
AthenaPoolConverter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENAPOOLCNVSVC_ATHENAPOOLCONVERTER_H
6 #define ATHENAPOOLCNVSVC_ATHENAPOOLCONVERTER_H
7 
13 #include "GaudiKernel/Converter.h"
14 #include "GaudiKernel/ServiceHandle.h"
17 #include "StoreGate/StoreGateSvc.h"
18 #include "DataModelRoot/RootType.h"
20 #include "PoolSvc/IPoolSvc.h"
21 
22 #include <string>
23 #include <map>
24 #include <mutex>
25 
26 class IOpaqueAddress;
27 class DataObject;
28 class StatusCode;
29 class IAthenaPoolCnvSvc;
30 class Guid;
31 class Placement;
32 class Token;
33 
35 template <class TYPE> class CnvFactory;
36 
41 class AthenaPoolConverter : public ::Converter, public ::AthMessaging, virtual public IAthenaPoolCleanUp {
42 
43 public:
45  virtual ~AthenaPoolConverter();
46 
48  virtual StatusCode initialize() override;
49  virtual StatusCode finalize() override;
50 
51  virtual long repSvcType() const override;
52 
56  virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj) override;
57 
61  virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& pAddr) override;
62 
66  virtual StatusCode fillRepRefs(IOpaqueAddress* pAddr, DataObject* pObj) override;
67 
69  const ServiceHandle<StoreGateSvc>& detStore() const { return m_detStore; }
70 
72  static long storageType();
73 
75  static const CLID& classID();
76 
78  virtual StatusCode cleanUp(const std::string& output) override;
79 
80 
81 protected:
83  AthenaPoolConverter(const CLID& id, ISvcLocator* pSvcLocator,
84  const char* name = nullptr);
85 
89  virtual StatusCode DataObjectToPers(DataObject* pObj, IOpaqueAddress*& pAddr) = 0;
90 
94  virtual StatusCode DataObjectToPool(IOpaqueAddress* pAddr, DataObject* pObj) = 0;
95 
100  virtual StatusCode PoolToDataObject(DataObject*& pObj, const Token* token,
101  const std::string& key) = 0;
102 
106  virtual Placement setPlacementWithType(const std::string& tname, const std::string& key, const std::string& output);
108  virtual Placement setPlacement(const std::string& key, const std::string& output) = 0;
109 
111  virtual const DataObject* getDataObject() const;
112 
113  bool compareClassGuid(const Guid &guid) const;
114 
115 protected: // data
119 
120  typedef std::map<std::string, RootType> ClassMap;
121  typedef ClassMap::const_iterator ClassMapIt;
122  std::string m_className;
124 
125  std::string m_containerPrefix;
126  std::string m_containerNameHint;
127  std::string m_branchNameHint;
128 
129  const DataObject* m_dataObject;
131 
134 };
135 
136 #endif
AthenaPoolConverter::setPlacementWithType
virtual Placement setPlacementWithType(const std::string &tname, const std::string &key, const std::string &output)
Set POOL placement hint for a given type.
Definition: AthenaPoolConverter.cxx:174
AthenaPoolConverter::m_dataObject
const DataObject * m_dataObject
Definition: AthenaPoolConverter.h:129
Placement
This class holds all the necessary information to guide the writing of an object in a physical place.
Definition: Placement.h:19
AthenaPoolConverter::m_classDescs
ClassMap m_classDescs
Definition: AthenaPoolConverter.h:123
AthenaPoolConverter::DataObjectToPool
virtual StatusCode DataObjectToPool(IOpaqueAddress *pAddr, DataObject *pObj)=0
Write an object into POOL.
AthCheckMacros.h
AthenaPoolConverter::m_athenaPoolCnvSvc
ServiceHandle< IAthenaPoolCnvSvc > m_athenaPoolCnvSvc
Definition: AthenaPoolConverter.h:117
AthenaPoolConverter::~AthenaPoolConverter
virtual ~AthenaPoolConverter()
Destructor.
Definition: AthenaPoolConverter.cxx:23
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
AthenaPoolConverter::setPlacement
virtual Placement setPlacement(const std::string &key, const std::string &output)=0
Set POOL placement hint; pure virtual method implemented by classes templated by type.
AthenaPoolConverter::compareClassGuid
bool compareClassGuid(const Guid &guid) const
Definition: AthenaPoolConverter.cxx:271
AthenaPoolConverter::storageType
static long storageType()
Definition: AthenaPoolConverter.cxx:153
IAthenaPoolCleanUp
This class provides the interface for the AthenaPoolCleanUp which is used to clean up AthenaPoolConve...
Definition: IAthenaPoolCleanUp.h:19
AthenaPoolConverter::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Definition: AthenaPoolConverter.h:116
AthenaPoolConverter::m_className
std::string m_className
Definition: AthenaPoolConverter.h:122
AthenaPoolConverter::repSvcType
virtual long repSvcType() const override
Definition: AthenaPoolConverter.cxx:57
AthenaPoolConverter::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: AthenaPoolConverter.cxx:27
AthenaPoolConverter::m_conv_mut
CallMutex m_conv_mut
Definition: AthenaPoolConverter.h:133
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
AthenaPoolConverter::CallMutex
std::mutex CallMutex
Definition: AthenaPoolConverter.h:132
AthenaPoolConverter::ClassMapIt
ClassMap::const_iterator ClassMapIt
Definition: AthenaPoolConverter.h:121
AthenaPoolConverter
This class provides the abstract converter to translate an object to/from its persistent POOL represe...
Definition: AthenaPoolConverter.h:41
AthenaPoolConverter::cleanUp
virtual StatusCode cleanUp(const std::string &output) override
Implement cleanUp for AthenaPoolConverter to do nothing.
Definition: AthenaPoolConverter.cxx:275
AthenaPoolConverter::m_i_poolToken
const Token * m_i_poolToken
Definition: AthenaPoolConverter.h:130
AthenaPoolConverter::classID
static const CLID & classID()
AthenaPoolConverter::AthenaPoolConverter
AthenaPoolConverter(const CLID &id, ISvcLocator *pSvcLocator, const char *name=nullptr)
Standard Service Constructor.
Definition: AthenaPoolConverter.cxx:157
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IAthenaPoolCleanUp.h
This file contains the class definition for the IAthenaPoolCleanUp class.
AthenaPoolConverter::m_containerPrefix
std::string m_containerPrefix
Definition: AthenaPoolConverter.h:125
AthenaPoolConverter::m_containerNameHint
std::string m_containerNameHint
Definition: AthenaPoolConverter.h:126
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
CnvFactory
Abstract factory to create the converter.
Definition: ToyConverter.h:16
AthenaPoolConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: AthenaPoolConverter.h:69
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
AthenaPoolConverter::fillRepRefs
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddr, DataObject *pObj) override
Create a POOL persistent representation for a transient object.
Definition: AthenaPoolConverter.cxx:139
pool_uuid.guid
guid
Definition: pool_uuid.py:112
merge.output
output
Definition: merge.py:17
Converter
Definition: Converter.h:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthenaPoolConverter::PoolToDataObject
virtual StatusCode PoolToDataObject(DataObject *&pObj, const Token *token, const std::string &key)=0
Read an object from POOL.
IPoolSvc.h
This file contains the class definition for the IPoolSvc interface class.
AthenaPoolConverter::DataObjectToPers
virtual StatusCode DataObjectToPers(DataObject *pObj, IOpaqueAddress *&pAddr)=0
Convert an object into Persistent.
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:20
AthenaPoolConverter::ClassMap
std::map< std::string, RootType > ClassMap
Definition: AthenaPoolConverter.h:120
AthenaPoolConverter::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr) override
Create a POOL persistent representation for a transient object.
Definition: AthenaPoolConverter.cxx:110
AthenaPoolConverter::m_branchNameHint
std::string m_branchNameHint
Definition: AthenaPoolConverter.h:127
AthMessaging.h
RootType.h
AthenaPoolConverter::getDataObject
virtual const DataObject * getDataObject() const
Definition: AthenaPoolConverter.cxx:267
AthenaPoolConverter::finalize
virtual StatusCode finalize() override
Definition: AthenaPoolConverter.cxx:49
AthenaPoolConverter::m_classDesc
RootType m_classDesc
Definition: AthenaPoolConverter.h:118
StoreGateSvc.h
AthenaPoolConverter::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Create a transient object from a POOL persistent representation.
Definition: AthenaPoolConverter.cxx:61
ServiceHandle< StoreGateSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
TScopeAdapter
Definition: RootType.h:119
IAthenaPoolCnvSvc
This class provides the interface between Athena and PoolSvc.
Definition: IAthenaPoolCnvSvc.h:34