ATLAS Offline Software
TVirtualConverter.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 */
90 #ifndef TVIRTUALCONVERTER_H
91 #define TVIRTUALCONVERTER_H
92 
93 #include <string>
94 #include <typeinfo>
95 #include "Rtypes.h"
96 
97 class TClass;
98 class TBuffer;
99 
100 
110 {
111 public:
118  TVirtualConverter (UInt_t checksum,
119  TClass* trans_cls,
120  TClass* pers_cls);
121 
129  TVirtualConverter (TClass* trans_cls,
130  TClass* pers_cls);
131 
140  TVirtualConverter (UInt_t checksum,
141  const std::string& trans_cls,
142  const std::string& pers_cls);
143 
153  TVirtualConverter (const std::string& trans_cls,
154  const std::string& pers_cls);
155 
159  virtual ~TVirtualConverter();
160 
164  TClass* GetTransClass ();
165 
169  TClass* GetPersClass();
170 
174  int GetCheckSum() const;
175 
182  virtual void* NewPersObj ();
183 
191  virtual void DeletePersObj (void* persobj);
192 
202  virtual void ConvertVoid (void* transobj, const void* persobj) = 0;
203 
217  virtual void ReadBuffer(TBuffer& b, void* obj, Version_t version,
218  UInt_t R__S, UInt_t R__c);
219 
226  static TClass* ToClass (const std::string& name);
227 
234  static TClass* ToClass (const std::type_info& id);
235 
236 
237 protected:
238  // For compatibility with @c T_AthenaRootConverter only.
239  // Allows specifying the constructor arguments after the constructor
240  // itself is called.
242  void SetCtorInfo (UInt_t checksum,
243  TClass* trans_cls,
244  TClass* pers_cls);
245 
246 
247 private:
249  void CheckStreamInfos();
250 
252  void CheckClasses();
253 
255  TClass* fTransClass;
256 
258  TClass* fPersClass;
259 
261  UInt_t fCheckSum;
262 
265  int fOldLast;
266 
267 
268 protected:
271  void* fPersObj;
272 };
273 
274 
282 template <class TTrans, class TPers>
284  : public TVirtualConverter
285 {
286 public:
297  TVirtualConverter_T (TClass* trans_cls = 0,
298  TClass* pers_cls = 0);
299 
309  TVirtualConverter_T (UInt_t checksum,
310  TClass* trans_cls = 0,
311  TClass* pers_cls = 0);
312 
321  virtual void ConvertVoid (void* transobj, const void* persobj);
322 
332  virtual void Convert (TTrans* transobj, const TPers* persobj) = 0;
333 };
334 
335 
337 
338 
339 #endif // not TVIRTUALCONVERTER_H
TVirtualConverter::GetPersClass
TClass * GetPersClass()
Return the persistent class, from which we're converting.
Definition: TVirtualConverter.cxx:230
TVirtualConverter::ToClass
static TClass * ToClass(const std::string &name)
Helper to convert a class name to a Root class pointer.
Definition: TVirtualConverter.cxx:311
TVirtualConverter_T::ConvertVoid
virtual void ConvertVoid(void *transobj, const void *persobj)
Do the conversion.
TVirtualConverter::GetCheckSum
int GetCheckSum() const
Return the checksum of the class from which we're converting.
Definition: TVirtualConverter.cxx:239
TVirtualConverter::fOldLast
int fOldLast
Used by CheckStreamInfos: the length of the streamerinfo list that we saw on the last CheckStreamInfo...
Definition: TVirtualConverter.h:265
TVirtualConverter::TVirtualConverter
TVirtualConverter()
Default constructor.
Definition: TVirtualConverter.cxx:413
TVirtualConverter_T::TVirtualConverter_T
TVirtualConverter_T(UInt_t checksum, TClass *trans_cls=0, TClass *pers_cls=0)
Constructor, with checksum and class pointers.
TVirtualConverter::~TVirtualConverter
virtual ~TVirtualConverter()
Destructor.
Definition: TVirtualConverter.cxx:210
TVirtualConverter::ReadBuffer
virtual void ReadBuffer(TBuffer &b, void *obj, Version_t version, UInt_t R__S, UInt_t R__c)
Read object in non-split mode.
Definition: TVirtualConverter.cxx:283
TVirtualConverter::fCheckSum
UInt_t fCheckSum
The declared checksum.
Definition: TVirtualConverter.h:261
TVirtualConverter::fTransClass
TClass * fTransClass
The declared transient class.
Definition: TVirtualConverter.h:255
TVirtualConverter::fPersObj
void * fPersObj
The temporary persistent object instance, used for conversions (in non-split mode).
Definition: TVirtualConverter.h:271
TVirtualConverter_T::TVirtualConverter_T
TVirtualConverter_T(TClass *trans_cls=0, TClass *pers_cls=0)
Constructor, with class pointers.
TVirtualConverter::CheckClasses
void CheckClasses()
Helper to check that the classes have been defined properly.
Definition: TVirtualConverter.cxx:189
TVirtualConverter.icc
TVirtualConverter
Base class for converters for Root schema evolution.
Definition: TVirtualConverter.h:110
TVirtualConverter::CheckStreamInfos
void CheckStreamInfos()
Helper to allow for automatic schema evolution for persistent classes.
Definition: TVirtualConverter.cxx:369
TVirtualConverter::GetTransClass
TClass * GetTransClass()
Return the transient class, to which we're converting.
Definition: TVirtualConverter.cxx:221
TVirtualConverter::fPersClass
TClass * fPersClass
The declared persistent class.
Definition: TVirtualConverter.h:258
TVirtualConverter_T::Convert
virtual void Convert(TTrans *transobj, const TPers *persobj)=0
Do the conversion.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
get_generator_info.version
version
Definition: get_generator_info.py:33
TVirtualConverter::SetCtorInfo
void SetCtorInfo(UInt_t checksum, TClass *trans_cls, TClass *pers_cls)
Set the parameters that would normally be passed to the constructor.
Definition: TVirtualConverter.cxx:431
TVirtualConverter::NewPersObj
virtual void * NewPersObj()
Create a new instance of the persistent class.
Definition: TVirtualConverter.cxx:251
TVirtualConverter::DeletePersObj
virtual void DeletePersObj(void *persobj)
Destroy an instance of the persistent class.
Definition: TVirtualConverter.cxx:264
TVirtualConverter_T
Easy-to-use templated class for defining converters.
Definition: TVirtualConverter.h:285
python.PyAthena.obj
obj
Definition: PyAthena.py:132
TVirtualConverter::ConvertVoid
virtual void ConvertVoid(void *transobj, const void *persobj)=0
Do the conversion.