Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TStreamerElement.cxx
Go to the documentation of this file.
1// @(#)root/meta:$Id$
2// Author: Rene Brun 12/10/2000
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TROOT.h"
13#include "TStreamerElement.h"
15#include "TBuffer.h"
16#include "TClass.h"
17#include "TClassEdit.h"
18#include "TClassStreamer.h"
19#include "TClassTable.h"
20#include "TBaseClass.h"
21#include "TDataMember.h"
22#include "TDataType.h"
24#include "TEnum.h"
25#include "TRealData.h"
26#include "ThreadLocalStorage.h"
27#include "TList.h"
28#include "TRef.h"
29#include "TInterpreter.h"
30#include "TError.h"
31#include "TObjArray.h"
32#include "TVirtualMutex.h"
34#include "strlcpy.h"
35#include "snprintf.h"
36
37#include <string>
38
39using std::string;
40
41const Int_t kMaxLen = 1024;
42
47
49{
50 TString className = type_name.Strip(TString::kTrailing, '*');
51 if (className.Index("const ")==0) className.Remove(0,6);
52 return className;
53}
54////////////////////////////////////////////////////////////////////////////////
55/// Helper function to initialize the 'index/counter' value of
56/// the Pointer streamerElements. If directive is a StreamerInfo and it correspond to the
57/// same class a 'countClass' the streamerInfo is used instead of the current StreamerInfo of the TClass
58/// for 'countClass'.
59
61{
62 TStreamerBasicType *counter = nullptr;
63
65
66 if (directive) {
67
68 if (directive->GetClass() == cl) {
69 // The info we have been passed is indeed describing the counter holder, just look there.
70
71 TStreamerElement *element = (TStreamerElement *)directive->GetElements()->FindObject(countName);
72 if (!element) return nullptr;
73 if (element->IsA() != TStreamerBasicType::Class()) return nullptr;
74 counter = (TStreamerBasicType*)element;
75
76 } else {
77 if (directive->GetClass()->GetListOfRealData()) {
78 TRealData* rdCounter = (TRealData*) directive->GetClass()->GetListOfRealData()->FindObject(countName);
79 if (!rdCounter) return nullptr;
80 TDataMember *dmCounter = rdCounter->GetDataMember();
81 cl = dmCounter->GetClass();
82 } else {
83 TStreamerElement *element = (TStreamerElement *)directive->GetElements()->FindObject(countName);
84 if (!element) return nullptr;
85 if (element->IsA() != TStreamerBasicType::Class()) return nullptr;
86 cl = directive->GetClass();
87 }
88 if (cl==nullptr) return nullptr;
90 }
91 } else {
92
93 if (cl==nullptr) return nullptr;
95 }
96
97 //at this point the counter may be declared to be skipped
98 if (counter) {
100 }
101 return counter;
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// Parse comments to search for a range specifier of the style:
106/// [xmin,xmax] or [xmin,xmax,nbits]
107/// [0,1]
108/// [-10,100];
109/// [-pi,pi], [-pi/2,pi/4],[-2pi,2*pi]
110/// [-10,100,16]
111/// [0,0,8]
112/// if nbits is not specified, or nbits <2 or nbits>32 it is set to 32
113/// if (xmin==0 and xmax==0 and nbits <=16) the double word will be converted
114/// to a float and its mantissa truncated to nbits significative bits.
115///
116/// see comments in TBufferFile::WriteDouble32.
117
118static void GetRange(const char *comments, Double_t &xmin, Double_t &xmax, Double_t &factor)
119{
120 const Double_t kPi =3.14159265358979323846 ;
121 factor = xmin = xmax = 0;
122 if (!comments) return;
123 const char *left = strstr(comments,"[");
124 if (!left) return;
125 const char *right = strstr(left,"]");
126 if (!right) return;
127 const char *comma = strstr(left,",");
128 if (!comma || comma > right) {
129 //may be first bracket was a dimension specifier
130 left = strstr(right,"[");
131 if (!left) return;
132 right = strstr(left,"]");
133 if (!right) return;
134 comma = strstr(left,",");
135 if (!comma || comma >right) return;
136 }
137 //search if nbits is specified
138 const char *comma2 = nullptr;
139 if (comma) comma2 = strstr(comma+1,",");
140 if (comma2 > right) comma2 = nullptr;
141 Int_t nbits = 32;
142 if (comma2) {
143 TString sbits(comma2+1,right-comma2-1);
144 sscanf(sbits.Data(),"%d",&nbits);
145 if (nbits < 2 || nbits > 32) {
146 ::Error("GetRange","Illegal specification for the number of bits; %d. reset to 32.",nbits);
147 nbits = 32;
148 }
149 right = comma2;
150 }
151 TString range(left+1,right-left-1);
152 TString sxmin(left+1,comma-left-1);
153 sxmin.ToLower();
154 sxmin.ReplaceAll(" ","");
155 if (sxmin.Contains("pi")) {
156 if (sxmin.Contains("2pi")) xmin = 2*kPi;
157 else if (sxmin.Contains("2*pi")) xmin = 2*kPi;
158 else if (sxmin.Contains("twopi")) xmin = 2*kPi;
159 else if (sxmin.Contains("pi/2")) xmin = kPi/2;
160 else if (sxmin.Contains("pi/4")) xmin = kPi/4;
161 else if (sxmin.Contains("pi")) xmin = kPi;
162 if (sxmin.Contains("-")) xmin = -xmin;
163 } else {
164 sscanf(sxmin.Data(),"%lg",&xmin);
165 }
166 TString sxmax(comma+1,right-comma-1);
167 sxmax.ToLower();
168 sxmax.ReplaceAll(" ","");
169 if (sxmax.Contains("pi")) {
170 if (sxmax.Contains("2pi")) xmax = 2*kPi;
171 else if (sxmax.Contains("2*pi")) xmax = 2*kPi;
172 else if (sxmax.Contains("twopi")) xmax = 2*kPi;
173 else if (sxmax.Contains("pi/2")) xmax = kPi/2;
174 else if (sxmax.Contains("pi/4")) xmax = kPi/4;
175 else if (sxmax.Contains("pi")) xmax = kPi;
176 if (sxmax.Contains("-")) xmax = -xmax;
177 } else {
178 sscanf(sxmax.Data(),"%lg",&xmax);
179 }
181 if (nbits < 32) bigint = 1<<nbits;
182 else bigint = 0xffffffff;
183 if (xmin < xmax) factor = bigint/(xmax-xmin);
184 if (xmin >= xmax && nbits <15) xmin = nbits+0.1;
185}
186
187
188////////////////////////////////////////////////////////////////////////////////
189/// Default ctor.
190
192{
193 // clang-format off
195 fSize = 0;
197 fArrayDim = 0;
198 fArrayLength = 0;
199 fStreamer = nullptr;
200 fOffset = 0;
201 fClassObject = (TClass*)(-1);
202 fNewClass = nullptr;
203 fTObjectOffset = 0;
204 fFactor = 0;
205 fXmin = 0;
206 fXmax = 0;
207 // clang-format on
208 for (Int_t i=0;i<5;i++) fMaxIndex[i] = 0;
209}
210
211////////////////////////////////////////////////////////////////////////////////
212/// Create a TStreamerElement object.
213
214TStreamerElement::TStreamerElement(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName)
215 : TNamed(name,title)
216{
217 fOffset = offset;
218 fType = dtype;
219 fSize = 0;
220 fNewType = fType;
221 fArrayDim = 0;
222 fArrayLength = 0;
223 if (typeName && !strcmp(typeName, "BASE")) {
224 // TStreamerBase case; fTypeName should stay "BASE".
225 fTypeName = typeName;
226 } else {
227 //must protect call into the interpreter
230 }
231 fStreamer = nullptr;
232 fClassObject = (TClass*)(-1);
233 fNewClass = nullptr;
234 fTObjectOffset = 0;
235 fFactor = 0;
236 fXmin = 0;
237 fXmax = 0;
238 for (Int_t i=0;i<5;i++) fMaxIndex[i] = 0;
239 if (fTypeName == "Float16_t" || fTypeName == "Float16_t*") {
241 if (fFactor > 0 || fXmin > 0) SetBit(kHasRange);
242 }
243 if (fTypeName == "Double32_t" || fTypeName == "Double32_t*") {
245 if (fFactor > 0 || fXmin > 0) SetBit(kHasRange);
246 }
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// TStreamerElement dtor.
251
255
256
257////////////////////////////////////////////////////////////////////////////////
258/// Returns true if the element cannot be split, false otherwise.
259/// An element cannot be split if the corresponding class member has
260/// the special characters "||" as the first characters in the
261/// comment field.
262
264{
265 if (GetTitle()[0] != 0 && strspn(GetTitle(),"||") == 2) return kTRUE;
266 TClass *cl = GetClassPointer();
267 if (!cl) return kFALSE; //basic type
268
269 static TClassRef clonesArray("TClonesArray");
270 if (IsaPointer() && cl != clonesArray && !cl->GetCollectionProxy()) return kTRUE;
271
272 switch(fType) {
278 return kTRUE;
279 }
280
281 if ( !cl->CanSplit() ) return kTRUE;
282
283 return kFALSE;
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Returns a pointer to the TClass of this element and updates fClassObject
288
290{
291 if (fClassObject!=(TClass*)(-1)) return fClassObject;
292
295 ((TStreamerElement*)this)->fClassObject = TClass::GetClass(className, kTRUE, quiet);
296 return fClassObject;
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Returns the TExec id for the EXEC instruction in the comment field
301/// of a TRef data member.
302
304{
305 TString typeName = fTypeName;
306 if (typeName != "TRef" && typeName != "TRefArray") {
307 // It's not a ROOT standard TRef or TRefArray class, but it could be a user class
308 // inheriting from it (see ROOT-7052)
310 const auto cl = TClass::GetClass(clName, kFALSE, kTRUE);
311 // FIXME: The check for HasDataMemberInfo() is likely wrong because it could miss inheritance (chains) from TRef.
312 // However, it is needed to protect against non-loaded classes, previously also present in TClass::GetBaseClass.
313 if (!cl || !cl->HasDataMemberInfo())
314 return 0;
315 // Classes cannot both inherit from TRef/TRefArray and have a collection proxy.
316 if (cl->GetCollectionProxy())
317 return 0;
318 // Only classes inheriting from TObject can inherit from TRef. Do not look inside other classes.
319 if (!cl->IsTObject())
320 return 0;
321 if (!cl->InheritsFrom("TRef") && !cl->InheritsFrom("TRefArray"))
322 return 0;
323 }
324
325 //if the UniqueID of this element has already been set, we assume
326 //that it contains the exec id of a TRef object.
327 if (GetUniqueID()) return GetUniqueID();
328
329 //check if an Exec is specified in the comment field
330 char *action = (char*)strstr(GetTitle(),"EXEC:");
331 if (!action) return 0;
332 Int_t nch = strlen(action)+1;
333 char *caction = new char[nch];
335 char *blank = (char*)strchr(caction,' ');
336 if (blank) *blank = 0;
337 //we have found the Exec name in the comment
338 //we register this Exec to the list of Execs.
340 delete [] caction;
341 //we save the Exec index as the uniqueid of this STreamerElement
342 const_cast<TStreamerElement*>(this)->SetUniqueID(index+1);
343 return index+1;
344}
345
346////////////////////////////////////////////////////////////////////////////////
347/// Return element name including dimensions, if any
348/// Note that this function stores the name into a static array.
349/// You should copy the result.
350
352{
354 char cdim[20];
355 name = GetName();
356 for (Int_t i=0;i<fArrayDim;i++) {
357 snprintf(cdim,19,"[%d]",fMaxIndex[i]);
358 name += cdim;
359 }
360 return name;
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Fill type with the string representation of sequence
365/// information including 'cached','repeat','write' or
366/// 'nodelete'.
367
369{
370 sequenceType.Clear();
371 auto test_bit = [this, &sequenceType](unsigned bit, const char *name) {
372 if (TestBit(bit)) {
373 if (!sequenceType.IsNull()) sequenceType += ",";
375 }
376 };
377
383}
384
385////////////////////////////////////////////////////////////////////////////////
386/// Returns size of this element in bytes.
387
389{
390 return fSize;
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Returns the alignment of this element in bytes.
395/// The bare underlying type (stripping kOffsetL / kOffsetP array/pointer markers)
396/// is used to determine the alignment from TDataType.
397
399{
400 // Strip kOffsetL / kOffsetP markers to recover the bare type id.
402 if (bareType == kCounter || bareType == kBits)
403 return sizeof(UInt_t);
404 if (auto *dt = TDataType::GetDataType(bareType); dt && dt->GetAlignOf())
405 return dt->GetAlignOf();
406 Error("TStreamerElement::GetAlignment", "Cannot determine alignment for type %d (bare type %d) for element %s",
408 return alignof(std::max_align_t);
409}
410
411////////////////////////////////////////////////////////////////////////////////
412/// Return the local streamer object.
413
418
419////////////////////////////////////////////////////////////////////////////////
420/// Return type name of this element
421/// in case the type name is not a standard basic type, return
422/// the basic type name known to CINT.
423
425{
426 TDataType *dt = gROOT->GetType(fTypeName.Data());
427 if (fType < 1 || fType > 55) return fTypeName.Data();
428 if (dt && dt->GetType() > 0) return fTypeName.Data();
429 Int_t dtype = fType%20;
431}
432
433////////////////////////////////////////////////////////////////////////////////
434/// Initliaze the element.
435
443
444////////////////////////////////////////////////////////////////////////////////
445/// The early 3.00/00 and 3.01/01 versions used to store
446/// dm->GetTypeName instead of dm->GetFullTypename
447/// if this case is detected, the element type name is modified.
448
450{
451 //if (!IsaPointer()) return kFALSE;
452 if (!strstr(newTypeName,fTypeName.Data())) return kFALSE;
453 //if (!strstr(fTypeName.Data(),newTypeName)) return kFALSE;
455 return kTRUE;
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// Return kTRUE if the element represent a base class.
460
462{
463 return kFALSE;
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Return kTRUE if the element represent an entity that is not written
468/// to the disk (transient members, cache allocator/deallocator, etc.)
469
471{
473 // if (((const TStreamerArtificial*)this)->GetWriteFunc() == 0)
474 return kTRUE;
475 }
481
482 return kFALSE;
483}
484
485////////////////////////////////////////////////////////////////////////////////
486/// Print the content of the element.
487
489{
490 TString temp(GetTypeName());
491 if (IsaPointer() && !fTypeName.Contains("*")) temp += "*";
492
495 if (sequenceType.Length()) {
496 sequenceType.Prepend(" (");
497 sequenceType += ") ";
498 }
499 printf(" %-14s %-15s offset=%3d type=%2d",
500 temp.Data(),GetFullName(),fOffset,fType);
502 printf(" newtype=%2d", fNewType);
503 printf(" %s%-20s\n",
504 sequenceType.Data(), GetTitle());
505}
506
507////////////////////////////////////////////////////////////////////////////////
508/// Set number of array dimensions.
509
518
519////////////////////////////////////////////////////////////////////////////////
520///set maximum index for array with dimension dim
521
523{
524 if (dim < 0 || dim > 4) return;
525 fMaxIndex[dim] = max;
526 if (fArrayLength == 0) fArrayLength = max;
527 else fArrayLength *= max;
528}
529
530////////////////////////////////////////////////////////////////////////////////
531///set pointer to Streamer function for this element
532
537
538////////////////////////////////////////////////////////////////////////////////
539/// Stream an object of class TStreamerElement.
540
542{
544 if (R__b.IsReading()) {
545 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
546 //NOTE that when reading, one cannot use Class()->ReadBuffer
547 // TBuffer::Class methods used for reading streamerinfos from SQL database
548 // Any changes of class structure should be reflected by them starting from version 4
549
550 R__b.ClassBegin(TStreamerElement::Class(), R__v);
551 R__b.ClassMember("TNamed");
553 R__b.ClassMember("fType","Int_t");
554 R__b >> fType;
555 R__b.ClassMember("fSize","Int_t");
556 R__b >> fSize;
557 R__b.ClassMember("fArrayLength","Int_t");
559 R__b.ClassMember("fArrayDim","Int_t");
560 R__b >> fArrayDim;
561 R__b.ClassMember("fMaxIndex","Int_t", 5);
562 if (R__v == 1) R__b.ReadStaticArray(fMaxIndex);
563 else R__b.ReadFastArray(fMaxIndex,5);
564 R__b.ClassMember("fTypeName","TString");
566 if (fType==11&&(fTypeName=="Bool_t"||fTypeName=="bool")) fType = 18;
567 if (R__v > 1) {
568 SetUniqueID(0);
569 //check if element is a TRef or TRefArray
570 GetExecID();
571 }
573 // In TStreamerElement v2, fSize was holding the size of
574 // the underlying data type. In later version it contains
575 // the full length of the data member.
576 TDataType *type = gROOT->GetType(GetTypeName());
577 if (type && fArrayLength) fSize = fArrayLength * type->Size();
578 }
579 if (R__v == 3) {
580 R__b >> fXmin;
581 R__b >> fXmax;
582 R__b >> fFactor;
583 if (fFactor > 0) SetBit(kHasRange);
584 }
585 if (R__v > 3) {
587 }
588 //R__b.CheckByteCount(R__s, R__c, TStreamerElement::IsA());
589 R__b.ClassEnd(TStreamerElement::Class());
590 R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
591
594 } else {
595 R__b.WriteClassBuffer(TStreamerElement::Class(),this);
596 }
597}
598
599////////////////////////////////////////////////////////////////////////////////
600///function called by the TClass constructor when replacing an emulated class
601///by the real class
602
604{
605 if (fClassObject == oldClass) {
609 }
610 } else if (fClassObject == nullptr) {
611 // Well since some emulated class is replaced by a real class, we can
612 // assume a new library has been loaded. If this is the case, we should
613 // check whether the class now exist (this would be the case for example
614 // for reading STL containers).
615
617
618 if (classname == newClass->GetName()) {
622 }
623 } else if (TClassTable::GetDict(classname)) {
624 fClassObject = (TClass*)-1;
625 GetClassPointer(); //force fClassObject
628 }
629 }
630 }
631}
632
633//______________________________________________________________________________
634
635//////////////////////////////////////////////////////////////////////////
636// //
637// TStreamerBase implement the streamer of the base class //
638// //
639//////////////////////////////////////////////////////////////////////////
640
641
642////////////////////////////////////////////////////////////////////////////////
643
645 // Abuse TStreamerElement data member that is not used by TStreamerBase
646 fBaseCheckSum( *( (UInt_t*)&(fMaxIndex[1]) ) ),
647 fStreamerFunc(nullptr), fConvStreamerFunc(nullptr), fStreamerInfo(nullptr)
648{
649 // Default ctor.
650
651 fBaseClass = (TClass*)(-1);
652 fBaseVersion = 0;
653 fNewBaseClass = nullptr;
654}
655
656////////////////////////////////////////////////////////////////////////////////
657
659 : TStreamerElement(name,title,offset,TVirtualStreamerInfo::kBase,"BASE"),
660 // Abuse TStreamerElement data member that is not used by TStreamerBase
661 fBaseCheckSum( *( (UInt_t*)&(fMaxIndex[1]) ) ),
662 fStreamerFunc(nullptr), fConvStreamerFunc(nullptr), fStreamerInfo(nullptr)
663
664{
665 // Create a TStreamerBase object.
666
667 if (strcmp(name,"TObject") == 0) fType = TVirtualStreamerInfo::kTObject;
668 if (strcmp(name,"TNamed") == 0) fType = TVirtualStreamerInfo::kTNamed;
669 fNewType = fType;
671 if (fBaseClass) {
672 if (fBaseClass->IsVersioned()) {
674 } else {
675 fBaseVersion = -1;
676 }
678 } else {
679 fBaseVersion = 0;
680 }
681 fNewBaseClass = nullptr;
683}
684
685////////////////////////////////////////////////////////////////////////////////
686/// TStreamerBase dtor
687
691
692////////////////////////////////////////////////////////////////////////////////
693/// Returns a pointer to the TClass of this element.
694
696{
697 if (fBaseClass!=(TClass*)(-1)) return fBaseClass;
698 ((TStreamerBase*)this)->fBaseClass = TClass::GetClass(GetName());
699 return fBaseClass;
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// Returns size of baseclass in bytes.
704
706{
707 TClass *cl = GetNewClass();
708 if (!cl)
709 cl = GetClassPointer();
710 if (cl)
711 return cl->Size();
712 return 0;
713}
714
715////////////////////////////////////////////////////////////////////////////////
716/// Returns the alignment of the base class in bytes.
717
719{
720 TClass *cl = GetNewClass();
721 if (!cl)
722 cl = GetClassPointer();
723 if (cl && cl->GetClassAlignment())
724 return cl->GetClassAlignment();
725 // The caller will complains if the missing alignment information
726 // causes a problem.
727 return 0;
728}
729
730////////////////////////////////////////////////////////////////////////////////
731/// Setup the element.
732
737
745
746////////////////////////////////////////////////////////////////////////////////
747/// Setup the fStreamerFunc and fStreamerinfo
748
773
774////////////////////////////////////////////////////////////////////////////////
775/// Return kTRUE if the element represent a base class.
776
778{
779 return kTRUE;
780}
781
782////////////////////////////////////////////////////////////////////////////////
783/// Return the proper include for this element.
784
785const char *TStreamerBase::GetInclude() const
786{
788 IncludeNameBuffer().Form("\"%s\"",fBaseClass->GetDeclFileName());
789 } else {
790 std::string shortname( TClassEdit::ShortType( GetName(), 1 ) );
791 IncludeNameBuffer().Form("\"%s.h\"",shortname.c_str());
792 }
793 return IncludeNameBuffer();
794}
795
796////////////////////////////////////////////////////////////////////////////////
797/// Print the content of the element.
798
800{
803 if (sequenceType.Length()) {
804 sequenceType.Prepend(" (");
805 sequenceType += ") ";
806 }
807 printf(" %-14s %-15s offset=%3d type=%2d %s%-20s\n",GetFullName(),GetTypeName(),fOffset,fType,sequenceType.Data(),GetTitle());
808}
809
810////////////////////////////////////////////////////////////////////////////////
811/// Read the content of the buffer.
812
814{
815 if (fConvStreamerFunc) {
816 // We have a custom Streamer member function, we must use it.
818 } else if (fStreamerFunc) {
819 // We have a custom Streamer member function, we must use it.
820 fStreamerFunc(b,pointer+fOffset);
821 } else {
822 // We don't have a custom Streamer member function. That still doesn't mean
823 // that there is no streamer - it could be an external one:
824 // If the old base class has an adopted streamer we take that
825 // one instead of the new base class:
826 if( fNewBaseClass ) {
828 if (extstrm) {
829 // The new base class has an adopted streamer:
830 extstrm->SetOnFileClass(fBaseClass);
831 (*extstrm)(b, pointer);
832 } else {
833 b.ReadClassBuffer( fNewBaseClass, pointer+fOffset, fBaseClass );
834 }
835 } else {
837 if (extstrm) {
838 // The class has an adopted streamer:
839 (*extstrm)(b, pointer);
840 } else {
841 b.ReadClassBuffer( fBaseClass, pointer+fOffset );
842 }
843 }
844 }
845 return 0;
846}
847
848////////////////////////////////////////////////////////////////////////////////
849/// Stream an object of class TStreamerBase.
850
852{
854 if (R__b.IsReading()) {
855 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
856
857 R__b.ClassBegin(TStreamerBase::Class(), R__v);
858
859 R__b.ClassMember("TStreamerElement");
861 // If the class owning the TStreamerElement and the base class are not
862 // loaded, on the file their streamer info might be in the following
863 // order (derived class,base class) and hence the base class is not
864 // yet emulated.
865 fBaseClass = (TClass*)-1;
866 fNewBaseClass = nullptr;
867 // Eventually we need a v3 that stores directly fBaseCheckSum (and
868 // a version of TStreamerElement should not stored fMaxIndex)
869 if (R__v > 2) {
870 R__b.ClassMember("fBaseVersion","Int_t");
872 } else {
873 // could have been: fBaseVersion = GetClassPointer()->GetClassVersion();
876 }
877 R__b.ClassEnd(TStreamerBase::Class());
878 R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
879 } else {
880 R__b.WriteClassBuffer(TStreamerBase::Class(),this);
881 }
882}
883
884////////////////////////////////////////////////////////////////////////////////
885///Function called by the TClass constructor when replacing an emulated class
886///by the real class.
887
889{
891
892 if (fBaseClass == oldClass) {
895 } else if (fBaseClass == nullptr) {
896 if (fName == newClass->GetName()) {
899 } else if (TClassTable::GetDict(fName)) {
902 }
903 }
904}
905
906////////////////////////////////////////////////////////////////////////////////
907/// Write the base class into the buffer.
908
910{
911 if (fStreamerFunc) {
912 // We have a custom Streamer member function, we must use it.
913 fStreamerFunc(b,pointer+fOffset);
914 } else {
915 // We don't have a custom Streamer member function. That still doesn't mean
916 // that there is no streamer - it could be an external one:
917 // If the old base class has an adopted streamer we take that
918 // one instead of the new base class:
919 if (fNewBaseClass) {
921 if (extstrm) {
922 // The new base class has an adopted streamer:
923 extstrm->SetOnFileClass(fBaseClass);
924 (*extstrm)(b, pointer);
925 return 0;
926 } else {
928 return 0;
929 }
930 } else {
932 if (extstrm) {
933 (*extstrm)(b, pointer);
934 return 0;
935 } else {
937 return 0;
938 }
939 }
940 }
941 return 0;
942}
943
944//______________________________________________________________________________
945
946//////////////////////////////////////////////////////////////////////////
947// //
948// TStreamerBasicPointer implements the streamering of pointer to //
949// fundamental types. //
950// //
951//////////////////////////////////////////////////////////////////////////
952
953
954////////////////////////////////////////////////////////////////////////////////
955/// Default ctor.
956
957TStreamerBasicPointer::TStreamerBasicPointer() : fCountVersion(0),fCountName(),fCountClass(),fCounter(nullptr)
958{
959 fCounter = nullptr;
960}
961
962////////////////////////////////////////////////////////////////////////////////
963/// Create a TStreamerBasicPointer object.
964
965TStreamerBasicPointer::TStreamerBasicPointer(const char *name, const char *title, Int_t offset, Int_t dtype, const char *countName, const char *countClass, Int_t countVersion, const char *typeName)
966 : TStreamerElement(name,title,offset,dtype,typeName)
967{
971 fCountVersion = countVersion; //currently unused
972 Init();
973// printf("BasicPointer Init:%s, countName=%s, countClass=%s, countVersion=%d, fCounter=%x\n",
974// name,countName,countClass,countVersion,fCounter);
975}
976
977////////////////////////////////////////////////////////////////////////////////
978/// TStreamerBasicPointer dtor.
979
983
984////////////////////////////////////////////////////////////////////////////////
985/// return offset of counter
986
988{
989 if (!fCounter) ((TStreamerBasicPointer*)this)->Init();
990 if (!fCounter) return 0;
991 // FIXME: does not suport multiple inheritance for counter in base class.
992 // This is wrong in case counter is not in the same class or one of
993 // the left most (non virtual) base classes. For the other we would
994 // really need to use the object coming from the list of real data.
995 // (and even that need analysis for virtual base class).
996 return (ULongptr_t)fCounter->GetOffset();
997}
998
999////////////////////////////////////////////////////////////////////////////////
1000/// Returns size of basicpointer in bytes.
1001
1003{
1004 if (fArrayLength) return fArrayLength*sizeof(void *);
1005 return sizeof(void *);
1006}
1007
1008////////////////////////////////////////////////////////////////////////////////
1009/// Setup the element.
1010/// If directive is a StreamerInfo and it correspond to the
1011/// same class a 'countClass' the streamerInfo is used instead of the current StreamerInfo of the TClass
1012/// for 'countClass'.
1013
1018
1019////////////////////////////////////////////////////////////////////////////////
1020/// Set number of array dimensions.
1021
1023{
1024 fArrayDim = dim;
1025 //if (dim) fType += TVirtualStreamerInfo::kOffsetL;
1026 fNewType = fType;
1027}
1028
1029////////////////////////////////////////////////////////////////////////////////
1030/// Stream an object of class TStreamerBasicPointer.
1031
1033{
1034 UInt_t R__s, R__c;
1035 if (R__b.IsReading()) {
1036 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1037 if (R__v > 1) {
1038 R__b.ReadClassBuffer(TStreamerBasicPointer::Class(), this, R__v, R__s, R__c);
1039 //Init();
1040 //fCounter = InitCounter( fCountClass, fCountName );
1041 return;
1042 }
1043 //====process old versions before automatic schema evolution
1048 R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
1049 } else {
1050 R__b.WriteClassBuffer(TStreamerBasicPointer::Class(),this);
1051 }
1052}
1053
1054
1055//______________________________________________________________________________
1056
1057//////////////////////////////////////////////////////////////////////////
1058// //
1059// TStreamerLoop implement streaming of a few construct that require //
1060// looping over the data member and are not convered by other case //
1061// (most deprecated). //
1062// //
1063//////////////////////////////////////////////////////////////////////////
1064
1065
1066////////////////////////////////////////////////////////////////////////////////
1067/// Default ctor.
1068
1069TStreamerLoop::TStreamerLoop() : fCountVersion(0),fCountName(),fCountClass(),fCounter(nullptr)
1070{
1071}
1072
1073////////////////////////////////////////////////////////////////////////////////
1074/// Create a TStreamerLoop object.
1075
1076TStreamerLoop::TStreamerLoop(const char *name, const char *title, Int_t offset, const char *countName, const char *countClass, Int_t countVersion, const char *typeName)
1077 : TStreamerElement(name,title,offset,TVirtualStreamerInfo::kStreamLoop,typeName)
1078{
1081 fCountVersion = countVersion; //currently unused
1082 Init();
1083}
1084
1085////////////////////////////////////////////////////////////////////////////////
1086/// TStreamerLoop dtor.
1087
1091
1092////////////////////////////////////////////////////////////////////////////////
1093/// Returns the alignment of this element in bytes.
1094/// The bare underlying type (stripping kOffsetL / kOffsetP array/pointer markers)
1095/// is used to determine the alignment from TDataType.
1096
1098{
1099 // Strip kOffsetL / kOffsetP markers to recover the bare type id.
1101 if (bareType == kCounter || bareType == kBits)
1102 return sizeof(UInt_t);
1103 if (auto *dt = TDataType::GetDataType(bareType); dt && dt->GetAlignOf())
1104 return dt->GetAlignOf();
1105 Error("TStreamerLoop::GetAlignment", "Cannot determine alignment for type %d (bare type %d) for element %s", fType,
1106 bareType, GetName());
1107 return alignof(std::max_align_t);
1108}
1109
1110////////////////////////////////////////////////////////////////////////////////
1111/// return address of counter
1112
1114{
1115 //if (!fCounter) {
1116 // Init();
1117 // if (!fCounter) return 0;
1118 //}
1119 if (!fCounter) return 0;
1120 return (ULongptr_t)fCounter->GetOffset();
1121}
1122
1123////////////////////////////////////////////////////////////////////////////////
1124/// Returns size of counter in bytes.
1125
1127{
1128 if (fArrayLength) return fArrayLength*sizeof(void*);
1129 return sizeof(void*);
1130}
1131
1132////////////////////////////////////////////////////////////////////////////////
1133/// Setup the element.
1134/// If directive is a StreamerInfo and it correspond to the
1135/// same class a 'countClass' the streamerInfo is used instead of the current StreamerInfo of the TClass
1136/// for 'countClass'.
1137
1142
1143////////////////////////////////////////////////////////////////////////////////
1144/// Return the proper include for this element.
1145
1146const char *TStreamerLoop::GetInclude() const
1147{
1148 IncludeNameBuffer().Form("<%s>","TString.h"); //to be generalized
1149 return IncludeNameBuffer();
1150}
1151
1152////////////////////////////////////////////////////////////////////////////////
1153/// Stream an object of class TStreamerLoop.
1154
1156{
1157 UInt_t R__s, R__c;
1158 if (R__b.IsReading()) {
1159 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1160 if (R__v > 1) {
1161 R__b.ReadClassBuffer(TStreamerLoop::Class(), this, R__v, R__s, R__c);
1162 //Init();
1163 return;
1164 }
1165 //====process old versions before automatic schema evolution
1170 R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
1171 } else {
1172 R__b.WriteClassBuffer(TStreamerLoop::Class(),this);
1173 }
1174}
1175
1176
1177//______________________________________________________________________________
1178
1179//////////////////////////////////////////////////////////////////////////
1180// //
1181// TStreamerBasicType implement streaming of fundamental types (int, //
1182// float, etc.). //
1183// //
1184//////////////////////////////////////////////////////////////////////////
1185
1186
1187////////////////////////////////////////////////////////////////////////////////
1188/// Default ctor.
1189
1191{
1192}
1193
1194////////////////////////////////////////////////////////////////////////////////
1195/// Create a TStreamerBasicType object.
1196
1197TStreamerBasicType::TStreamerBasicType(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName)
1198 : TStreamerElement(name,title,offset,dtype,typeName),fCounter(0)
1199{
1200}
1201
1202////////////////////////////////////////////////////////////////////////////////
1203/// TStreamerBasicType dtor.
1204
1208
1209////////////////////////////////////////////////////////////////////////////////
1210/// return address of counter
1211
1218
1219////////////////////////////////////////////////////////////////////////////////
1220/// Returns size of this element in bytes.
1221
1223{
1224 return fSize;
1225}
1226
1227////////////////////////////////////////////////////////////////////////////////
1228/// Stream an object of class TStreamerBasicType.
1229
1231{
1232 UInt_t R__s, R__c;
1233 if (R__b.IsReading()) {
1234 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1235 if (R__v > 1) {
1236 R__b.ReadClassBuffer(TStreamerBasicType::Class(), this, R__v, R__s, R__c);
1237 } else {
1238 //====process old versions before automatic schema evolution
1240 R__b.CheckByteCount(R__s, R__c, TStreamerBasicType::IsA());
1241 }
1242 Int_t type = fType;
1245 }
1246 switch(type) {
1247 // basic types
1248 case TVirtualStreamerInfo::kBool: fSize = sizeof(Bool_t); break;
1249 case TVirtualStreamerInfo::kShort: fSize = sizeof(Short_t); break;
1250 case TVirtualStreamerInfo::kInt: fSize = sizeof(Int_t); break;
1251 case TVirtualStreamerInfo::kLong: fSize = sizeof(Long_t); break;
1252 case TVirtualStreamerInfo::kLong64: fSize = sizeof(Long64_t); break;
1253 case TVirtualStreamerInfo::kFloat: fSize = sizeof(Float_t); break;
1254 case TVirtualStreamerInfo::kFloat16: fSize = sizeof(Float_t); break;
1255 case TVirtualStreamerInfo::kDouble: fSize = sizeof(Double_t); break;
1256 case TVirtualStreamerInfo::kDouble32: fSize = sizeof(Double_t); break;
1257 case TVirtualStreamerInfo::kUChar: fSize = sizeof(UChar_t); break;
1258 case TVirtualStreamerInfo::kUShort: fSize = sizeof(UShort_t); break;
1259 case TVirtualStreamerInfo::kUInt: fSize = sizeof(UInt_t); break;
1260 case TVirtualStreamerInfo::kULong: fSize = sizeof(ULong_t); break;
1261 case TVirtualStreamerInfo::kULong64: fSize = sizeof(ULong64_t); break;
1262 case TVirtualStreamerInfo::kBits: fSize = sizeof(UInt_t); break;
1263 case TVirtualStreamerInfo::kCounter: fSize = sizeof(Int_t); break;
1264 case TVirtualStreamerInfo::kChar: fSize = sizeof(Char_t); break;
1265 case TVirtualStreamerInfo::kCharStar: fSize = sizeof(Char_t*); break;
1266 default: return; // If we don't change the size let's not remultiply it.
1267 }
1269 } else {
1270 R__b.WriteClassBuffer(TStreamerBasicType::Class(),this);
1271 }
1272}
1273
1274
1275
1276//______________________________________________________________________________
1277
1278//////////////////////////////////////////////////////////////////////////
1279// //
1280// TStreamerObject implements streaming of embedded objects whose type //
1281// inherits from TObject. //
1282// //
1283//////////////////////////////////////////////////////////////////////////
1284
1285
1286////////////////////////////////////////////////////////////////////////////////
1287/// Default ctor.
1288
1292
1293////////////////////////////////////////////////////////////////////////////////
1294/// Create a TStreamerObject object.
1295
1296TStreamerObject::TStreamerObject(const char *name, const char *title, Int_t offset, const char *typeName)
1297 : TStreamerElement(name,title,offset,0,typeName)
1298{
1300 if (strcmp(typeName,"TObject") == 0) fType = TVirtualStreamerInfo::kTObject;
1301 if (strcmp(typeName,"TNamed") == 0) fType = TVirtualStreamerInfo::kTNamed;
1302 fNewType = fType;
1303 Init();
1304}
1305
1306////////////////////////////////////////////////////////////////////////////////
1307/// TStreamerObject dtor.
1308
1312
1313////////////////////////////////////////////////////////////////////////////////
1314/// Setup the element.
1315
1323
1324////////////////////////////////////////////////////////////////////////////////
1325/// Return the proper include for this element.
1326
1328{
1329 TClass *cl = GetClassPointer();
1330 if (cl && cl->HasInterpreterInfo()) {
1331 IncludeNameBuffer().Form("\"%s\"",cl->GetDeclFileName());
1332 } else {
1333 std::string shortname( TClassEdit::ShortType( GetTypeName(), 1 ) );
1334 IncludeNameBuffer().Form("\"%s.h\"",shortname.c_str());
1335 }
1336 return IncludeNameBuffer();
1337}
1338
1339////////////////////////////////////////////////////////////////////////////////
1340/// Returns size of object class in bytes.
1341
1343{
1344 TClass *cl = GetNewClass();
1345 if (!cl)
1346 cl = GetClassPointer();
1347 Int_t classSize = 8;
1348 if (cl)
1349 classSize = cl->Size();
1350 if (fArrayLength)
1351 return fArrayLength * classSize;
1352 return classSize;
1353}
1354
1355////////////////////////////////////////////////////////////////////////////////
1356/// Returns the alignment of the object class in bytes.
1357
1359{
1360 TClass *cl = GetNewClass();
1361 if (!cl)
1362 cl = GetClassPointer();
1363 if (cl && cl->GetClassAlignment())
1364 return cl->GetClassAlignment();
1365 // The caller will complains if the missing alignment information
1366 // causes a problem.
1367 return 0;
1368}
1369
1370////////////////////////////////////////////////////////////////////////////////
1371/// Stream an object of class TStreamerObject.
1372
1374{
1375 UInt_t R__s, R__c;
1376 if (R__b.IsReading()) {
1377 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1378 if (R__v > 1) {
1379 R__b.ReadClassBuffer(TStreamerObject::Class(), this, R__v, R__s, R__c);
1380 return;
1381 }
1382 //====process old versions before automatic schema evolution
1384 R__b.CheckByteCount(R__s, R__c, TStreamerObject::IsA());
1385 } else {
1386 R__b.WriteClassBuffer(TStreamerObject::Class(),this);
1387 }
1388}
1389
1390
1391//______________________________________________________________________________
1392
1393//////////////////////////////////////////////////////////////////////////
1394// //
1395// TStreamerObjectAny implement streaming of embedded object not //
1396// inheriting from TObject. //
1397// //
1398//////////////////////////////////////////////////////////////////////////
1399
1400
1401////////////////////////////////////////////////////////////////////////////////
1402/// Default ctor.
1403
1407
1408////////////////////////////////////////////////////////////////////////////////
1409/// Create a TStreamerObjectAny object.
1410
1411TStreamerObjectAny::TStreamerObjectAny(const char *name, const char *title, Int_t offset, const char *typeName)
1412 : TStreamerElement(name,title,offset,TVirtualStreamerInfo::kAny,typeName)
1413{
1414 Init();
1415}
1416
1417////////////////////////////////////////////////////////////////////////////////
1418/// TStreamerObjectAny dtor.
1419
1423
1424////////////////////////////////////////////////////////////////////////////////
1425/// Setup the element.
1426
1434
1435////////////////////////////////////////////////////////////////////////////////
1436/// Return the proper include for this element.
1437
1439{
1440 TClass *cl = GetClassPointer();
1441 if (cl && cl->HasInterpreterInfo()) {
1442 IncludeNameBuffer().Form("\"%s\"",cl->GetDeclFileName());
1443 } else {
1444 std::string shortname( TClassEdit::ShortType( GetTypeName(), 1 ) );
1445 IncludeNameBuffer().Form("\"%s.h\"",shortname.c_str());
1446 }
1447 return IncludeNameBuffer();
1448}
1449
1450////////////////////////////////////////////////////////////////////////////////
1451/// Returns size of anyclass in bytes.
1452
1454{
1455 TClass *cl = GetNewClass();
1456 if (!cl)
1457 cl = GetClassPointer();
1458 Int_t classSize = 8;
1459 if (cl)
1460 classSize = cl->Size();
1461 if (fArrayLength)
1462 return fArrayLength * classSize;
1463 return classSize;
1464}
1465
1466////////////////////////////////////////////////////////////////////////////////
1467/// Returns the alignment of the object (non-TObject) class in bytes.
1468
1470{
1471 TClass *cl = GetNewClass();
1472 if (!cl)
1473 cl = GetClassPointer();
1474 if (cl && cl->GetClassAlignment())
1475 return cl->GetClassAlignment();
1476 // The caller will complains if the missing alignment information
1477 // causes a problem.
1478 return 0;
1479}
1480
1481////////////////////////////////////////////////////////////////////////////////
1482/// Stream an object of class TStreamerObjectAny.
1483
1485{
1486 UInt_t R__s, R__c;
1487 if (R__b.IsReading()) {
1488 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1489 if (R__v > 1) {
1490 R__b.ReadClassBuffer(TStreamerObjectAny::Class(), this, R__v, R__s, R__c);
1491 return;
1492 }
1493 //====process old versions before automatic schema evolution
1495 R__b.CheckByteCount(R__s, R__c, TStreamerObjectAny::IsA());
1496 } else {
1497 R__b.WriteClassBuffer(TStreamerObjectAny::Class(),this);
1498 }
1499}
1500
1501
1502
1503//______________________________________________________________________________
1504
1505//////////////////////////////////////////////////////////////////////////
1506// //
1507// TStreamerObjectPointer implements streaming of pointer to object //
1508// inheriting from TObject. //
1509// //
1510//////////////////////////////////////////////////////////////////////////
1511
1512
1513////////////////////////////////////////////////////////////////////////////////
1514/// Default ctor.
1515
1519
1520////////////////////////////////////////////////////////////////////////////////
1521/// Create a TStreamerObjectPointer object.
1522
1524 Int_t offset, const char *typeName)
1525 : TStreamerElement(name,title,offset,TVirtualStreamerInfo::kObjectP,typeName)
1526{
1527 if (strncmp(title,"->",2) == 0) fType = TVirtualStreamerInfo::kObjectp;
1528 fNewType = fType;
1529 Init();
1530}
1531
1532////////////////////////////////////////////////////////////////////////////////
1533/// TStreamerObjectPointer dtor.
1534
1538
1539////////////////////////////////////////////////////////////////////////////////
1540/// Setup the element.
1541
1549
1550////////////////////////////////////////////////////////////////////////////////
1551/// Return the proper include for this element.
1552
1554{
1555 TClass *cl = GetClassPointer();
1556 if (cl && cl->HasInterpreterInfo()) {
1557 IncludeNameBuffer().Form("\"%s\"",cl->GetDeclFileName());
1558 } else {
1559 std::string shortname( TClassEdit::ShortType( GetTypeName(), 1 ) );
1560 IncludeNameBuffer().Form("\"%s.h\"",shortname.c_str());
1561 }
1562
1563 return IncludeNameBuffer();
1564}
1565
1566////////////////////////////////////////////////////////////////////////////////
1567/// Returns size of objectpointer in bytes.
1568
1570{
1571 if (fArrayLength) return fArrayLength*sizeof(void *);
1572 return sizeof(void *);
1573}
1574
1575////////////////////////////////////////////////////////////////////////////////
1576/// Set number of array dimensions.
1577
1579{
1580 fArrayDim = dim;
1581 //if (dim) fType += TVirtualStreamerInfo::kOffsetL;
1582 fNewType = fType;
1583}
1584
1585////////////////////////////////////////////////////////////////////////////////
1586/// Stream an object of class TStreamerObjectPointer.
1587
1589{
1590 UInt_t R__s, R__c;
1591 if (R__b.IsReading()) {
1592 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1593 if (R__v > 1) {
1594 R__b.ReadClassBuffer(TStreamerObjectPointer::Class(), this, R__v, R__s, R__c);
1595 return;
1596 }
1597 //====process old versions before automatic schema evolution
1599 R__b.CheckByteCount(R__s, R__c, TStreamerObjectPointer::IsA());
1600 } else {
1601 R__b.WriteClassBuffer(TStreamerObjectPointer::Class(),this);
1602 }
1603}
1604
1605
1606//______________________________________________________________________________
1607
1608//////////////////////////////////////////////////////////////////////////
1609// //
1610// TStreamerObjectPointerAny implements streaming of pointer to object //
1611// not inheriting from TObject. //
1612// //
1613//////////////////////////////////////////////////////////////////////////
1614
1615
1616////////////////////////////////////////////////////////////////////////////////
1617/// Default ctor.
1618
1622
1623////////////////////////////////////////////////////////////////////////////////
1624/// Create a TStreamerObjectAnyPointer object.
1625
1627 Int_t offset, const char *typeName)
1628 : TStreamerElement(name,title,offset,TVirtualStreamerInfo::kAnyP,typeName)
1629{
1630 if (strncmp(title,"->",2) == 0) fType = TVirtualStreamerInfo::kAnyp;
1631 fNewType = fType;
1632 Init();
1633}
1634
1635////////////////////////////////////////////////////////////////////////////////
1636/// TStreamerObjectAnyPointer dtor.
1637
1641
1642////////////////////////////////////////////////////////////////////////////////
1643/// Setup the element.
1644
1652
1653////////////////////////////////////////////////////////////////////////////////
1654/// Return the proper include for this element.
1655
1657{
1658 TClass *cl = GetClassPointer();
1659 if (cl && cl->HasInterpreterInfo()) {
1660 IncludeNameBuffer().Form("\"%s\"",cl->GetDeclFileName());
1661 } else {
1662 std::string shortname( TClassEdit::ShortType( GetTypeName(), 1 ) );
1663 IncludeNameBuffer().Form("\"%s.h\"",shortname.c_str());
1664 }
1665
1666 return IncludeNameBuffer();
1667}
1668
1669////////////////////////////////////////////////////////////////////////////////
1670/// Returns size of objectpointer in bytes.
1671
1673{
1674 if (fArrayLength) return fArrayLength*sizeof(void *);
1675 return sizeof(void *);
1676}
1677
1678////////////////////////////////////////////////////////////////////////////////
1679/// Set number of array dimensions.
1680
1682{
1683 fArrayDim = dim;
1684 //if (dim) fType += TVirtualStreamerInfo::kOffsetL;
1685 fNewType = fType;
1686}
1687
1688////////////////////////////////////////////////////////////////////////////////
1689/// Stream an object of class TStreamerObjectAnyPointer.
1690
1692{
1693 if (R__b.IsReading()) {
1694 R__b.ReadClassBuffer(TStreamerObjectAnyPointer::Class(), this);
1695 } else {
1696 R__b.WriteClassBuffer(TStreamerObjectAnyPointer::Class(),this);
1697 }
1698}
1699
1700
1701//______________________________________________________________________________
1702
1703//////////////////////////////////////////////////////////////////////////
1704// //
1705// TSreamerString implements streaming of TString. //
1706// //
1707//////////////////////////////////////////////////////////////////////////
1708
1709
1710////////////////////////////////////////////////////////////////////////////////
1711/// Default ctor.
1712
1716
1717////////////////////////////////////////////////////////////////////////////////
1718/// Create a TStreamerString object.
1719
1720TStreamerString::TStreamerString(const char *name, const char *title, Int_t offset)
1721 : TStreamerElement(name,title,offset,TVirtualStreamerInfo::kTString,"TString")
1722{
1723}
1724
1725////////////////////////////////////////////////////////////////////////////////
1726/// TStreamerString dtor.
1727
1731
1732////////////////////////////////////////////////////////////////////////////////
1733/// Return the proper include for this element.
1734
1736{
1737 IncludeNameBuffer().Form("<%s>","TString.h");
1738 return IncludeNameBuffer();
1739}
1740
1741////////////////////////////////////////////////////////////////////////////////
1742/// Returns size of anyclass in bytes.
1743
1745{
1746 if (fArrayLength) return fArrayLength*sizeof(TString);
1747 return sizeof(TString);
1748}
1749
1750////////////////////////////////////////////////////////////////////////////////
1751/// Stream an object of class TStreamerString.
1752
1754{
1755 UInt_t R__s, R__c;
1756 if (R__b.IsReading()) {
1757 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1758 if (R__v > 1) {
1759 R__b.ReadClassBuffer(TStreamerString::Class(), this, R__v, R__s, R__c);
1760 return;
1761 }
1762 //====process old versions before automatic schema evolution
1764 R__b.CheckByteCount(R__s, R__c, TStreamerString::IsA());
1765 } else {
1766 R__b.WriteClassBuffer(TStreamerString::Class(),this);
1767 }
1768}
1769
1770//______________________________________________________________________________
1771
1772//////////////////////////////////////////////////////////////////////////
1773// //
1774// TStreamerSTL implements streamer of STL container. //
1775// //
1776//////////////////////////////////////////////////////////////////////////
1777
1778
1779////////////////////////////////////////////////////////////////////////////////
1780/// Default ctor.
1781
1782TStreamerSTL::TStreamerSTL() : fSTLtype(0), fCtype(0)
1783{
1784}
1785
1786////////////////////////////////////////////////////////////////////////////////
1787/// Create a TStreamerSTL object.
1788
1789TStreamerSTL::TStreamerSTL(const char *name, const char *title, Int_t offset,
1790 const char *typeName, const TVirtualCollectionProxy &proxy, Bool_t dmPointer)
1791 : TStreamerElement(name,title,offset,ROOT::kSTLany,typeName)
1792{
1793 std::string answer;
1796 fTypeName = answer;
1797
1798 if (name==typeName /* intentional pointer comparison */
1799 || strcmp(name,typeName)==0) {
1800 // We have a base class.
1801 fName = fTypeName;
1802 }
1803 fSTLtype = proxy.GetCollectionType();
1804 fCtype = 0;
1805
1807
1808 if (fSTLtype == ROOT::kSTLbitset) {
1809 // Nothing to check
1810 } else if (proxy.GetValueClass()) {
1811 if (proxy.HasPointers()) fCtype = TVirtualStreamerInfo::kObjectp;
1813 } else {
1814 fCtype = proxy.GetType();
1815 if (proxy.HasPointers()) fCtype += TVirtualStreamerInfo::kOffsetP;
1816 auto enumdesc = TEnum::GetEnum(arglist.fElements[1].c_str());
1817 if (enumdesc || gCling->ClassInfo_IsEnum(arglist.fElements[1].c_str())) {
1818 fCtype = enumdesc ? enumdesc->GetUnderlyingType() : 3;
1819 }
1820 }
1823 fNewType = fType;
1824 }
1825}
1826
1827////////////////////////////////////////////////////////////////////////////////
1828/// Create a TStreamerSTL object.
1829
1830TStreamerSTL::TStreamerSTL(const char *name, const char *title, Int_t offset,
1831 const char *typeName, const char *trueType, Bool_t dmPointer)
1832 : TStreamerElement(name,title,offset,ROOT::kSTLany,typeName)
1833{
1834 const char *t = trueType;
1835 if (!t || !*t) t = typeName;
1836
1837 std::string answer;
1840 fTypeName = answer;
1841
1842 if (name==typeName /* intentional pointer comparison */
1843 || strcmp(name,typeName)==0) {
1844 // We have a base class.
1845 fName = fTypeName;
1846 }
1847
1848 if (arglist.fElements.size() < 2) {
1849 Fatal("TStreamerSTL","For %s, the type name (%s) is seemingly not a template (template argument not found)", name, t);
1850 return;
1851 }
1852
1853 const std::string& inside_type = arglist.fElements[1];
1854 std::string inside = (inside_type.find("const ")==0) ? inside_type.substr(6) : inside_type;
1855
1856 // Let's treat the unique_ptr case
1858
1859 bool isPointer = false;
1860 // The incoming name is normalized (it comes from splitting the name of a TClass),
1861 // so all we need to do is drop the last trailing star (if any) and record that information.
1862 while (intype.back() == '*') {
1863 isPointer = true;
1864 intype.pop_back();
1865 }
1866
1867 fSTLtype = TClassEdit::STLKind(arglist.fElements[0]);
1868 fCtype = 0;
1869 if (fSTLtype == ROOT::kNotSTL) { return; }
1871
1872 TDataType *dt = (TDataType*)gROOT->GetListOfTypes()->FindObject(intype.c_str());
1873 if (fSTLtype == ROOT::kSTLbitset) {
1874 // Nothing to check
1875 } else if (dt) {
1876 fCtype = dt->GetType();
1878 } else {
1879 // this could also be a nested enums ... which should work ... be let's see.
1880 TClass *cl = TClass::GetClass(intype.c_str());
1881 if (cl) {
1884 } else {
1885 auto enumdesc = TEnum::GetEnum(intype.c_str());
1886 if (enumdesc || gCling->ClassInfo_IsEnum(intype.c_str())) {
1887 fCtype = enumdesc ? enumdesc->GetUnderlyingType() : 3;
1888 if (isPointer)
1890 } else {
1891 if (intype != "string") {
1892 // This case can happens when 'this' is a TStreamerElement for
1893 // a STL container containing something for which we do not have
1894 // a TVirtualStreamerInfo (This happens in particular is the collection
1895 // objects themselves are always empty) and we do not have the
1896 // dictionary/shared library for the container.
1897 if (GetClassPointer() && GetClassPointer()->IsLoaded()) {
1898 Warning("TStreamerSTL", "For %s we could not find any information about the type %s %d %s",
1899 fTypeName.Data(), arglist.fElements[1].c_str(), fSTLtype, arglist.fElements[0].c_str());
1900 }
1901 }
1902 }
1903 }
1904 }
1905
1908 fNewType = fType;
1909 }
1910}
1911
1912////////////////////////////////////////////////////////////////////////////////
1913/// TStreamerSTL dtor.
1914
1918
1919////////////////////////////////////////////////////////////////////////////////
1920/// We can not split STL's which are inside a variable size array.
1921/// At least for now.
1922
1924{
1925 if (IsaPointer()) {
1926 if (GetTitle()[0]=='[') return kTRUE; // can not split variable size array
1927 return kTRUE;
1928 }
1929
1930 if (GetArrayDim()>=1 && GetArrayLength()>1) return kTRUE;
1931
1933
1934 return kFALSE;
1935}
1936
1937////////////////////////////////////////////////////////////////////////////////
1938/// Return true if the data member is a pointer.
1939
1941{
1942 const char *type_name = GetTypeName();
1943 if ( type_name[strlen(type_name)-1]=='*' ) return kTRUE;
1944 else return kFALSE;
1945}
1946
1947
1948////////////////////////////////////////////////////////////////////////////////
1949/// Return kTRUE if the element represent a base class.
1950
1952{
1953 TString ts(GetName());
1954
1955 if (strcmp(ts.Data(),GetTypeName())==0) return kTRUE;
1956 if (strcmp(ts.Data(),GetTypeNameBasic())==0) return kTRUE;
1957 return kFALSE;
1958}
1959
1960////////////////////////////////////////////////////////////////////////////////
1961/// Returns a pointer to the TClass of this element.
1962
1964{
1965 if (fClassObject!=(TClass*)(-1))
1966 return fClassObject;
1967
1969
1971 TClass *cl = TClass::GetClass(className, kTRUE, quiet);
1972
1973 auto proxy = cl->GetCollectionProxy();
1974 if (!fNewClass && proxy && proxy->GetValueClass() == nullptr) {
1975 // Collection of numerical type, let check if it is an enum.
1977 if ( arglist.fElements[1].size() >= 2 ) {
1978 auto enumdesc = TEnum::GetEnum(arglist.fElements[1].c_str());
1979 if (enumdesc || gCling->ClassInfo_IsEnum(arglist.fElements[1].c_str())) {
1980 ((TStreamerElement *)this)->fNewClass = cl;
1981 if (proxy->HasPointers())
1982 cl = TClass::GetClass("vector<Int_t*>");
1983 else
1984 cl = TClass::GetClass("vector<Int_t>");
1985 }
1986 }
1987 }
1988 ((TStreamerElement*)this)->fClassObject = cl;
1989 return fClassObject;
1990}
1991
1992////////////////////////////////////////////////////////////////////////////////
1993/// Returns size of STL container in bytes.
1994
1996{
1997 // Since the STL collection might or might not be emulated and that the
1998 // sizeof the object depends on this, let's just always retrieve the
1999 // current size!
2000 TClass *cl = GetNewClass();
2001 if (!cl)
2002 cl = GetClassPointer();
2003 UInt_t size = 0;
2004 if (cl==nullptr) {
2005 if (!TestBit(kWarned)) {
2006 Error("GetSize","Could not find the TClass for %s.\n"
2007 "This is likely to have been a typedef, if possible please declare it in CINT to work around the issue\n",fTypeName.Data());
2008 const_cast<TStreamerSTL*>(this)->SetBit(kWarned);
2009 }
2010 } else {
2011 size = cl->Size();
2012 }
2013
2014 if (fArrayLength) return fArrayLength*size;
2015 return size;
2016}
2017
2018////////////////////////////////////////////////////////////////////////////////
2019/// Returns the alignment of the STL container in bytes.
2020
2022{
2023 TClass *cl = GetNewClass();
2024 if (!cl)
2025 cl = GetClassPointer();
2026 if (cl && cl->GetClassAlignment())
2027 return cl->GetClassAlignment();
2028 // The caller will complains if the missing alignment information
2029 // causes a problem.
2030 return 0;
2031}
2032
2033////////////////////////////////////////////////////////////////////////////////
2034/// Print the content of the element.
2035
2037{
2039 TString cdim;
2040 name = GetName();
2041 for (Int_t i=0;i<fArrayDim;i++) {
2042 cdim.Form("[%d]",fMaxIndex[i]);
2043 name += cdim;
2044 }
2047 if (sequenceType.Length()) {
2048 sequenceType.Prepend(" (");
2049 sequenceType += ") ";
2050 }
2051 printf(" %-14s %-15s offset=%3d type=%2d",
2052 GetTypeName(), name.Data(), fOffset, fType);
2054 printf(" newtype=%2d", fNewType);
2055 printf(" stl=%d ctype=%d %s%-20s\n",
2056 fSTLtype, fCtype, sequenceType.Data(), GetTitle());
2057}
2058
2059////////////////////////////////////////////////////////////////////////////////
2060/// Return the proper include for this element.
2061
2062const char *TStreamerSTL::GetInclude() const
2063{
2064 if (fSTLtype == ROOT::kSTLvector) IncludeNameBuffer().Form("<%s>","vector");
2065 else if (fSTLtype == ROOT::kSTLlist) IncludeNameBuffer().Form("<%s>","list");
2066 else if (fSTLtype == ROOT::kSTLforwardlist) IncludeNameBuffer().Form("<%s>","forward_list");
2067 else if (fSTLtype == ROOT::kSTLdeque) IncludeNameBuffer().Form("<%s>","deque");
2068 else if (fSTLtype == ROOT::kSTLmap) IncludeNameBuffer().Form("<%s>","map");
2069 else if (fSTLtype == ROOT::kSTLmultimap) IncludeNameBuffer().Form("<%s>","map");
2070 else if (fSTLtype == ROOT::kSTLset) IncludeNameBuffer().Form("<%s>","set");
2071 else if (fSTLtype == ROOT::kSTLmultiset) IncludeNameBuffer().Form("<%s>","set");
2072 else if (fSTLtype == ROOT::kSTLunorderedset) IncludeNameBuffer().Form("<%s>","unordered_set");
2073 else if (fSTLtype == ROOT::kSTLunorderedmultiset) IncludeNameBuffer().Form("<%s>","unordered_set");
2074 else if (fSTLtype == ROOT::kSTLunorderedmap) IncludeNameBuffer().Form("<%s>","unordered_map");
2075 else if (fSTLtype == ROOT::kSTLunorderedmultimap) IncludeNameBuffer().Form("<%s>","unordered_map");
2076 else if (fSTLtype == ROOT::kSTLbitset) IncludeNameBuffer().Form("<%s>","bitset");
2077 return IncludeNameBuffer();
2078}
2079
2080////////////////////////////////////////////////////////////////////////////////
2081/// Set pointer to Streamer function for this element
2082/// NOTE: we do not take ownership
2083
2088
2089////////////////////////////////////////////////////////////////////////////////
2090/// Stream an object of class TStreamerSTL.
2091
2093{
2094 UInt_t R__s, R__c;
2095 if (R__b.IsReading()) {
2096 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
2097 if (R__v > 2) {
2098 R__b.ReadClassBuffer(TStreamerSTL::Class(), this, R__v, R__s, R__c);
2099 } else {
2100 //====process old versions before automatic schema evolution
2102 R__b >> fSTLtype;
2103 R__b >> fCtype;
2104 R__b.CheckByteCount(R__s, R__c, TStreamerSTL::IsA());
2105 }
2106 // In old versions (prior to v6.24/02) the value of fArrayDim was not stored properly.
2107 if (fArrayDim == 0 && fArrayLength > 0) {
2108 while(fArrayDim < 5 && fMaxIndex[fArrayDim] != 0) {
2109 ++fArrayDim;
2110 }
2111 }
2113 // For a long time those where inverted in TStreamerElement
2114 // compared to the other definitions. When we moved to version '4',
2115 // this got standardized, but we now need to fix it.
2116
2117 if (fTypeName.BeginsWith("std::set") || fTypeName.BeginsWith("set")) {
2119 } else if (fTypeName.BeginsWith("std::multimap") || fTypeName.BeginsWith("multimap")) {
2121 }
2122 }
2123
2126 if (GetArrayLength() > 0) {
2128 }
2129 if (R__b.GetParent()) { // Avoid resetting during a cloning.
2131 SetBit(kDoNotDelete); // For backward compatibility
2132 } else if ( fSTLtype == ROOT::kSTLmap || fSTLtype == ROOT::kSTLmultimap) {
2133 // Here we would like to set the bit only if one of the element of the pair is a pointer,
2134 // however we have no easy to determine this short of parsing the class name.
2135 SetBit(kDoNotDelete); // For backward compatibility
2136 }
2137 }
2138 return;
2139 } else {
2140 // To enable forward compatibility we actually save with the old value
2142 // Hand coded copy constructor since the 'normal' one are intentionally
2143 // deleted.
2144 tmp.fName = fName;
2145 tmp.fTitle = fTitle;
2147 tmp.fSize = fSize;
2148 tmp.fArrayDim = fArrayDim;
2149 tmp.fArrayLength = fArrayLength;
2150 for(int i = 0; i < 5; ++i)
2151 tmp.fMaxIndex[i] = fMaxIndex[i];
2152 tmp.fTypeName = fTypeName;
2153 tmp.fSTLtype = fSTLtype;
2154 tmp.fCtype = fCtype;
2155 R__b.WriteClassBuffer(TStreamerSTL::Class(), &tmp);
2156 }
2157}
2158
2159//______________________________________________________________________________
2160
2161//////////////////////////////////////////////////////////////////////////
2162// //
2163// TStreamerSTLstring implements streaming std::string. //
2164// //
2165//////////////////////////////////////////////////////////////////////////
2166
2167
2168////////////////////////////////////////////////////////////////////////////////
2169/// Default ctor.
2170
2174
2175////////////////////////////////////////////////////////////////////////////////
2176/// Create a TStreamerSTLstring object.
2177
2179 const char *typeName, Bool_t dmPointer)
2180 : TStreamerSTL()
2181{
2182 SetName(name);
2183 SetTitle(title);
2184
2185 if (dmPointer) {
2187 } else {
2189 }
2190
2191 fNewType = fType;
2192 fOffset = offset;
2195 fTypeName= typeName;
2196
2197}
2198
2199////////////////////////////////////////////////////////////////////////////////
2200/// TStreamerSTLstring dtor.
2201
2205
2206////////////////////////////////////////////////////////////////////////////////
2207/// Return the proper include for this element.
2208
2210{
2211 IncludeNameBuffer() = "<string>";
2212 return IncludeNameBuffer();
2213}
2214
2215////////////////////////////////////////////////////////////////////////////////
2216/// Returns size of anyclass in bytes.
2217
2219{
2220 if (fArrayLength) return fArrayLength*sizeof(string);
2221 return sizeof(string);
2222}
2223
2224////////////////////////////////////////////////////////////////////////////////
2225/// Stream an object of class TStreamerSTLstring.
2226
2228{
2229 UInt_t R__s, R__c;
2230 if (R__b.IsReading()) {
2231 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
2232 if (R__v > 1) {
2233 R__b.ReadClassBuffer(TStreamerSTLstring::Class(), this, R__v, R__s, R__c);
2234 return;
2235 }
2236 //====process old versions before automatic schema evolution
2238 R__b.CheckByteCount(R__s, R__c, TStreamerSTLstring::IsA());
2239 } else {
2240 R__b.WriteClassBuffer(TStreamerSTLstring::Class(),this);
2241 }
2242}
2243
2244//______________________________________________________________________________
2245
2246///////////////////////////////////////////////////////////////////////////////
2247// //
2248// TStreamerArtificial implements StreamerElement injected by a TSchemaRule. //
2249// //
2250///////////////////////////////////////////////////////////////////////////////
2251
2252
2254{
2255 // Avoid streaming the synthetic/artificial streamer elements.
2256
2257 // Intentionally, nothing to do at all.
2258 return;
2259}
2260
2262{
2263 // Return the read function if any.
2264
2265 return fReadFunc;
2266}
2267
2269{
2270 // Return the raw read function if any.
2271
2272 return fReadRawFunc;
2273}
#define b(i)
Definition RSha256.hxx:100
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:54
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:51
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
Definition RtypesCore.h:84
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
EDataType
Definition TDataType.h:28
@ kBits
Definition TDataType.h:34
@ kCounter
Definition TDataType.h:34
const Int_t kMaxLen
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:145
float xmin
float xmax
R__EXTERN TVirtualMutex * gInterpreterMutex
R__EXTERN TInterpreter * gCling
#define gROOT
Definition TROOT.h:426
static TStreamerBasicType * InitCounter(const char *countClass, const char *countName, TVirtualStreamerInfo *directive)
Helper function to initialize the 'index/counter' value of the Pointer streamerElements.
static TString & IncludeNameBuffer()
static void GetRange(const char *comments, Double_t &xmin, Double_t &xmax, Double_t &factor)
Parse comments to search for a range specifier of the style: [xmin,xmax] or [xmin,...
const Int_t kMaxLen
static TString ExtractClassName(const TString &type_name)
#define R__LOCKGUARD(mutex)
#define snprintf
Definition civetweb.c:1579
void(* ReadFuncPtr_t)(char *, TVirtualObject *)
Definition TSchemaRule.h:77
void(* ReadRawFuncPtr_t)(char *, TBuffer &)
Definition TSchemaRule.h:78
Buffer base class used for serializing objects.
Definition TBuffer.h:43
TClassRef is used to implement a permanent reference to a TClass object.
Definition TClassRef.h:29
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
UInt_t GetCheckSum(ECheckSum code=kCurrentCheckSum) const
Call GetCheckSum with validity check.
Definition TClass.cxx:6616
Bool_t CanSplit() const
Return true if the data member of this TClass can be saved separately.
Definition TClass.cxx:2326
ClassStreamerFunc_t GetStreamerFunc() const
Get a wrapper/accessor function around this class custom streamer (member function).
Definition TClass.cxx:2960
size_t GetClassAlignment() const
Return the alignment requirement (in bytes) for objects of this class.
Definition TClass.cxx:5781
TClassStreamer * GetStreamer() const
Return the Streamer Class allowing streaming (if any).
Definition TClass.cxx:2935
Bool_t HasInterpreterInfo() const
Definition TClass.h:424
Int_t Size() const
Return size of object of this class.
Definition TClass.cxx:5806
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition TClass.cxx:6043
ClassConvStreamerFunc_t GetConvStreamerFunc() const
Get a wrapper/accessor function around this class custom conversion streamer (member function).
Definition TClass.cxx:2968
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
Definition TClass.cxx:4657
Int_t GetBaseClassOffset(const TClass *toBase, void *address=nullptr, bool isDerivedObject=true)
Definition TClass.cxx:2812
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Definition TClass.cxx:2918
TVirtualStreamerInfo * GetConversionStreamerInfo(const char *onfile_classname, Int_t version) const
Return a Conversion StreamerInfo from the class 'classname' for version number 'version' to this clas...
Definition TClass.cxx:7209
TVirtualStreamerInfo * FindConversionStreamerInfo(const char *onfile_classname, UInt_t checksum) const
Return a Conversion StreamerInfo from the class 'classname' for the layout represented by 'checksum' ...
Definition TClass.cxx:7316
Bool_t IsVersioned() const
Definition TClass.h:538
TVirtualStreamerInfo * FindStreamerInfo(TObjArray *arr, UInt_t checksum) const
Find the TVirtualStreamerInfo in the StreamerInfos corresponding to checksum.
Definition TClass.cxx:7189
Version_t GetClassVersion() const
Definition TClass.h:434
const char * GetDeclFileName() const
Return name of the file containing the declaration of this class.
Definition TClass.cxx:3525
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2994
Int_t WriteBuffer(TBuffer &b, void *pointer, const char *info="")
Function called by the Streamer functions to serialize object at p to buffer b.
Definition TClass.cxx:6887
All ROOT classes may have RTTI (run time type identification) support added.
Definition TDataMember.h:31
Basic data type descriptor (datatype information is obtained from CINT).
Definition TDataType.h:44
TString GetTypeName()
Get basic type of typedef, e,g.: "class TDirectory*" -> "TDirectory".
static TDataType * GetDataType(EDataType type)
Given a EDataType type, get the TDataType* that represents it.
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Definition TEnum.cxx:181
virtual Bool_t ClassInfo_IsEnum(const char *) const
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
void Streamer(TBuffer &) override
Stream an object of class TObject.
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TString fTitle
Definition TNamed.h:33
TString fName
Definition TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:477
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
static TClass * Class()
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:885
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1123
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:896
void ResetBit(UInt_t f)
Definition TObject.h:203
The TRealData class manages the effective list of all data members for a given class.
Definition TRealData.h:30
static Int_t AddExec(const char *name)
If Exec with name does not exist in the list of Execs, it is created.
Definition TRef.cxx:338
void Streamer(TBuffer &) override
Stream an object of class TObject.
ROOT::TSchemaRule::ReadRawFuncPtr_t GetReadRawFunc()
ROOT::TSchemaRule::ReadRawFuncPtr_t fReadRawFunc
!
ROOT::TSchemaRule::ReadFuncPtr_t GetReadFunc()
ROOT::TSchemaRule::ReadFuncPtr_t fReadFunc
!
Int_t GetSize() const override
Returns size of baseclass in bytes.
void InitStreaming(Bool_t isTransient)
Setup the fStreamerFunc and fStreamerinfo.
UInt_t & fBaseCheckSum
!checksum of the base class (used during memberwise streaming)
Bool_t IsBase() const override
Return kTRUE if the element represent a base class.
std::size_t GetAlignment() const override
Returns the alignment of the base class in bytes.
Int_t WriteBuffer(TBuffer &b, char *pointer)
Write the base class into the buffer.
virtual ~TStreamerBase()
TStreamerBase dtor.
const char * GetInclude() const override
Return the proper include for this element.
TClass * fBaseClass
!pointer to base class
TClass * GetClassPointer() const override
Returns a pointer to the TClass of this element.
void ls(Option_t *option="") const override
Print the content of the element.
void Update(const TClass *oldClass, TClass *newClass) override
Function called by the TClass constructor when replacing an emulated class by the real class.
Int_t ReadBuffer(TBuffer &b, char *pointer)
Read the content of the buffer.
ClassConvStreamerFunc_t fConvStreamerFunc
!Pointer to a wrapper around a custom convertion streamer member function.
static TClass * Class()
void Init(TVirtualStreamerInfo *obj=nullptr) override
Setup the element.
void Streamer(TBuffer &) override
Stream an object of class TStreamerBase.
TClass * fNewBaseClass
!pointer to new base class if renamed
TVirtualStreamerInfo * fStreamerInfo
!Pointer to the current StreamerInfo for the baset class.
ClassStreamerFunc_t fStreamerFunc
!Pointer to a wrapper around a custom streamer member function.
virtual ~TStreamerBasicPointer()
TStreamerBasicPointer dtor.
ULongptr_t GetMethod() const override
return offset of counter
static TClass * Class()
TStreamerBasicPointer()
Default ctor.
void SetArrayDim(Int_t dim) override
Set number of array dimensions.
void Init(TVirtualStreamerInfo *obj=nullptr) override
Setup the element.
void Streamer(TBuffer &) override
Stream an object of class TStreamerBasicPointer.
TStreamerBasicType * fCounter
!pointer to basic type counter
Int_t GetSize() const override
Returns size of basicpointer in bytes.
Int_t GetSize() const override
Returns size of this element in bytes.
TClass * IsA() const override
static TClass * Class()
Int_t fCounter
!value of data member when referenced by an array
ULongptr_t GetMethod() const override
return address of counter
TStreamerBasicType()
Default ctor.
void Streamer(TBuffer &) override
Stream an object of class TStreamerBasicType.
virtual ~TStreamerBasicType()
TStreamerBasicType dtor.
Describe one element (data member) to be Streamed.
void Streamer(TBuffer &) override
Stream an object of class TStreamerElement.
TStreamerElement()
Default ctor.
virtual Int_t GetSize() const
Returns size of this element in bytes.
Int_t fOffset
!element offset in class
Int_t GetType() const
virtual Bool_t IsOldFormat(const char *newTypeName)
The early 3.00/00 and 3.01/01 versions used to store dm->GetTypeName instead of dm->GetFullTypename i...
virtual void Init(TVirtualStreamerInfo *obj=nullptr)
Initliaze the element.
virtual const char * GetFullName() const
Return element name including dimensions, if any Note that this function stores the name into a stati...
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element and updates fClassObject.
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
virtual ~TStreamerElement()
TStreamerElement dtor.
Int_t GetArrayDim() const
TMemberStreamer * GetStreamer() const
Return the local streamer object.
Int_t fTObjectOffset
!base offset for TObject if the element inherits from it
Double_t fXmax
!Maximum of data member if a range is specified [xmin,xmax,nbits]
TClass * GetNewClass() const
Int_t GetArrayLength() const
virtual void SetStreamer(TMemberStreamer *streamer)
set pointer to Streamer function for this element
TMemberStreamer * fStreamer
!pointer to element Streamer
void ls(Option_t *option="") const override
Print the content of the element.
virtual Bool_t IsTransient() const
Return kTRUE if the element represent an entity that is not written to the disk (transient members,...
Double_t fFactor
!Conversion factor if a range is specified fFactor = (1<<nbits/(xmax-xmin)
virtual Bool_t IsaPointer() const
virtual void Update(const TClass *oldClass, TClass *newClass)
function called by the TClass constructor when replacing an emulated class by the real class
const char * GetTypeName() const
virtual Bool_t CannotSplit() const
Returns true if the element cannot be split, false otherwise.
TClass * IsA() const override
virtual void SetType(Int_t dtype)
Int_t GetOffset() const
Double_t fXmin
!Minimum of data member if a range is specified [xmin,xmax,nbits]
TClass * fClassObject
!pointer to class of object
const char * GetTypeNameBasic() const
Return type name of this element in case the type name is not a standard basic type,...
virtual Bool_t IsBase() const
Return kTRUE if the element represent a base class.
virtual Int_t GetExecID() const
Returns the TExec id for the EXEC instruction in the comment field of a TRef data member.
static TClass * Class()
TClass * fNewClass
!new element class when reading
virtual void SetMaxIndex(Int_t dim, Int_t max)
set maximum index for array with dimension dim
virtual std::size_t GetAlignment() const
Returns the alignment of this element in bytes.
void GetSequenceType(TString &type) const
Fill type with the string representation of sequence information including 'cached',...
Int_t fNewType
!new element type when reading
const char * GetInclude() const override
Return the proper include for this element.
void Init(TVirtualStreamerInfo *obj=nullptr) override
Setup the element.
Int_t GetSize() const override
Returns size of counter in bytes.
TStreamerBasicType * fCounter
!pointer to basic type counter
virtual ~TStreamerLoop()
TStreamerLoop dtor.
ULongptr_t GetMethod() const override
return address of counter
void Streamer(TBuffer &) override
Stream an object of class TStreamerLoop.
std::size_t GetAlignment() const override
Returns the alignment of this element in bytes.
static TClass * Class()
TStreamerLoop()
Default ctor.
static TClass * Class()
const char * GetInclude() const override
Return the proper include for this element.
void Streamer(TBuffer &) override
Stream an object of class TStreamerObjectAnyPointer.
void SetArrayDim(Int_t dim) override
Set number of array dimensions.
void Init(TVirtualStreamerInfo *obj=nullptr) override
Setup the element.
virtual ~TStreamerObjectAnyPointer()
TStreamerObjectAnyPointer dtor.
Int_t GetSize() const override
Returns size of objectpointer in bytes.
virtual ~TStreamerObjectAny()
TStreamerObjectAny dtor.
Int_t GetSize() const override
Returns size of anyclass in bytes.
TClass * IsA() const override
static TClass * Class()
const char * GetInclude() const override
Return the proper include for this element.
TStreamerObjectAny()
Default ctor.
void Init(TVirtualStreamerInfo *obj=nullptr) override
Setup the element.
std::size_t GetAlignment() const override
Returns the alignment of the object (non-TObject) class in bytes.
void Streamer(TBuffer &) override
Stream an object of class TStreamerObjectAny.
TClass * IsA() const override
void Init(TVirtualStreamerInfo *obj=nullptr) override
Setup the element.
TStreamerObjectPointer()
Default ctor.
virtual ~TStreamerObjectPointer()
TStreamerObjectPointer dtor.
void Streamer(TBuffer &) override
Stream an object of class TStreamerObjectPointer.
Int_t GetSize() const override
Returns size of objectpointer in bytes.
static TClass * Class()
void SetArrayDim(Int_t dim) override
Set number of array dimensions.
const char * GetInclude() const override
Return the proper include for this element.
void Init(TVirtualStreamerInfo *obj=nullptr) override
Setup the element.
TClass * IsA() const override
static TClass * Class()
void Streamer(TBuffer &) override
Stream an object of class TStreamerObject.
TStreamerObject()
Default ctor.
std::size_t GetAlignment() const override
Returns the alignment of the object class in bytes.
virtual ~TStreamerObject()
TStreamerObject dtor.
Int_t GetSize() const override
Returns size of object class in bytes.
const char * GetInclude() const override
Return the proper include for this element.
TClass * GetClassPointer() const override
Returns a pointer to the TClass of this element.
Bool_t IsaPointer() const override
Return true if the data member is a pointer.
Int_t GetSize() const override
Returns size of STL container in bytes.
const char * GetInclude() const override
Return the proper include for this element.
static TClass * Class()
std::size_t GetAlignment() const override
Returns the alignment of the STL container in bytes.
TStreamerSTL()
Default ctor.
void SetStreamer(TMemberStreamer *streamer) override
Set pointer to Streamer function for this element NOTE: we do not take ownership.
Bool_t CannotSplit() const override
We can not split STL's which are inside a variable size array.
void Streamer(TBuffer &) override
Stream an object of class TStreamerSTL.
TClass * IsA() const override
virtual ~TStreamerSTL()
TStreamerSTL dtor.
void ls(Option_t *option="") const override
Print the content of the element.
Bool_t IsBase() const override
Return kTRUE if the element represent a base class.
Int_t GetSize() const override
Returns size of anyclass in bytes.
virtual ~TStreamerSTLstring()
TStreamerSTLstring dtor.
void Streamer(TBuffer &) override
Stream an object of class TStreamerSTLstring.
static TClass * Class()
TClass * IsA() const override
TStreamerSTLstring()
Default ctor.
const char * GetInclude() const override
Return the proper include for this element.
TStreamerString()
Default ctor.
const char * GetInclude() const override
Return the proper include for this element.
static TClass * Class()
TClass * IsA() const override
Int_t GetSize() const override
Returns size of anyclass in bytes.
virtual ~TStreamerString()
TStreamerString dtor.
void Streamer(TBuffer &) override
Stream an object of class TStreamerString.
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
@ kTrailing
Definition TString.h:284
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:632
TString & Remove(Ssiz_t pos)
Definition TString.h:694
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1418
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:660
Defines a common interface to inspect/change the contents of an object that represents a collection.
Abstract Interface class describing Streamer information for one class.
@ kUChar
Equal to TDataType's kchar.
static TStreamerBasicType * GetElementCounter(const char *countName, TClass *cl)
Get pointer to a TStreamerBasicType in TClass *cl static function.
@ kSTLbitset
Definition ESTLType.h:37
@ kSTLmap
Definition ESTLType.h:33
@ kSTLunorderedmultiset
Definition ESTLType.h:43
@ kSTLstring
Definition ESTLType.h:49
@ kSTLset
Definition ESTLType.h:35
@ kSTLmultiset
Definition ESTLType.h:36
@ kSTLdeque
Definition ESTLType.h:32
@ kSTLvector
Definition ESTLType.h:30
@ kSTLunorderedmultimap
Definition ESTLType.h:45
@ kSTLunorderedset
Definition ESTLType.h:42
@ kSTLlist
Definition ESTLType.h:31
@ kSTLforwardlist
Definition ESTLType.h:41
@ kSTLunorderedmap
Definition ESTLType.h:44
@ kNotSTL
Definition ESTLType.h:29
@ kSTLmultimap
Definition ESTLType.h:34
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
std::string GetNameForIO(const std::string &templateInstanceName, TClassEdit::EModType mode=TClassEdit::kNone, bool *hasChanged=nullptr)
@ kDropStlDefault
Definition TClassEdit.h:83