ATLAS Offline Software
T_AthenaPoolCustomCnv.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENAPOOLCNVSVC_T_ATHENAPOOLCUSTOMCNV_H
6 #define ATHENAPOOLCNVSVC_T_ATHENAPOOLCUSTOMCNV_H
7 
13 #include "GaudiKernel/ThreadLocalContext.h"
14 #include "GaudiKernel/EventContext.h"
15 #include "T_AthenaPoolCustCnv.h"
16 
17 #include <vector>
18 
19 // class TopLevelTPCnvBase;
20 // need the TopLevelTPCnvBase typedef still
22 
23 // forward declarations:
24 template <class T, class P> class T_AthenaPoolExtendingCnv;
25 
33 template <class TRANS, class PERS>
35 {
38 friend class T_AthenaPoolExtendingCnv<TRANS,PERS>;
39 
40 public:
42 
46  T_AthenaPoolCustomCnvWithKey(ISvcLocator* pSvcLocator,
47  const char* name = nullptr);
48 
49 protected:
50 
51  // the 2 following methods are allowed to throw std::runtime_error
52 
59  virtual PERS* createPersistentWithKey(TRANS* obj, const std::string& key) = 0;
60 
69  virtual TRANS* createTransientWithKey(const std::string& key) = 0;
70 
76  template <class P>
78 
85  template <class P>
86  void poolReadObject(TopLevelTPCnvBase& tlp_converter);
87 
90  void keepPoolObj(PERS* obj, const std::string& output);
91 
94  virtual StatusCode transToPers(TRANS*, PERS*&) override { return(StatusCode::FAILURE); }
96  virtual StatusCode persToTrans(TRANS*&, PERS*) override { return(StatusCode::FAILURE); }
97 
101  virtual StatusCode DataObjectToPers(DataObject* pObj, IOpaqueAddress*& pAddr) override;
102 
106  virtual StatusCode DataObjectToPool(IOpaqueAddress* pAddr, DataObject* pObj) override;
107 
112  virtual StatusCode PoolToDataObject(DataObject*& pObj, const Token* token,
113  const std::string& key) override;
114 
116  virtual StatusCode cleanUp(const std::string& output) override;
117 
120  std::map<std::string, std::vector< std::unique_ptr<PERS> > > m_persObjLists;
121 
124 };
125 
129 template <class TRANS, class PERS>
131  : public T_AthenaPoolCustomCnvWithKey<TRANS, PERS>
132 {
133 protected:
135 
136  virtual PERS* createPersistent(TRANS* obj) = 0;
137  virtual PERS* createPersistentWithKey(TRANS* obj, const std::string& /*key*/) override;
138 
139  virtual TRANS* createTransient() = 0;
140  virtual TRANS* createTransientWithKey(const std::string& /*key*/) override;
141 };
142 
144 
145 #endif
T_AthenaPoolCustomCnvWithKey::cleanUp
virtual StatusCode cleanUp(const std::string &output) override
Callback from the CleanupSvc to delete persistent object in the local list.
T_AthenaPoolCustomCnv.icc
T_AthenaPoolCustomCnvWithKey::m_persObjLists
std::map< std::string, std::vector< std::unique_ptr< PERS > > > m_persObjLists
Local cache for persistent objects created by this converter, grouped by processing slot These object...
Definition: T_AthenaPoolCustomCnv.h:120
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
DMTest::P
P_v1 P
Definition: P.h:23
AthenaPoolTopLevelTPCnvBase.h
T_AthenaPoolCustomCnvWithKey::createTransientWithKey
virtual TRANS * createTransientWithKey(const std::string &key)=0
method to be implemented by the developer.
T_AthenaPoolCustomCnvWithKey::keepPoolObj
void keepPoolObj(PERS *obj, const std::string &output)
Remember the POOL object to be written out (will be deleted after commit)
T_AthenaPoolCustomCnvWithKey::m_pListMutex
std::mutex m_pListMutex
protection mutex for m_persObjLists
Definition: T_AthenaPoolCustomCnv.h:123
T_AthenaPoolCustomCnvWithKey::T_AthenaPoolCustomCnvWithKey
T_AthenaPoolCustomCnvWithKey(ISvcLocator *pSvcLocator, const char *name=nullptr)
Constructor.
T_AthenaPoolCustCnv
This templated class provides the converter to translate an object to/from its persistent POOL repres...
Definition: T_AthenaPoolCustCnv.h:35
T_AthenaPoolCustCnv.h
his file contains the class definition for the templated T_AthenaPoolCustCnv class.
T_AthenaPoolCustomCnvWithKey::DataObjectToPool
virtual StatusCode DataObjectToPool(IOpaqueAddress *pAddr, DataObject *pObj) override
Write an object into POOL.
T_AthenaPoolCustomCnvWithKey
This templated class extends T_AthenaPoolCustCnv to provide management of the persistent objects crea...
Definition: T_AthenaPoolCustomCnv.h:35
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
T_AthenaPoolCustomCnvWithKey::BaseType
T_AthenaPoolCustCnv< TRANS, PERS > BaseType
Definition: T_AthenaPoolCustomCnv.h:41
T_AthenaPoolCustomCnv
Compatibility for old converter classes that don't get passed the key.
Definition: T_AthenaPoolCustomCnv.h:132
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
T_AthenaPoolCustomCnvWithKey::transToPers
virtual StatusCode transToPers(TRANS *, PERS *&) override
Obsolete methods replaced by createPersistent() and createTransient() obsolete.
Definition: T_AthenaPoolCustomCnv.h:94
T_AthenaPoolCustomCnvWithKey::poolReadObject
void poolReadObject(TopLevelTPCnvBase &tlp_converter)
Read object of type P (plus all extending objects) using the indicated top-level TP converter.
T_AthenaPoolCustomCnvWithKey::PoolToDataObject
virtual StatusCode PoolToDataObject(DataObject *&pObj, const Token *token, const std::string &key) override
Read an object from POOL.
T_AthenaPoolCustomCnvWithKey::createPersistentWithKey
virtual PERS * createPersistentWithKey(TRANS *obj, const std::string &key)=0
method to be implemented by the developer.
merge.output
output
Definition: merge.py:17
T_AthenaPoolCustomCnv::createTransientWithKey
virtual TRANS * createTransientWithKey(const std::string &) override
method to be implemented by the developer.
TopLevelTPCnvBase
Base class for top-level TP converters.
Definition: TopLevelTPCnvBase.h:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RpcSectorLogicContainer_p1
Class to represent.
Definition: RpcSectorLogicContainer_p1.h:19
T_AthenaPoolCustomCnvWithKey::poolReadObject
P * poolReadObject()
Read object of type P.
T_AthenaPoolCustomCnv::createPersistentWithKey
virtual PERS * createPersistentWithKey(TRANS *obj, const std::string &) override
method to be implemented by the developer.
python.PyAthena.obj
obj
Definition: PyAthena.py:132
T_AthenaPoolCustomCnv::createTransient
virtual TRANS * createTransient()=0
T_AthenaPoolCustomCnv::createPersistent
virtual PERS * createPersistent(TRANS *obj)=0
T_AthenaPoolExtendingCnv
This templated class extends T_AthenaPoolCustomCnv to provide additional/chaged functionality for Ath...
Definition: T_AthenaPoolCustomCnv.h:24
T_AthenaPoolCustomCnvWithKey::DataObjectToPers
virtual StatusCode DataObjectToPers(DataObject *pObj, IOpaqueAddress *&pAddr) override
Convert an object into Persistent.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
T_AthenaPoolCustomCnvWithKey::persToTrans
virtual StatusCode persToTrans(TRANS *&, PERS *) override
obsolete
Definition: T_AthenaPoolCustomCnv.h:96