ATLAS Offline Software
TopLevelTPCnvBaseP.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TopLevelTPCnvBaseP_H
6 #define TopLevelTPCnvBaseP_H
7 
14 #include "TopLevelTPCnvBase.h"
15 
24 template< class TL_PERS >
26  : public TopLevelTPCnvBase
27 {
28 public:
29 
30  // ---- Methods to be implement in the derived converter:
31 
38  virtual void setPStorage( TL_PERS* persObj) = 0;
39 
40 
42 
44 
47 
48 
49  // --------------- internals - "non-public" use
50 
52  virtual bool hasTLPersObject() const override {
53  return m_tlPersObject;
54  }
55 
57  virtual void createTLPersObject() override {
58  m_tlPersObject = new TL_PERS();
60  }
61 
63  // cppcheck-suppress virtualCallInConstructor
64  virtual void deleteTLPersObject() override {
65  if( m_tlPersObject ) {
66  delete m_tlPersObject;
68  }
69  }
70 
72  TL_PERS* getTLPersObject() {
73  return m_tlPersObject;
74  }
75 
77  const TL_PERS* getTLPersObject() const {
78  return m_tlPersObject;
79  }
80 
82  TL_PERS* releaseTLPersObject() {
83  TL_PERS *tmp = m_tlPersObject;
85  return tmp;
86  }
87 
89  virtual void* getTLPersObjectAsVoid() override {
90  return getTLPersObject();
91  }
92 
94  virtual const void* getTLPersObjectAsVoid() const override {
95  return getTLPersObject();
96  }
97 
99  virtual void clearTLPersObject() override {
100  m_tlPersObject = 0;
101  }
102 
104  virtual void setTLPersObject( void *persObj ) override {
105  if( m_tlPersObject ) delete m_tlPersObject;
106  m_tlPersObject = reinterpret_cast<TL_PERS*>( persObj );
108  }
109 
110 
112  virtual TPCnvTokenList_p1* getTokenListVar() override { return 0; }
113 
115  virtual TPCnvTokenList_p1* getTokenListVarFrom( void *persObj ) override {
116  // avoid setting up the pointer to persistent object
117  // (can lead to deleting it twice, if the user deletes too)
118  TL_PERS *tmp = m_tlPersObject;
119  m_tlPersObject = reinterpret_cast<TL_PERS*>( persObj );
120  TPCnvTokenList_p1 *toklist = getTokenListVar();
122  return toklist;
123  }
124 
125 
126 protected:
128  TL_PERS* m_tlPersObject;
129 
130 };
131 
132 #endif
TPCnvTokenList_p1
Definition: TPCnvTokenList_p1.h:55
TopLevelTPCnvBaseP::getTokenListVarFrom
virtual TPCnvTokenList_p1 * getTokenListVarFrom(void *persObj) override
Return the list of tokens to the objects extending the object NOT owned by this converter.
Definition: TopLevelTPCnvBaseP.h:115
TopLevelTPCnvBaseP::~TopLevelTPCnvBaseP
virtual ~TopLevelTPCnvBaseP()
Definition: TopLevelTPCnvBaseP.h:43
TopLevelTPCnvBaseP
Definition: TopLevelTPCnvBaseP.h:27
TopLevelTPCnvBaseP::getTokenListVar
virtual TPCnvTokenList_p1 * getTokenListVar() override
Return the list of tokens to the objects extending the object owned by this converter.
Definition: TopLevelTPCnvBaseP.h:112
TopLevelTPCnvBaseP::getTLPersObject
TL_PERS * getTLPersObject()
Definition: TopLevelTPCnvBaseP.h:72
TopLevelTPCnvBaseP::operator=
TopLevelTPCnvBaseP & operator=(const TopLevelTPCnvBaseP &)=delete
TopLevelTPCnvBaseP::getTLPersObjectAsVoid
virtual void * getTLPersObjectAsVoid() override
Definition: TopLevelTPCnvBaseP.h:89
TopLevelTPCnvBaseP::getTLPersObjectAsVoid
virtual const void * getTLPersObjectAsVoid() const override
Definition: TopLevelTPCnvBaseP.h:94
TopLevelTPCnvBaseP::deleteTLPersObject
virtual void deleteTLPersObject() override
Delete the persistent object owned by the converter.
Definition: TopLevelTPCnvBaseP.h:64
TopLevelTPCnvBaseP::clearTLPersObject
virtual void clearTLPersObject() override
Discard the persistent object.
Definition: TopLevelTPCnvBaseP.h:99
TopLevelTPCnvBaseP::setPStorage
virtual void setPStorage(TL_PERS *persObj)=0
A stub for a method that should be provided by the converter creator.
TopLevelTPCnvBaseP::getTLPersObject
const TL_PERS * getTLPersObject() const
Definition: TopLevelTPCnvBaseP.h:77
TopLevelTPCnvBaseP::TopLevelTPCnvBaseP
TopLevelTPCnvBaseP(const TopLevelTPCnvBaseP &)=delete
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
TopLevelTPCnvBaseP::releaseTLPersObject
TL_PERS * releaseTLPersObject()
@release the persistent object from this converter
Definition: TopLevelTPCnvBaseP.h:82
TopLevelTPCnvBase
Base class for top-level TP converters.
Definition: TopLevelTPCnvBase.h:32
TopLevelTPCnvBaseP::m_tlPersObject
TL_PERS * m_tlPersObject
The persistent object this conveter is working on.
Definition: TopLevelTPCnvBaseP.h:128
TopLevelTPCnvBaseP::setTLPersObject
virtual void setTLPersObject(void *persObj) override
Take ownership of the persistent object.
Definition: TopLevelTPCnvBaseP.h:104
TopLevelTPCnvBase.h
Defines the base class for top-level TP converters.
TopLevelTPCnvBaseP::hasTLPersObject
virtual bool hasTLPersObject() const override
Returns true if the converter has a persistent object.
Definition: TopLevelTPCnvBaseP.h:52
TopLevelTPCnvBaseP::TopLevelTPCnvBaseP
TopLevelTPCnvBaseP()
Definition: TopLevelTPCnvBaseP.h:41
TopLevelTPCnvBaseP::createTLPersObject
virtual void createTLPersObject() override
Create persistent object - the converter keeps it.
Definition: TopLevelTPCnvBaseP.h:57