12 #ifndef ROOT_TFormLeafInfo
13 #define ROOT_TFormLeafInfo
26 #define DECLARE_GETVAL \
27 virtual Double_t GetValue(TLeaf *leaf, Int_t instance = 0) \
28 { return GetValueImpl<Double_t>(leaf, instance); } \
29 virtual Long64_t GetValueLong64(TLeaf *leaf, Int_t instance = 0) \
30 { return GetValueImpl<Long64_t>(leaf, instance); } \
31 virtual LongDouble_t GetValueLongDouble(TLeaf *leaf, Int_t instance = 0) \
32 { return GetValueImpl<LongDouble_t>(leaf, instance); } \
33 template<typename T> T GetValueImpl(TLeaf *leaf, Int_t instance = 0) // no semicolon
37 #define DECLARE_READVAL \
38 virtual Double_t ReadValue(char *where, Int_t instance = 0) \
39 { return ReadValueImpl<Double_t>(where, instance); } \
40 virtual Long64_t ReadValueLong64(char *where, Int_t instance = 0) \
41 { return ReadValueImpl<Long64_t>(where, instance); } \
42 virtual LongDouble_t ReadValueLongDouble(char *where, Int_t instance = 0) \
43 { return ReadValueImpl<LongDouble_t>(where, instance); } \
44 template<typename T> T ReadValueImpl(char *where, Int_t instance = 0) // no semicolon
49 class TFormLeafInfo :
public TObject {
52 TFormLeafInfo(TClass* classptr = 0, Long_t offset = 0,
53 TStreamerElement* element = 0);
54 TFormLeafInfo(
const TFormLeafInfo& orig);
55 virtual TFormLeafInfo* DeepCopy()
const;
56 virtual ~TFormLeafInfo();
58 void Swap(TFormLeafInfo &other);
59 TFormLeafInfo &operator=(
const TFormLeafInfo &orig);
65 TStreamerElement *fElement;
68 TFormLeafInfo *fCounter;
77 virtual void AddOffset(Int_t offset, TStreamerElement* element);
79 virtual Int_t GetArrayLength();
80 virtual TClass* GetClass()
const;
81 virtual Int_t GetCounterValue(TLeaf* leaf);
82 virtual Int_t ReadCounterValue(
char *where);
84 char* GetObjectAddress(TLeafElement* leaf, Int_t &instance);
86 Int_t GetMultiplicity();
89 Int_t GetNdata(TLeaf* leaf);
90 virtual Int_t GetNdata();
92 virtual void *GetValuePointer(TLeaf *leaf, Int_t instance = 0);
93 virtual void *GetValuePointer(
char *from, Int_t instance = 0);
94 virtual void *GetLocalValuePointer(TLeaf *leaf, Int_t instance = 0);
95 virtual void *GetLocalValuePointer(
char *from, Int_t instance = 0);
97 virtual Bool_t HasCounter()
const;
98 virtual Bool_t IsString()
const;
100 virtual Bool_t IsInteger()
const;
101 virtual Bool_t IsReference()
const {
return kFALSE; }
104 virtual Int_t GetPrimaryIndex();
105 virtual Int_t GetVarDim();
106 virtual Int_t GetVirtVarDim();
107 virtual Int_t GetSize(Int_t index);
108 virtual Int_t GetSumOfSizes();
109 virtual void LoadSizes(TBranch* branch);
110 virtual void SetPrimaryIndex(Int_t index);
111 virtual void SetSecondaryIndex(Int_t index);
112 virtual void SetSize(Int_t index, Int_t val);
113 virtual void SetBranch(TBranch* br) {
if ( fNext ) fNext->SetBranch(br); }
114 virtual void UpdateSizes(TArrayI *garr);
116 virtual Bool_t Update();
121 template <
typename T>
struct ReadValueHelper {
122 static T Exec(TFormLeafInfo *leaf,
char *where, Int_t instance) {
123 return leaf->ReadValue(where, instance);
126 template <
typename T > T ReadTypedValue(
char *where, Int_t instance = 0) {
127 return ReadValueHelper<T>::Exec(
this, where, instance);
130 template <
typename T>
struct GetValueHelper {
131 static T Exec(TFormLeafInfo *linfo, TLeaf *leaf, Int_t instance) {
132 return linfo->GetValue(leaf, instance);
135 template <
typename T > T GetTypedValue(TLeaf *leaf, Int_t instance = 0) {
136 return GetValueHelper<T>::Exec(
this, leaf, instance);
141 template <>
struct TFormLeafInfo::ReadValueHelper<Long64_t> {
142 static Long64_t Exec(TFormLeafInfo *leaf,
char *where, Int_t instance) {
return leaf->ReadValueLong64(where, instance); }
144 template <>
struct TFormLeafInfo::ReadValueHelper<ULong64_t> {
145 static ULong64_t Exec(TFormLeafInfo *leaf,
char *where, Int_t instance) {
return (ULong64_t)leaf->ReadValueLong64(where, instance); }
147 template <>
struct TFormLeafInfo::ReadValueHelper<LongDouble_t> {
148 static LongDouble_t Exec(TFormLeafInfo *leaf,
char *where, Int_t instance) {
return leaf->ReadValueLongDouble(where, instance); }
151 template <>
struct TFormLeafInfo::GetValueHelper<Long64_t> {
152 static Long64_t Exec(TFormLeafInfo *linfo, TLeaf *leaf, Int_t instance) {
return linfo->GetValueLong64(leaf, instance); }
154 template <>
struct TFormLeafInfo::GetValueHelper<ULong64_t> {
155 static ULong64_t Exec(TFormLeafInfo *linfo, TLeaf *leaf, Int_t instance) {
return (ULong64_t)linfo->GetValueLong64(leaf, instance); }
157 template <>
struct TFormLeafInfo::GetValueHelper<LongDouble_t> {
158 static LongDouble_t Exec(TFormLeafInfo *linfo, TLeaf *leaf, Int_t instance) {
return linfo->GetValueLongDouble(leaf, instance); }
164 class TFormLeafInfoDirect :
public TFormLeafInfo {
166 TFormLeafInfoDirect(TBranchElement * from);
169 virtual TFormLeafInfo* DeepCopy()
const;
172 virtual void *GetLocalValuePointer(TLeaf *leaf, Int_t instance = 0);
173 virtual void *GetLocalValuePointer(
char *thisobj, Int_t instance = 0);
175 virtual Double_t ReadValue(
char * , Int_t = 0);
176 virtual Long64_t ReadValueLong64(
char *where, Int_t i= 0) {
return ReadValue(where, i); }
177 virtual LongDouble_t ReadValueLongDouble(
char *where, Int_t i= 0) {
return ReadValue(where, i); }
184 class TFormLeafInfoNumerical :
public TFormLeafInfo {
188 TFormLeafInfoNumerical(TVirtualCollectionProxy *holder_of);
189 TFormLeafInfoNumerical(EDataType kind);
190 TFormLeafInfoNumerical(
const TFormLeafInfoNumerical& orig);
192 virtual TFormLeafInfo* DeepCopy()
const;
193 void Swap(TFormLeafInfoNumerical &other);
194 TFormLeafInfoNumerical &operator=(
const TFormLeafInfoNumerical &orig);
196 virtual ~TFormLeafInfoNumerical();
198 virtual Bool_t IsString()
const;
199 virtual Bool_t Update();
206 class TFormLeafInfoCollectionObject :
public TFormLeafInfo {
209 TFormLeafInfoCollectionObject(TClass* classptr = 0, Bool_t fTop = kTRUE);
210 TFormLeafInfoCollectionObject(
const TFormLeafInfoCollectionObject &orig);
212 void Swap(TFormLeafInfoCollectionObject &other);
213 TFormLeafInfoCollectionObject &operator=(
const TFormLeafInfoCollectionObject &orig);
215 virtual TFormLeafInfo* DeepCopy()
const {
216 return new TFormLeafInfoCollectionObject(*
this);
220 virtual Int_t GetCounterValue(TLeaf* leaf);
221 virtual Double_t ReadValue(
char *where, Int_t instance = 0);
222 virtual Long64_t ReadValueLong64(
char *where, Int_t i= 0) {
return ReadValue(where, i); }
223 virtual LongDouble_t ReadValueLongDouble(
char *where, Int_t i= 0) {
return ReadValue(where, i); }
224 virtual void *GetValuePointer(TLeaf *leaf, Int_t instance = 0);
225 virtual void *GetValuePointer(
char *thisobj, Int_t instance = 0);
226 virtual void *GetLocalValuePointer(TLeaf *leaf, Int_t instance = 0);
227 virtual void *GetLocalValuePointer(
char *thisobj, Int_t instance = 0);
233 class TFormLeafInfoClones :
public TFormLeafInfo {
237 TFormLeafInfoClones(TClass* classptr = 0, Long_t offset = 0);
238 TFormLeafInfoClones(TClass* classptr, Long_t offset, Bool_t top);
239 TFormLeafInfoClones(TClass* classptr, Long_t offset, TStreamerElement* element,
240 Bool_t top = kFALSE);
241 TFormLeafInfoClones(
const TFormLeafInfoClones &orig);
243 void Swap(TFormLeafInfoClones &other);
244 TFormLeafInfoClones &operator=(
const TFormLeafInfoClones &orig);
246 virtual TFormLeafInfo* DeepCopy()
const {
247 return new TFormLeafInfoClones(*
this);
252 virtual Int_t GetCounterValue(TLeaf* leaf);
253 virtual Int_t ReadCounterValue(
char *where);
254 virtual void *GetValuePointer(TLeaf *leaf, Int_t instance = 0);
255 virtual void *GetValuePointer(
char *thisobj, Int_t instance = 0);
256 virtual void *GetLocalValuePointer(TLeaf *leaf, Int_t instance = 0);
257 virtual void *GetLocalValuePointer(
char *thisobj, Int_t instance = 0);
263 class TFormLeafInfoCollection :
public TFormLeafInfo {
267 TString fCollClassName;
268 TVirtualCollectionProxy *fCollProxy;
269 TStreamerElement *fLocalElement;
272 TFormLeafInfoCollection(TClass* classptr,
274 TStreamerElement* element,
275 Bool_t top = kFALSE);
277 TFormLeafInfoCollection(TClass* motherclassptr,
279 TClass* elementclassptr = 0,
280 Bool_t top = kFALSE);
282 TFormLeafInfoCollection();
283 TFormLeafInfoCollection(
const TFormLeafInfoCollection& orig);
285 ~TFormLeafInfoCollection();
287 void Swap(TFormLeafInfoCollection &other);
288 TFormLeafInfoCollection &operator=(
const TFormLeafInfoCollection &orig);
290 virtual TFormLeafInfo* DeepCopy()
const;
292 virtual Bool_t Update();
296 virtual Int_t GetCounterValue(TLeaf* leaf);
297 virtual Int_t ReadCounterValue(
char* where);
298 virtual Int_t GetCounterValue(TLeaf* leaf, Int_t instance);
299 virtual Bool_t HasCounter()
const;
300 virtual void *GetValuePointer(TLeaf *leaf, Int_t instance = 0);
301 virtual void *GetValuePointer(
char *thisobj, Int_t instance = 0);
302 virtual void *GetLocalValuePointer(TLeaf *leaf, Int_t instance = 0);
303 virtual void *GetLocalValuePointer(
char *thisobj, Int_t instance = 0);
308 class TFormLeafInfoCollectionSize :
public TFormLeafInfo {
310 TString fCollClassName;
311 TVirtualCollectionProxy *fCollProxy;
313 TFormLeafInfoCollectionSize(TClass*);
314 TFormLeafInfoCollectionSize(TClass* classptr,Long_t offset,TStreamerElement* element);
315 TFormLeafInfoCollectionSize();
316 TFormLeafInfoCollectionSize(
const TFormLeafInfoCollectionSize& orig);
318 ~TFormLeafInfoCollectionSize();
320 void Swap(TFormLeafInfoCollectionSize &other);
321 TFormLeafInfoCollectionSize &operator=(
const TFormLeafInfoCollectionSize &orig);
323 virtual TFormLeafInfo* DeepCopy()
const;
325 virtual Bool_t Update();
327 virtual void *GetValuePointer(TLeaf *leaf, Int_t instance = 0);
328 virtual void *GetValuePointer(
char *from, Int_t instance = 0);
329 virtual void *GetLocalValuePointer(TLeaf *leaf, Int_t instance = 0);
330 virtual void *GetLocalValuePointer(
char *from, Int_t instance = 0);
331 virtual Double_t ReadValue(
char *where, Int_t instance = 0);
332 virtual Long64_t ReadValueLong64(
char *where, Int_t i= 0) {
return ReadValue(where, i); }
333 virtual LongDouble_t ReadValueLongDouble(
char *where, Int_t i= 0) {
return ReadValue(where, i); }
339 class TFormLeafInfoPointer :
public TFormLeafInfo {
341 TFormLeafInfoPointer(TClass* classptr = 0, Long_t offset = 0,
342 TStreamerElement* element = 0);
345 virtual TFormLeafInfo* DeepCopy()
const;
354 class TFormLeafInfoMethod :
public TFormLeafInfo {
356 TMethodCall *fMethod;
361 TString fDeleteFormat;
366 static TClass *ReturnTClass(TMethodCall *mc);
368 TFormLeafInfoMethod(TClass* classptr = 0, TMethodCall *method = 0);
369 TFormLeafInfoMethod(
const TFormLeafInfoMethod& orig);
370 ~TFormLeafInfoMethod();
372 void Swap(TFormLeafInfoMethod &other);
373 TFormLeafInfoMethod &operator=(
const TFormLeafInfoMethod &orig);
375 virtual TFormLeafInfo* DeepCopy()
const;
378 virtual TClass* GetClass()
const;
379 virtual void *GetLocalValuePointer( TLeaf *from, Int_t instance = 0);
380 virtual void *GetLocalValuePointer(
char *from, Int_t instance = 0);
381 virtual Bool_t IsInteger()
const;
382 virtual Bool_t IsString()
const;
383 virtual Bool_t Update();
391 class TFormLeafInfoMultiVarDim :
public TFormLeafInfo {
395 TFormLeafInfo *fCounter2;
400 Int_t fSecondaryIndex;
403 TFormLeafInfoMultiVarDim(TClass* classptr, Long_t offset,
404 TStreamerElement* element) : TFormLeafInfo(classptr,offset,element),fNsize(0),fSizes(),fCounter2(0),fSumOfSizes(0),fDim(0),fVirtDim(0),fPrimaryIndex(-1),fSecondaryIndex(-1) {}
407 TFormLeafInfoMultiVarDim(TClass* classptr, Long_t offset,
408 TStreamerElement* element, TFormLeafInfo* parent);
409 TFormLeafInfoMultiVarDim();
410 TFormLeafInfoMultiVarDim(
const TFormLeafInfoMultiVarDim& orig);
411 ~TFormLeafInfoMultiVarDim();
413 void Swap(TFormLeafInfoMultiVarDim &other);
414 TFormLeafInfoMultiVarDim &operator=(
const TFormLeafInfoMultiVarDim &orig);
416 virtual TFormLeafInfo* DeepCopy()
const;
423 virtual void LoadSizes(TBranch* branch);
424 virtual Int_t GetPrimaryIndex();
425 virtual void SetPrimaryIndex(Int_t index);
426 virtual void SetSecondaryIndex(Int_t index);
427 virtual void SetSize(Int_t index, Int_t val);
428 virtual Int_t GetSize(Int_t index);
429 virtual Int_t GetSumOfSizes();
430 virtual Double_t GetValue(TLeaf * , Int_t = 0);
431 virtual Long64_t GetValueLong64(TLeaf *leaf, Int_t i= 0) {
return GetValue(leaf, i); }
432 virtual LongDouble_t GetValueLongDouble(TLeaf *leaf, Int_t i= 0) {
return GetValue(leaf, i); }
433 virtual Int_t GetVarDim();
434 virtual Int_t GetVirtVarDim();
435 virtual Bool_t Update();
436 virtual void UpdateSizes(TArrayI *garr);
443 class TFormLeafInfoMultiVarDimDirect :
public TFormLeafInfoMultiVarDim {
447 virtual TFormLeafInfo* DeepCopy()
const;
450 virtual Double_t ReadValue(
char * , Int_t = 0);
451 virtual Long64_t ReadValueLong64(
char *where, Int_t i= 0) {
return ReadValue(where, i); }
452 virtual LongDouble_t ReadValueLongDouble(
char *where, Int_t i= 0) {
return ReadValue(where, i); }
459 class TFormLeafInfoMultiVarDimCollection :
public TFormLeafInfoMultiVarDim {
461 TFormLeafInfoMultiVarDimCollection(TClass* motherclassptr, Long_t offset,
462 TClass* elementclassptr, TFormLeafInfo *parent);
463 TFormLeafInfoMultiVarDimCollection(TClass* classptr, Long_t offset,
464 TStreamerElement* element, TFormLeafInfo* parent);
467 virtual TFormLeafInfo* DeepCopy()
const;
469 virtual Int_t GetArrayLength() {
return 0; }
470 virtual void LoadSizes(TBranch* branch);
471 virtual Double_t GetValue(TLeaf *leaf, Int_t instance = 0);
472 virtual Long64_t GetValueLong64(TLeaf *leaf, Int_t i= 0) {
return GetValue(leaf, i); }
473 virtual LongDouble_t GetValueLongDouble(TLeaf *leaf, Int_t i= 0) {
return GetValue(leaf, i); }
481 class TFormLeafInfoMultiVarDimClones :
public TFormLeafInfoMultiVarDim {
483 TFormLeafInfoMultiVarDimClones(TClass* motherclassptr, Long_t offset,
484 TClass* elementclassptr, TFormLeafInfo *parent);
485 TFormLeafInfoMultiVarDimClones(TClass* classptr, Long_t offset,
486 TStreamerElement* element, TFormLeafInfo* parent);
489 virtual TFormLeafInfo* DeepCopy()
const;
491 virtual Int_t GetArrayLength() {
return 0; }
492 virtual void LoadSizes(TBranch* branch);
493 virtual Double_t GetValue(TLeaf *leaf, Int_t instance = 0);
494 virtual Long64_t GetValueLong64(TLeaf *leaf, Int_t i= 0) {
return GetValue(leaf, i); }
495 virtual LongDouble_t GetValueLongDouble(TLeaf *leaf, Int_t i= 0) {
return GetValue(leaf, i); }
502 class TFormLeafInfoCast :
public TFormLeafInfo {
509 TFormLeafInfoCast(TClass* classptr = 0, TClass* casted = 0);
510 TFormLeafInfoCast(
const TFormLeafInfoCast& orig);
511 virtual ~TFormLeafInfoCast();
513 void Swap(TFormLeafInfoCast &other);
514 TFormLeafInfoCast &operator=(
const TFormLeafInfoCast &orig);
516 virtual TFormLeafInfo* DeepCopy()
const;
520 virtual Int_t GetNdata();
521 virtual Bool_t Update();
527 class TFormLeafInfoTTree :
public TFormLeafInfo {
533 TFormLeafInfoTTree(TTree *tree = 0,
const char *alias = 0, TTree *current = 0);
534 TFormLeafInfoTTree(
const TFormLeafInfoTTree& orig);
536 void Swap(TFormLeafInfoTTree &other);
537 TFormLeafInfoTTree &operator=(
const TFormLeafInfoTTree &orig);
539 virtual TFormLeafInfo* DeepCopy()
const;
541 using TFormLeafInfo::GetLocalValuePointer;
542 using TFormLeafInfo::GetValue;
546 virtual void *GetLocalValuePointer(TLeaf *leaf, Int_t instance = 0);
547 virtual Bool_t Update();