Logo ROOT   6.16/01
Reference Guide
TStreamerInfoWriteBuffer.cxx
Go to the documentation of this file.
1// @(#)root/io:$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 "TBuffer.h"
13#include "TClass.h"
14#include "TClonesArray.h"
15#include "TError.h"
16#include "TProcessID.h"
17#include "TStreamer.h"
18#include "TStreamerElement.h"
19#include "TStreamerInfo.h"
21#include "TRefTable.h"
22#include "TFile.h"
23
24#include "TVirtualArray.h"
25#include "TBufferFile.h"
26#include "TInterpreter.h"
27
28//==========CPP macros
29
30#define DOLOOP for(int k=0; k<narr; ++k)
31
32#define WriteBasicTypeElem(name,index) \
33 { \
34 name *x=(name*)(arr[index]+ioffset); \
35 b << *x; \
36 }
37
38#define WriteBasicType(name) \
39 { \
40 WriteBasicTypeElem(name,0); \
41 }
42
43#define WriteBasicTypeLoop(name) \
44 { \
45 for(int k=0; k<narr; ++k) WriteBasicTypeElem(name,k); \
46 }
47
48#define WriteBasicArrayElem(name,index) \
49 { \
50 name *x=(name*)(arr[index]+ioffset); \
51 b.WriteFastArray(x,compinfo[i]->fLength); \
52 }
53
54#define WriteBasicArray(name) \
55 { \
56 WriteBasicArrayElem(name,0); \
57 }
58
59#define WriteBasicArrayLoop(name) \
60 { \
61 for(int k=0; k<narr; ++k) WriteBasicArrayElem(name,k); \
62 }
63
64#define WriteBasicPointerElem(name,index) \
65 { \
66 Int_t *l = (Int_t*)(arr[index]+imethod); \
67 name **f = (name**)(arr[index]+ioffset); \
68 name *af = *f; \
69 if (af && *l) b << Char_t(1); \
70 else {b << Char_t(0); continue;} \
71 int j; \
72 for(j=0;j<compinfo[i]->fLength;j++) { \
73 b.WriteFastArray(f[j],*l); \
74 } \
75 }
76
77#define WriteBasicPointer(name) \
78 { \
79 int imethod = compinfo[i]->fMethod+eoffset; \
80 WriteBasicPointerElem(name,0); \
81 }
82
83#define WriteBasicPointerLoop(name) \
84 { \
85 int imethod = compinfo[i]->fMethod+eoffset; \
86 for(int k=0; k<narr; ++k) { \
87 WriteBasicPointerElem(name,k); \
88 } \
89 }
90
91// Helper function for TStreamerInfo::WriteBuffer
92namespace {
93 template <class T> Bool_t R__TestUseCache(TStreamerElement *element)
94 {
95 return element->TestBit(TStreamerElement::kCache);
96 }
97
98 template <> Bool_t R__TestUseCache<TVirtualArray>(TStreamerElement*)
99 {
100 // We are already using the cache, no need to recurse one more time.
101 return kFALSE;
102 }
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// The object at pointer is serialized to the buffer b
107/// if (arrayMode & 1) ptr is a pointer to array of pointers to the objects
108/// otherwise it is a pointer to a pointer to a single object.
109/// This also means that T is of a type such that arr[i] is a pointer to an
110/// object. Currently the only anticipated instantiation are for T==char**
111/// and T==TVirtualCollectionProxy
112
113template <class T>
115 TCompInfo *const*const compinfo, Int_t first, Int_t last,
116 Int_t narr, Int_t eoffset, Int_t arrayMode)
117{
118 Bool_t needIncrement = !( arrayMode & 2 );
119 arrayMode = arrayMode & (~2);
120
121 if (needIncrement) b.IncrementLevel(this);
122
123 //mark this class as being used in the current file
124 b.TagStreamerInfo(this);
125
126 //============
127
128 //loop on all active members
129// Int_t last;
130// if (first < 0) {first = 0; last = ninfo;}
131// else last = first+1;
132
133 // In order to speed up the case where the object being written is
134 // not in a collection (i.e. arrayMode is false), we actually
135 // duplicate the elementary types using this typeOffset.
136 static const int kHaveLoop = 1024;
137 const Int_t typeOffset = arrayMode ? kHaveLoop : 0;
138
139 for (Int_t i=first;i<last;i++) {
140
141 TStreamerElement *aElement = (TStreamerElement*)compinfo[i]->fElem;
142
143 if (needIncrement) b.SetStreamerElementNumber(aElement,compinfo[i]->fType);
144
145 Int_t ioffset = eoffset+compinfo[i]->fOffset;
146
147 if (R__TestUseCache<T>(aElement)) {
148 if (aElement->TestBit(TStreamerElement::kWrite)) {
149 if (((TBufferFile&)b).PeekDataCache()==0) {
150 Warning("WriteBuffer","Skipping %s::%s because the cache is missing.",GetName(),aElement->GetName());
151 } else {
152 if (gDebug > 1) {
153 printf("WriteBuffer, class:%s, name=%s, fType[%d]=%d,"
154 " %s, bufpos=%d, arr=%p, eoffset=%d, Redirect=%p\n",
155 fClass->GetName(),aElement->GetName(),i,compinfo[i]->fType,
156 aElement->ClassName(),b.Length(),arr[0], eoffset,((TBufferFile&)b).PeekDataCache()->GetObjectAt(0));
157 }
158 WriteBufferAux(b,*((TBufferFile&)b).PeekDataCache(),compinfo,i,i+1,narr,eoffset, arrayMode);
159 }
160 continue;
161 } else {
162 if (gDebug > 1) {
163 printf("WriteBuffer, class:%s, name=%s, fType[%d]=%d,"
164 " %s, bufpos=%d, arr=%p, eoffset=%d, not a write rule, skipping.\n",
165 fClass->GetName(),aElement->GetName(),i,compinfo[i]->fType,
166 aElement->ClassName(),b.Length(),arr[0], eoffset);
167 }
168 // The rule was a cached element for a read, rule, the real offset is in the
169 // next element (the one for the rule itself).
170 if (aElement->TestBit(TStreamerElement::kRepeat)) continue;
171 ioffset = eoffset+compinfo[i]->fOffset;
172 continue;
173 }
174 }
175
176 if (gDebug > 1) {
177 printf("WriteBuffer, class:%s, name=%s, fType[%d]=%d, %s, "
178 "bufpos=%d, arr=%p, offset=%d\n",
179 fClass->GetName(),aElement->GetName(),i,compinfo[i]->fType,aElement->ClassName(),
180 b.Length(),arr[0],ioffset);
181 }
182
183 switch (compinfo[i]->fType+typeOffset) {
184 // In this switch we intentionally use 'continue' instead of
185 // 'break' to avoid running the 2nd switch (see later in this
186 // function).
187
202 Float_t *x=(Float_t*)(arr[0]+ioffset);
203 b.WriteFloat16(x,aElement);
204 continue;
205 }
207 Double_t *x=(Double_t*)(arr[0]+ioffset);
208 b.WriteDouble32(x,aElement);
209 continue;
210 }
211
212 case TStreamerInfo::kBool + kHaveLoop: WriteBasicTypeLoop(Bool_t); continue;
213 case TStreamerInfo::kChar + kHaveLoop: WriteBasicTypeLoop(Char_t); continue;
214 case TStreamerInfo::kShort + kHaveLoop: WriteBasicTypeLoop(Short_t); continue;
215 case TStreamerInfo::kInt + kHaveLoop: WriteBasicTypeLoop(Int_t); continue;
216 case TStreamerInfo::kLong + kHaveLoop: WriteBasicTypeLoop(Long_t); continue;
217 case TStreamerInfo::kLong64 + kHaveLoop: WriteBasicTypeLoop(Long64_t); continue;
218 case TStreamerInfo::kFloat + kHaveLoop: WriteBasicTypeLoop(Float_t); continue;
219 case TStreamerInfo::kDouble + kHaveLoop: WriteBasicTypeLoop(Double_t); continue;
220 case TStreamerInfo::kUChar + kHaveLoop: WriteBasicTypeLoop(UChar_t); continue;
221 case TStreamerInfo::kUShort + kHaveLoop: WriteBasicTypeLoop(UShort_t); continue;
222 case TStreamerInfo::kUInt + kHaveLoop: WriteBasicTypeLoop(UInt_t); continue;
223 case TStreamerInfo::kULong + kHaveLoop: WriteBasicTypeLoop(ULong_t); continue;
224 case TStreamerInfo::kULong64 + kHaveLoop: WriteBasicTypeLoop(ULong64_t); continue;
225 case TStreamerInfo::kFloat16+ kHaveLoop: {
226 for(int k=0; k<narr; ++k) {
227 Float_t *x=(Float_t*)(arr[k]+ioffset);
228 b.WriteFloat16(x,aElement);
229 }
230 continue;
231 }
232 case TStreamerInfo::kDouble32+ kHaveLoop: {
233 for(int k=0; k<narr; ++k) {
234 Double_t *x=(Double_t*)(arr[k]+ioffset);
235 b.WriteDouble32(x,aElement);
236 }
237 continue;
238 }
239
240 // write array of basic types array[8]
255 b.WriteFastArrayFloat16((Float_t*)(arr[0]+ioffset),compinfo[i]->fLength,aElement);
256 continue;
257 }
259 b.WriteFastArrayDouble32((Double_t*)(arr[0]+ioffset),compinfo[i]->fLength,aElement);
260 continue;
261 }
262
277 for(int k=0; k<narr; ++k) {
278 b.WriteFastArrayFloat16((Float_t*)(arr[k]+ioffset),compinfo[i]->fLength,aElement);
279 }
280 continue;
281 }
283 for(int k=0; k<narr; ++k) {
284 b.WriteFastArrayDouble32((Double_t*)(arr[k]+ioffset),compinfo[i]->fLength,aElement);
285 }
286 continue;
287 }
288
289 // write pointer to an array of basic types array[n]
304 int imethod = compinfo[i]->fMethod+eoffset;
305 Int_t *l = (Int_t*)(arr[0]+imethod);
306 Float_t **f = (Float_t**)(arr[0]+ioffset);
307 Float_t *af = *f;
308 if (af && *l) b << Char_t(1);
309 else {b << Char_t(0); continue;}
310 int j;
311 for(j=0;j<compinfo[i]->fLength;j++) {
312 b.WriteFastArrayFloat16(f[j],*l,aElement);
313 }
314 continue;
315 }
317 int imethod = compinfo[i]->fMethod+eoffset;
318 Int_t *l = (Int_t*)(arr[0]+imethod);
319 Double_t **f = (Double_t**)(arr[0]+ioffset);
320 Double_t *af = *f;
321 if (af && *l) b << Char_t(1);
322 else {b << Char_t(0); continue;}
323 int j;
324 for(j=0;j<compinfo[i]->fLength;j++) {
325 b.WriteFastArrayDouble32(f[j],*l,aElement);
326 }
327 continue;
328 }
329
344 int imethod = compinfo[i]->fMethod+eoffset;
345 for(int k=0; k<narr; ++k) {
346 Int_t *l = (Int_t*)(arr[k]+imethod);
347 Float_t **f = (Float_t**)(arr[k]+ioffset);
348 Float_t *af = *f;
349 if (af && *l) b << Char_t(1);
350 else {b << Char_t(0); continue;}
351 int j;
352 for(j=0;j<compinfo[i]->fLength;j++) {
353 b.WriteFastArrayFloat16(f[j],*l,aElement);
354 }
355 }
356 continue;
357 }
359 int imethod = compinfo[i]->fMethod+eoffset;
360 for(int k=0; k<narr; ++k) {
361 Int_t *l = (Int_t*)(arr[k]+imethod);
362 Double_t **f = (Double_t**)(arr[k]+ioffset);
363 Double_t *af = *f;
364 if (af && *l) b << Char_t(1);
365 else {b << Char_t(0); continue;}
366 int j;
367 for(j=0;j<compinfo[i]->fLength;j++) {
368 b.WriteFastArrayDouble32(f[j],*l,aElement);
369 }
370 }
371 continue;
372 }
373
375 Int_t *x=(Int_t*)(arr[0]+ioffset);
376 b << *x;
377 if (i == last-1) {
378 if (needIncrement) b.DecrementLevel(this);
379 return x[0]; // info used by TBranchElement::FillLeaves
380 }
381 continue;
382 }
383
384 case TStreamerInfo::kCounter + kHaveLoop : {
385 DOLOOP {
386 Int_t *x=(Int_t*)(arr[k]+ioffset);
387 b << x[0];
388 }
389 continue;
390 }
391
392
393 };
394 Bool_t isPreAlloc = 0;
395
396 switch (compinfo[i]->fType) {
397
398 // char*
400 char **f = (char**)(arr[k]+ioffset);
401 b.WriteCharStar(*f);
402 }
403 continue; }
404
405 // special case for TObject::fBits in case of a referenced object
407 UInt_t *x=(UInt_t*)(arr[k]+ioffset); b << *x;
408 if ((*x & kIsReferenced) != 0) {
409 TObject *obj = (TObject*)(arr[k]+eoffset);
412 if(table) table->Add(obj->GetUniqueID(),pid);
413 UShort_t pidf = b.WriteProcessID(pid);
414 b << pidf;
415 }
416 }
417 continue; }
418
419 // Special case for TString, TObject, TNamed
420 case TStreamerInfo::kTString: { DOLOOP{ ((TString*)(arr[k]+ioffset))->Streamer(b); }; continue; }
421 case TStreamerInfo::kTObject: { DOLOOP{ ((TObject*)(arr[k]+ioffset))->TObject::Streamer(b);}; continue; }
422 case TStreamerInfo::kTNamed: { DOLOOP{ ((TNamed *)(arr[k]+ioffset))->TNamed::Streamer(b); }; continue; }
423
424 case TStreamerInfo::kAnyp: // Class* Class not derived from TObject and with comment field //->
426
427 case TStreamerInfo::kObjectp: // Class * Class derived from TObject and with comment field //->
429
430 isPreAlloc = kTRUE;
431
432 // Intentional fallthrough now that isPreAlloc is set.
433 case TStreamerInfo::kAnyP: // Class* Class not derived from TObject and no comment
435
436 case TStreamerInfo::kObjectP: // Class* Class derived from TObject
438 TClass *cl = compinfo[i]->fClass;
439 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
440 DOLOOP {
441 Int_t res = b.WriteFastArray((void**)(arr[k]+ioffset),cl,compinfo[i]->fLength,isPreAlloc,pstreamer);
442 if (res==2) {
443 Warning("WriteBuffer",
444 "The actual class of %s::%s is not available. Only the \"%s\" part will be written\n",
445 GetName(),aElement->GetName(),cl->GetName());
446 }
447 }
448 continue;
449 }
450
451 case TStreamerInfo::kAnyPnoVT: // Class* Class not derived from TObject and no virtual table and no comment
453 TClass *cl = compinfo[i]->fClass;
454 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
455 DOLOOP {
456 void **f = (void**)(arr[k]+ioffset);
457 int j;
458 for(j=0;j<compinfo[i]->fLength;j++) {
459 void *af = f[j];
460 if (af) b << Char_t(1);
461 else {b << Char_t(0); continue;}
462 if (pstreamer) (*pstreamer)(b, af, 0);
463 else cl->Streamer( af, b );
464 }
465 }
466 continue;
467 }
468
469// case TStreamerInfo::kSTLvarp: // Variable size array of STL containers.
470// {
471// TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
472// TClass *cl = compinfo[i]->fClass;
473// UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
474// if (pstreamer == 0) {
475// Int_t size = cl->Size();
476// Int_t imethod = compinfo[i]->fMethod+eoffset;
477// DOLOOP {
478// char **contp = (char**)(arr[k]+ioffset);
479// const Int_t *counter = (Int_t*)(arr[k]+imethod);
480// const Int_t sublen = (*counter);
481
482// for(int j=0;j<compinfo[i]->fLength;++j) {
483// char *cont = contp[j];
484// for(int k=0;k<sublen;++k) {
485// cl->Streamer( cont, b );
486// cont += size;
487// }
488// }
489// }
490// } else {
491// DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
492// }
493// b.SetByteCount(pos,kTRUE);
494// }
495// continue;
496
497
498 case TStreamerInfo::kSTLp: // Pointer to container with no virtual table (stl) and no comment
499 case TStreamerInfo::kSTLp + TStreamerInfo::kOffsetL: // array of pointers to container with no virtual table (stl) and no comment
500 {
501 TClass *cl = compinfo[i]->fClass;
502 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
504 TClass* vClass = proxy ? proxy->GetValueClass() : 0;
505
507 && proxy && vClass
509 && cl->CanSplit()
510 && !(strspn(aElement->GetTitle(),"||") == 2)
512 // Let's save the collection member-wise.
513
514 UInt_t pos = b.WriteVersionMemberWise(this->IsA(),kTRUE);
515 b.WriteVersion( vClass, kFALSE );
516 TStreamerInfo *subinfo = (TStreamerInfo*)vClass->GetStreamerInfo();
517 DOLOOP {
518 char **contp = (char**)(arr[k]+ioffset);
519 for(int j=0;j<compinfo[i]->fLength;++j) {
520 char *cont = contp[j];
521 TVirtualCollectionProxy::TPushPop helper( proxy, cont );
522 Int_t nobjects = cont ? proxy->Size() : 0;
523 b << nobjects;
524 subinfo->WriteBufferSTL(b,proxy,nobjects);
525 }
526 }
527 b.SetByteCount(pos,kTRUE);
528 continue;
529 }
530 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
531 if (pstreamer == 0) {
532 DOLOOP {
533 char **contp = (char**)(arr[k]+ioffset);
534 for(int j=0;j<compinfo[i]->fLength;++j) {
535 char *cont = contp[j];
536 cl->Streamer( cont, b );
537 }
538 }
539 } else {
540 DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
541 }
542 b.SetByteCount(pos,kTRUE);
543 }
544 continue;
545
546 case TStreamerInfo::kSTL: // container with no virtual table (stl) and no comment
547 case TStreamerInfo::kSTL + TStreamerInfo::kOffsetL: // array of containers with no virtual table (stl) and no comment
548 {
549 TClass *cl = compinfo[i]->fClass;
550 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
552 TClass* vClass = proxy ? proxy->GetValueClass() : 0;
554 && proxy && vClass
555 && GetStreamMemberWise() && cl->CanSplit()
556 && !(strspn(aElement->GetTitle(),"||") == 2)
558 // Let's save the collection in member-wise order.
559
560 UInt_t pos = b.WriteVersionMemberWise(this->IsA(),kTRUE);
561 b.WriteVersion( vClass, kFALSE );
562 TStreamerInfo *subinfo = (TStreamerInfo*)vClass->GetStreamerInfo();
563 DOLOOP {
564 char *obj = (char*)(arr[k]+ioffset);
565 Int_t n = compinfo[i]->fLength;
566 if (!n) n=1;
567 int size = cl->Size();
568
569 for(Int_t j=0; j<n; j++,obj+=size) {
570 TVirtualCollectionProxy::TPushPop helper( proxy, obj );
571 Int_t nobjects = proxy->Size();
572 b << nobjects;
573 subinfo->WriteBufferSTL(b,proxy,nobjects);
574 }
575 }
576 b.SetByteCount(pos,kTRUE);
577 continue;
578 }
579 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
580 if (pstreamer == 0) {
581 DOLOOP {
582 b.WriteFastArray((void*)(arr[k]+ioffset),cl,compinfo[i]->fLength,0);
583 }
584 } else {
585 DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
586 }
587 b.SetByteCount(pos,kTRUE);
588
589 continue;
590 }
591
592 case TStreamerInfo::kObject: // Class derived from TObject
593 case TStreamerInfo::kAny: // Class NOT derived from TObject
596 TClass *cl = compinfo[i]->fClass;
597 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
598 DOLOOP
599 {b.WriteFastArray((void*)(arr[k]+ioffset),cl,compinfo[i]->fLength,pstreamer);}
600 continue;
601 }
602
606 {
607 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
608 TClass *cl = compinfo[i]->fClass;
609
610 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
611 DOLOOP {b.WriteFastArray((void*)(arr[k]+ioffset),cl,compinfo[i]->fLength,pstreamer);}
612 b.SetByteCount(pos,kTRUE);
613 continue;
614 }
615
616 // Base Class
618 if (!(arrayMode&1)) {
619 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
620 if(pstreamer) {
621 // See kStreamer case (similar code)
622 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
623 DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
624 b.SetByteCount(pos,kTRUE);
625 } else {
626 DOLOOP { ((TStreamerBase*)aElement)->WriteBuffer(b,arr[k]);}
627 }
628 } else {
629 TClass *cl = compinfo[i]->fClass;
631 binfo->WriteBufferAux(b,arr,binfo->fCompFull,0,binfo->fNfulldata,narr,ioffset,arrayMode);
632 }
633 continue;
634
636 {
637 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
638
639 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
640 if (pstreamer == 0) {
641 printf("ERROR, Streamer is null\n");
642 aElement->ls();continue;
643 } else {
644 DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
645 }
646 b.SetByteCount(pos,kTRUE);
647 }
648 continue;
649
651 // -- A pointer to a varying-length array of objects.
652 // MyClass* ary; //[n]
653 // -- Or a pointer to a varying-length array of pointers to objects.
654 // MyClass** ary; //[n]
656 // -- An array of pointers to a varying-length array of objects.
657 // MyClass* ary[d]; //[n]
658 // -- Or an array of pointers to a varying-length array of pointers to objects.
659 // MyClass** ary[d]; //[n]
660 {
661 // Get the class of the data member.
662 TClass* cl = compinfo[i]->fClass;
663 // Get any private streamer which was set for the data member.
664 TMemberStreamer* pstreamer = compinfo[i]->fStreamer;
665 // Which are we, an array of objects or an array of pointers to objects?
666 Bool_t isPtrPtr = (strstr(aElement->GetTypeName(), "**") != 0);
667 if (pstreamer) {
668 // -- We have a private streamer.
669 UInt_t pos = b.WriteVersion(this->IsA(), kTRUE);
670 // Loop over the entries in the clones array or the STL container.
671 for (int k = 0; k < narr; ++k) {
672 // Get a pointer to the counter for the varying length array.
673 Int_t* counter = (Int_t*) (arr[k] /*entry pointer*/ + eoffset /*entry offset*/ + compinfo[i]->fMethod /*counter offset*/);
674 // And call the private streamer, passing it the buffer, the object, and the counter.
675 (*pstreamer)(b, arr[k] /*entry pointer*/ + ioffset /*object offset*/, *counter);
676 }
677 b.SetByteCount(pos, kTRUE);
678 // We are done, next streamer element.
679 continue;
680 }
681 // At this point we do *not* have a private streamer.
682 // Get the version of the file we are writing to.
683 TFile* file = (TFile*) b.GetParent();
684 // By default assume the file version is the newest.
685 Int_t fileVersion = kMaxInt;
686 if (file) {
687 fileVersion = file->GetVersion();
688 }
689 // Write the class version to the buffer.
690 UInt_t pos = b.WriteVersion(this->IsA(), kTRUE);
691 if (fileVersion > 51508) {
692 // -- Newer versions allow polymorphic pointers to objects.
693 // Loop over the entries in the clones array or the STL container.
694 for (int k = 0; k < narr; ++k) {
695 // Get the counter for the varying length array.
696 Int_t vlen = *((Int_t*) (arr[k] /*entry pointer*/ + eoffset /*entry offset*/ + compinfo[i]->fMethod /*counter offset*/));
697 //b << vlen;
698 if (vlen) {
699 // Get a pointer to the array of pointers.
700 char** pp = (char**) (arr[k] /*entry pointer*/ + ioffset /*object offset*/);
701 // Loop over each element of the array of pointers to varying-length arrays.
702 for (Int_t ndx = 0; ndx < compinfo[i]->fLength; ++ndx) {
703 if (!pp[ndx]) {
704 // -- We do not have a pointer to a varying-length array.
705 Error("WriteBufferAux", "The pointer to element %s::%s type %d (%s) is null\n", GetName(), aElement->GetFullName(), compinfo[i]->fType, aElement->GetTypeName());
706 continue;
707 }
708 if (!isPtrPtr) {
709 // -- We are a varying-length array of objects.
710 // Write the entire array of objects to the buffer.
711 // Note: Polymorphism is not allowed here.
712 b.WriteFastArray(pp[ndx], cl, vlen, 0);
713 }
714 else {
715 // -- We are a varying-length array of pointers to objects.
716 // Write the entire array of object pointers to the buffer.
717 // Note: The object pointers are allowed to be polymorphic.
718 b.WriteFastArray((void**) pp[ndx], cl, vlen, kFALSE, 0);
719 } // isPtrPtr
720 } // ndx
721 } // vlen
722 } // k
723 }
724 else {
725 // -- Older versions do *not* allow polymorphic pointers to objects.
726 // Loop over the entries in the clones array or the STL container.
727 for (int k = 0; k < narr; ++k) {
728 // Get the counter for the varying length array.
729 Int_t vlen = *((Int_t*) (arr[k] /*entry pointer*/ + eoffset /*entry offset*/ + compinfo[i]->fMethod /*counter offset*/));
730 //b << vlen;
731 if (vlen) {
732 // Get a pointer to the array of pointers.
733 char** pp = (char**) (arr[k] /*entry pointer*/ + ioffset /*object offset*/);
734 // -- Older versions do *not* allow polymorphic pointers to objects.
735 // Loop over each element of the array of pointers to varying-length arrays.
736 for (Int_t ndx = 0; ndx < compinfo[i]->fLength; ++ndx) {
737 if (!pp[ndx]) {
738 // -- We do not have a pointer to a varying-length array.
739 Error("WriteBufferAux", "The pointer to element %s::%s type %d (%s) is null\n", GetName(), aElement->GetFullName(), compinfo[i]->fType, aElement->GetTypeName());
740 continue;
741 }
742 if (!isPtrPtr) {
743 // -- We are a varying-length array of objects.
744 // Loop over the elements of the varying length array.
745 for (Int_t v = 0; v < vlen; ++v) {
746 // Write the object to the buffer.
747 cl->Streamer(pp[ndx] + (v * cl->Size()), b);
748 } // v
749 }
750 else {
751 // -- We are a varying-length array of pointers to objects.
752 // Loop over the elements of the varying length array.
753 for (Int_t v = 0; v < vlen; ++v) {
754 // Get a pointer to the object pointer.
755 char** r = (char**) pp[ndx];
756 // Write the object to the buffer.
757 cl->Streamer(r[v], b);
758 } // v
759 } // isPtrPtr
760 } // ndx
761 } // vlen
762 } // k
763 } // fileVersion
764 // Backpatch the byte count into the buffer.
765 b.SetByteCount(pos, kTRUE);
766 continue;
767 }
768
770 ((TBufferFile&)b).PushDataCache( new TVirtualArray( aElement->GetClassPointer(), narr ) );
771 continue;
773 delete ((TBufferFile&)b).PopDataCache();
774 continue;
776#if 0
777 ROOT::TSchemaRule::WriteFuncPtr_t writefunc = ((TStreamerArtificial*)aElement)->GetWriteFunc();
778 if (writefunc) {
779 DOLOOP( writefunc(arr[k]+eoffset, b) );
780 }
781#endif
782 continue;
783 case -1:
784 // -- Skip an ignored TObject base class.
785 continue;
786 default:
787 Error("WriteBuffer","The element %s::%s type %d (%s) is not supported yet\n",GetName(),aElement->GetFullName(),compinfo[i]->fType,aElement->GetTypeName());
788 continue;
789 }
790 }
791
792 if (needIncrement) b.DecrementLevel(this);
793
794 return 0;
795}
796
797template Int_t TStreamerInfo::WriteBufferAux<char**>(TBuffer &b, char ** const &arr, TCompInfo *const*const compinfo, Int_t first, Int_t last, Int_t narr,Int_t eoffset,Int_t mode);
798
799////////////////////////////////////////////////////////////////////////////////
800/// Write for STL container. ('first' is an id between -1 and fNfulldata).
801
803{
804 if (!nc) return 0;
805 R__ASSERT((unsigned int)nc==cont->Size());
806
807
808 int ret = WriteBufferAux(b,*cont,fCompFull,0,fNfulldata,nc,/* eoffset = */ 0,1);
809 return ret;
810}
811
812////////////////////////////////////////////////////////////////////////////////
813/// Write for STL container. ('first' is an id between -1 and fNfulldata).
814/// Note: This is no longer used.
815
817{
818 if (!nc) return 0;
819 R__ASSERT((unsigned int)nc==cont->Size());
820 int ret = WriteBufferAux(b, TPointerCollectionAdapter(cont),fCompFull,first==-1?0:first,first==-1?fNfulldata:first+1,nc,eoffset,1);
821 return ret;
822}
823
824
825////////////////////////////////////////////////////////////////////////////////
826/// General Write. ('first' is an id between -1 and fNdata).
827/// Note: This is no longer used.
828
830{
831 return WriteBufferAux(b,&ipointer,fCompOpt,first==-1?0:first,first==-1?fNdata:first+1,1,0,0);
832}
833
834////////////////////////////////////////////////////////////////////////////////
835/// Write for ClonesArray ('first' is an id between -1 and fNfulldata).
836/// Note: This is no longer used.
837
839 Int_t nc, Int_t first, Int_t eoffset)
840{
841 char **arr = reinterpret_cast<char**>(clones->GetObjectRef(0));
842 return WriteBufferAux(b,arr,fCompFull,first==-1?0:first,first==-1?fNfulldata:first+1,nc,eoffset,1);
843}
844
845
SVector< double, 2 > v
Definition: Dict.h:5
PyObject * fType
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
unsigned short UShort_t
Definition: RtypesCore.h:36
int Int_t
Definition: RtypesCore.h:41
const Int_t kMaxInt
Definition: RtypesCore.h:99
unsigned char UChar_t
Definition: RtypesCore.h:34
char Char_t
Definition: RtypesCore.h:29
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
unsigned long ULong_t
Definition: RtypesCore.h:51
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
short Short_t
Definition: RtypesCore.h:35
double Double_t
Definition: RtypesCore.h:55
long long Long64_t
Definition: RtypesCore.h:69
unsigned long long ULong64_t
Definition: RtypesCore.h:70
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
R__EXTERN Int_t gDebug
Definition: Rtypes.h:90
#define R__ASSERT(e)
Definition: TError.h:96
#define WriteBasicArray(name)
#define WriteBasicPointer(name)
#define WriteBasicPointerLoop(name)
#define WriteBasicArrayLoop(name)
#define WriteBasicTypeLoop(name)
#define WriteBasicType(name)
#define DOLOOP
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:46
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
@ kCannotHandleMemberWiseStreaming
Definition: TBuffer.h:73
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
Definition: TClass.cxx:4452
Bool_t CanSplit() const
Return true if the data member of this TClass can be saved separately.
Definition: TClass.cxx:2229
Int_t Size() const
Return size of object of this class.
Definition: TClass.cxx:5466
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Definition: TClass.cxx:2814
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=0) const
Definition: TClass.h:566
@ kHasCustomStreamerMember
Definition: TClass.h:99
An array of clone (identical) objects.
Definition: TClonesArray.h:32
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TObject ** GetObjectRef() const
Definition: TObjArray.h:68
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition: TObject.cxx:375
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
@ kIsReferenced
if object is referenced by a TRef or TRefArray
Definition: TObject.h:61
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:69
static TProcessID * GetProcessWithUID(const TObject *obj)
static function returning a pointer to TProcessID with its pid encoded in the highest byte of obj->Ge...
Definition: TProcessID.cxx:295
A TRefTable maintains the association between a referenced object and the parent object supporting th...
Definition: TRefTable.h:35
static TRefTable * GetRefTable()
Static function returning the current TRefTable.
Definition: TRefTable.cxx:287
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.
const char * GetTypeName() const
virtual void ls(Option_t *option="") const
Print the content of the element.
TClass * fClass
Not Owned.
Definition: TStreamerInfo.h:57
TMemberStreamer * fStreamer
Not Owned.
Definition: TStreamerInfo.h:60
Describe Streamer information for one class version.
Definition: TStreamerInfo.h:43
Int_t fNfulldata
!number of elements
Definition: TStreamerInfo.h:98
Int_t WriteBufferSTL(TBuffer &b, TVirtualCollectionProxy *cont, Int_t nc)
Write for STL container. ('first' is an id between -1 and fNfulldata).
TCompInfo ** fCompFull
![fElements->GetEntries()]
@ kArtificial
Cache the value in memory than is not part of the object but is accessible via a SchemaRule.
@ kUChar
Equal to TDataType's kchar.
Int_t fNdata
!number of optimized elements
Definition: TStreamerInfo.h:97
TClass * fClass
!pointer to class
TCompInfo ** fCompOpt
![fNdata]
Int_t WriteBuffer(TBuffer &b, char *pointer, Int_t first)
General Write.
Int_t WriteBufferClones(TBuffer &b, TClonesArray *clones, Int_t nc, Int_t first, Int_t eoffset)
Write for ClonesArray ('first' is an id between -1 and fNfulldata).
Int_t WriteBufferAux(TBuffer &b, const T &arr, TCompInfo *const *const compinfo, Int_t first, Int_t last, Int_t narr, Int_t eoffset, Int_t mode)
The object at pointer is serialized to the buffer b if (arrayMode & 1) ptr is a pointer to array of p...
Int_t WriteBufferSTLPtrs(TBuffer &b, TVirtualCollectionProxy *cont, Int_t nc, Int_t first, Int_t eoffset)
Write for STL container.
Basic string class.
Definition: TString.h:131
Wrapper around an object and giving indirect access to its content even if the object is not of a cla...
Definition: TVirtualArray.h:26
virtual TClass * GetValueClass() const =0
virtual UInt_t Size() const =0
static Bool_t GetStreamMemberWise()
Return whether the TStreamerInfos will save the collections in "member-wise" order whenever possible.
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
double T(double x)
Definition: ChebyshevPol.h:34
Definition: file.py:1
Definition: first.py:1
void table()
Definition: table.C:85
auto * l
Definition: textangle.C:4