ATLAS Offline Software
Loading...
Searching...
No Matches
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-2025 CERN for the benefit of the ATLAS collaboration
5*/
89
90#ifndef ROOTCONVERSIONS_TVIRTUALCONVERTER_H
91#define ROOTCONVERSIONS_TVIRTUALCONVERTER_H
92
93#include <string>
94#include <typeinfo>
95#include "Rtypes.h"
96
97class TClass;
98class TBuffer;
99
100
110{
111public:
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
237protected:
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
247private:
249 void CheckStreamInfos();
250
252 void CheckClasses();
253
255 TClass* fTransClass;
256
258 TClass* fPersClass;
259
261 UInt_t fCheckSum;
262
266
267
268protected:
271 void* fPersObj;
272};
273
274
282template <class TTrans, class TPers>
284 : public TVirtualConverter
285{
286public:
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 ROOTCONVERSIONS_TVIRTUALCONVERTER_H
virtual void Convert(TTrans *transobj, const TPers *persobj)=0
Do the conversion.
TVirtualConverter_T(TClass *trans_cls=0, TClass *pers_cls=0)
Constructor, with class pointers.
virtual void ConvertVoid(void *transobj, const void *persobj)
Do the conversion.
TVirtualConverter_T(UInt_t checksum, TClass *trans_cls=0, TClass *pers_cls=0)
Constructor, with checksum and class pointers.
virtual void ReadBuffer(TBuffer &b, void *obj, Version_t version, UInt_t R__S, UInt_t R__c)
Read object in non-split mode.
TClass * fPersClass
The declared persistent class.
TClass * GetTransClass()
Return the transient class, to which we're converting.
virtual void * NewPersObj()
Create a new instance of the persistent class.
int fOldLast
Used by CheckStreamInfos: the length of the streamerinfo list that we saw on the last CheckStreamInfo...
virtual ~TVirtualConverter()
Destructor.
TVirtualConverter()
Default constructor.
virtual void DeletePersObj(void *persobj)
Destroy an instance of the persistent class.
TVirtualConverter(UInt_t checksum, TClass *trans_cls, TClass *pers_cls)
Constructor, with checksum and class pointers.
void CheckStreamInfos()
Helper to allow for automatic schema evolution for persistent classes.
int GetCheckSum() const
Return the checksum of the class from which we're converting.
void SetCtorInfo(UInt_t checksum, TClass *trans_cls, TClass *pers_cls)
Set the parameters that would normally be passed to the constructor.
virtual void ConvertVoid(void *transobj, const void *persobj)=0
Do the conversion.
TClass * GetPersClass()
Return the persistent class, from which we're converting.
static TClass * ToClass(const std::string &name)
Helper to convert a class name to a Root class pointer.
void * fPersObj
The temporary persistent object instance, used for conversions (in non-split mode).
TClass * fTransClass
The declared transient class.
UInt_t fCheckSum
The declared checksum.
void CheckClasses()
Helper to check that the classes have been defined properly.