ATLAS Offline Software
TopLevelTPCnvBase.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 TPTOPLEVELTPCNVBASE_H
6 #define TPTOPLEVELTPCNVBASE_H
7 
13 #include <set>
14 #include <map>
15 
17 class TPCnvTokenList_p1;
18 #include "ITPConverter.h"
19 
32 {
33 public:
35 
36  virtual ~TopLevelTPCnvBase() { }
37 
38  // ------------- Methods for elemental TP converter management
39 
42  virtual void addTPConverter( ITPConverter *cnv );
43 
48  virtual void addTPConverterForReading( ITPConverter *cnv );
49 
50 private:
54  virtual void addTPConverterForWriting( ITPConverter *cnv );
55 
56 public:
60  virtual void addExtTPConverterForReading( ITPConverter *cnv );
61 
67  virtual void addTPConvertersTo( TopLevelTPCnvBase *dest );
68 
75 
80  ITPConverter* converterForType( const std::type_info &info ) const {
82  }
83 
90  convIdMap_t::const_iterator iter = m_convIdMap.find( ref.typeID() );
91  return (iter == m_convIdMap.end())?
92  0 : iter->second;
93  }
94 
95 
96  // --------------------- methods dealing with the persistent
97  // object owned by the topl-level converter
98 
100  virtual bool hasTLPersObject() const = 0;
101 
103  virtual void* getTLPersObjectAsVoid() = 0;
104 
106  virtual const void* getTLPersObjectAsVoid() const = 0;
107 
109  virtual void createTLPersObject() = 0;
110 
112  virtual void deleteTLPersObject() = 0;
113 
115  virtual void clearTLPersObject() = 0;
116 
121  virtual void setTLPersObject(void* persObj) = 0;
122 
123 
124  // ----------- methods dealing with the token list
125 
126 
135 
142  virtual TPCnvTokenList_p1* getTokenListVarFrom( void *persObj ) = 0;
143 
144 
145  // ---- other methods
146 
148  virtual unsigned short getConverterID() = 0;
149 
150 protected:
157  {
158  m_registeredTLConverters.insert(cnv);
159  }
160 
167  {
168  return m_registeredTLConverters.find(cnv) != m_registeredTLConverters.end();
169  }
170 
171 
172 protected:
173 
174  typedef std::map<unsigned, ITPConverter*> convIdMap_t;
175 
178 
181 
184  std::set<TopLevelTPCnvBase*> m_registeredTLConverters;
185 
187  unsigned m_typeIDCount;
188 };
189 
190 
191 #endif
grepfile.info
info
Definition: grepfile.py:38
TPConverterTypeMap::findConverter
CONVERTER_BASE * findConverter(const std::type_info &objTypeInfo) const
Find converter for a given C++ type info.
Definition: TPTools/TPTools/ITPConverter.h:150
TopLevelTPCnvBase::converterForType
ITPConverter * converterForType(const std::type_info &info) const
Find and return a TP converter for a given C++ type info.
Definition: TopLevelTPCnvBase.h:80
TPCnvTokenList_p1
Definition: TPCnvTokenList_p1.h:55
TopLevelTPCnvBase::addExtTPConverterForReading
virtual void addExtTPConverterForReading(ITPConverter *cnv)
add extending TP converter to this top level converter - to the list consulted when reading only.
Definition: TopLevelTPCnvBase.cxx:47
TopLevelTPCnvBase::getTLPersObjectAsVoid
virtual const void * getTLPersObjectAsVoid() const =0
TopLevelTPCnvBase::getConverterID
virtual unsigned short getConverterID()=0
TopLevelTPCnvBase::addTPConvertersForReadingTo
virtual void addTPConvertersForReadingTo(TopLevelTPCnvBase *dest)
copy all extending converters from this top level converter to "dest" top level converter - for readi...
Definition: TopLevelTPCnvBase.cxx:78
TopLevelTPCnvBase::createTLPersObject
virtual void createTLPersObject()=0
Create persistent object - the converter keeps it.
TopLevelTPCnvBase::getTokenListVarFrom
virtual TPCnvTokenList_p1 * getTokenListVarFrom(void *persObj)=0
Return the list of tokens to the objects extending the object NOT owned by this converter.
TopLevelTPCnvBase::deleteTLPersObject
virtual void deleteTLPersObject()=0
Delete the persistent object owned by the converter.
TopLevelTPCnvBase::hasConvertersFrom
bool hasConvertersFrom(TopLevelTPCnvBase *cnv)
Check if TP converters from a given top-level converter were already registered in this converter.
Definition: TopLevelTPCnvBase.h:166
TopLevelTPCnvBase::converterForRef
ITPConverter * converterForRef(const TPObjRef &ref) const
Find and return a TP converter for persistent type referenced by ref.
Definition: TopLevelTPCnvBase.h:89
TopLevelTPCnvBase::m_registeredTLConverters
std::set< TopLevelTPCnvBase * > m_registeredTLConverters
Set top-level converters from which elemental TP converters were registered.
Definition: TopLevelTPCnvBase.h:184
perfmonmt-printer.dest
dest
Definition: perfmonmt-printer.py:189
TopLevelTPCnvBase::rememberConverter
void rememberConverter(TopLevelTPCnvBase *cnv)
Remember that elemental TP converters from the given top-level converter are already registered.
Definition: TopLevelTPCnvBase.h:156
TPObjRef
Definition: TPObjRef.h:20
TopLevelTPCnvBase::addTPConverter
virtual void addTPConverter(ITPConverter *cnv)
Add a TP converter to this top level converter.
Definition: TopLevelTPCnvBase.cxx:11
TopLevelTPCnvBase::addTPConverterForReading
virtual void addTPConverterForReading(ITPConverter *cnv)
Add a TP converter to this top level converter but only for reading.
Definition: TopLevelTPCnvBase.cxx:19
TopLevelTPCnvBase::setTLPersObject
virtual void setTLPersObject(void *persObj)=0
Take ownership of the persistent object.
TopLevelTPCnvBase::clearTLPersObject
virtual void clearTLPersObject()=0
Discard the persistent object.
TopLevelTPCnvBase::m_typeIDCount
unsigned m_typeIDCount
Counter used to create typed IDs used in the transient Ref.
Definition: TopLevelTPCnvBase.h:187
TopLevelTPCnvBase::TopLevelTPCnvBase
TopLevelTPCnvBase()
Definition: TopLevelTPCnvBase.h:34
ITPConverter.h
Defines the base ITPConverter class interface for all TP converters. Also defines TPConverterTypeMap ...
TopLevelTPCnvBase::~TopLevelTPCnvBase
virtual ~TopLevelTPCnvBase()
Definition: TopLevelTPCnvBase.h:36
TopLevelTPCnvBase::addTPConvertersTo
virtual void addTPConvertersTo(TopLevelTPCnvBase *dest)
copy all extending converters from this top level converter to "dest" top level converter
Definition: TopLevelTPCnvBase.cxx:60
TopLevelTPCnvBase::m_converters
TPConverterTypeMap< ITPConverter > m_converters
Map of elemental TP converters indexed by transient typeid - used for writing.
Definition: TopLevelTPCnvBase.h:180
TopLevelTPCnvBase
Base class for top-level TP converters.
Definition: TopLevelTPCnvBase.h:32
TPObjRef.h
TopLevelTPCnvBase::getTLPersObjectAsVoid
virtual void * getTLPersObjectAsVoid()=0
ref
const boost::regex ref(r_ef)
TopLevelTPCnvBase::m_convIdMap
convIdMap_t m_convIdMap
Map of elemental TP converters indexed by their ID - used for reading.
Definition: TopLevelTPCnvBase.h:177
TopLevelTPCnvBase::addTPConverterForWriting
virtual void addTPConverterForWriting(ITPConverter *cnv)
add TP converter to the list of converters consulted when writing - internal method.
Definition: TopLevelTPCnvBase.cxx:33
TopLevelTPCnvBase::convIdMap_t
std::map< unsigned, ITPConverter * > convIdMap_t
Definition: TopLevelTPCnvBase.h:174
TopLevelTPCnvBase::getTokenListVar
virtual TPCnvTokenList_p1 * getTokenListVar()=0
Return the list of tokens to the objects extending the object owned by this converter.
TopLevelTPCnvBase::hasTLPersObject
virtual bool hasTLPersObject() const =0
Returns true if the converter has a persistent object.
ITPConverter
Definition: TPTools/TPTools/ITPConverter.h:32
TPConverterTypeMap< ITPConverter >