Logo ROOT  
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 DOLOOP {
517 char **contp = (char**)(arr[k]+ioffset);
518 for(int j=0;j<compinfo[i]->fLength;++j) {
519 char *cont = contp[j];
520 TVirtualCollectionProxy::TPushPop helper( proxy, cont );
521 Int_t nobjects = cont ? proxy->Size() : 0;
522 b << nobjects;
523 if (nobjects) {
524 auto actions = proxy->GetWriteMemberWiseActions();
525
528 void *begin = &(startbuf[0]);
529 void *end = &(endbuf[0]);
530 proxy->GetFunctionCreateIterators()(cont, &begin, &end, proxy);
531 // We can not get here with a split vector of pointer, so we can indeed assume
532 // that actions->fConfiguration != null.
533 b.ApplySequence(*actions, begin, end);
534 if (begin != &(startbuf[0])) {
535 // assert(end != endbuf);
536 proxy->GetFunctionDeleteTwoIterators()(begin,end);
537 }
538 }
539 }
540 }
541 b.SetByteCount(pos,kTRUE);
542 continue;
543 }
544 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
545 if (pstreamer == 0) {
546 DOLOOP {
547 char **contp = (char**)(arr[k]+ioffset);
548 for(int j=0;j<compinfo[i]->fLength;++j) {
549 char *cont = contp[j];
550 cl->Streamer( cont, b );
551 }
552 }
553 } else {
554 DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
555 }
556 b.SetByteCount(pos,kTRUE);
557 }
558 continue;
559
560 case TStreamerInfo::kSTL: // container with no virtual table (stl) and no comment
561 case TStreamerInfo::kSTL + TStreamerInfo::kOffsetL: // array of containers with no virtual table (stl) and no comment
562 {
563 TClass *cl = compinfo[i]->fClass;
564 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
566 TClass* vClass = proxy ? proxy->GetValueClass() : 0;
568 && proxy && vClass
569 && GetStreamMemberWise() && cl->CanSplit()
570 && !(strspn(aElement->GetTitle(),"||") == 2)
572 // Let's save the collection in member-wise order.
573
574 UInt_t pos = b.WriteVersionMemberWise(this->IsA(),kTRUE);
575 b.WriteVersion( vClass, kFALSE );
576 DOLOOP {
577 char *obj = (char*)(arr[k]+ioffset);
578 Int_t n = compinfo[i]->fLength;
579 if (!n) n=1;
580 int size = cl->Size();
581
582 for(Int_t j=0; j<n; j++,obj+=size) {
583 TVirtualCollectionProxy::TPushPop helper( proxy, obj );
584 Int_t nobjects = proxy->Size();
585 b << nobjects;
586 if (nobjects) {
587 auto actions = proxy->GetWriteMemberWiseActions();
588
591 void *begin = &(startbuf[0]);
592 void *end = &(endbuf[0]);
593 proxy->GetFunctionCreateIterators()(obj, &begin, &end, proxy);
594 // We can not get here with a split vector of pointer, so we can indeed assume
595 // that actions->fConfiguration != null.
596 b.ApplySequence(*actions, begin, end);
597 if (begin != &(startbuf[0])) {
598 // assert(end != endbuf);
599 proxy->GetFunctionDeleteTwoIterators()(begin,end);
600 }
601 }
602 }
603 }
604 b.SetByteCount(pos,kTRUE);
605 continue;
606 }
607 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
608 if (pstreamer == 0) {
609 DOLOOP {
610 b.WriteFastArray((void*)(arr[k]+ioffset),cl,compinfo[i]->fLength,0);
611 }
612 } else {
613 DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
614 }
615 b.SetByteCount(pos,kTRUE);
616
617 continue;
618 }
619
620 case TStreamerInfo::kObject: // Class derived from TObject
621 case TStreamerInfo::kAny: // Class NOT derived from TObject
624 TClass *cl = compinfo[i]->fClass;
625 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
626 DOLOOP
627 {b.WriteFastArray((void*)(arr[k]+ioffset),cl,compinfo[i]->fLength,pstreamer);}
628 continue;
629 }
630
634 {
635 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
636 TClass *cl = compinfo[i]->fClass;
637
638 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
639 DOLOOP {b.WriteFastArray((void*)(arr[k]+ioffset),cl,compinfo[i]->fLength,pstreamer);}
640 b.SetByteCount(pos,kTRUE);
641 continue;
642 }
643
644 // Base Class
646 if (!(arrayMode&1)) {
647 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
648 if(pstreamer) {
649 // See kStreamer case (similar code)
650 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
651 DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
652 b.SetByteCount(pos,kTRUE);
653 } else {
654 DOLOOP { ((TStreamerBase*)aElement)->WriteBuffer(b,arr[k]);}
655 }
656 } else {
657 TClass *cl = compinfo[i]->fClass;
659 binfo->WriteBufferAux(b,arr,binfo->fCompFull,0,binfo->fNfulldata,narr,ioffset,arrayMode);
660 }
661 continue;
662
664 {
665 TMemberStreamer *pstreamer = compinfo[i]->fStreamer;
666
667 UInt_t pos = b.WriteVersion(this->IsA(),kTRUE);
668 if (pstreamer == 0) {
669 printf("ERROR, Streamer is null\n");
670 aElement->ls();continue;
671 } else {
672 DOLOOP{(*pstreamer)(b,arr[k]+ioffset,compinfo[i]->fLength);}
673 }
674 b.SetByteCount(pos,kTRUE);
675 }
676 continue;
677
679 // -- A pointer to a varying-length array of objects.
680 // MyClass* ary; //[n]
681 // -- Or a pointer to a varying-length array of pointers to objects.
682 // MyClass** ary; //[n]
684 // -- An array of pointers to a varying-length array of objects.
685 // MyClass* ary[d]; //[n]
686 // -- Or an array of pointers to a varying-length array of pointers to objects.
687 // MyClass** ary[d]; //[n]
688 {
689 // Get the class of the data member.
690 TClass* cl = compinfo[i]->fClass;
691 // Get any private streamer which was set for the data member.
692 TMemberStreamer* pstreamer = compinfo[i]->fStreamer;
693 // Which are we, an array of objects or an array of pointers to objects?
694 Bool_t isPtrPtr = (strstr(aElement->GetTypeName(), "**") != 0);
695 if (pstreamer) {
696 // -- We have a private streamer.
697 UInt_t pos = b.WriteVersion(this->IsA(), kTRUE);
698 // Loop over the entries in the clones array or the STL container.
699 for (int k = 0; k < narr; ++k) {
700 // Get a pointer to the counter for the varying length array.
701 Int_t* counter = (Int_t*) (arr[k] /*entry pointer*/ + eoffset /*entry offset*/ + compinfo[i]->fMethod /*counter offset*/);
702 // And call the private streamer, passing it the buffer, the object, and the counter.
703 (*pstreamer)(b, arr[k] /*entry pointer*/ + ioffset /*object offset*/, *counter);
704 }
705 b.SetByteCount(pos, kTRUE);
706 // We are done, next streamer element.
707 continue;
708 }
709 // At this point we do *not* have a private streamer.
710 // Get the version of the file we are writing to.
711 TFile* file = (TFile*) b.GetParent();
712 // By default assume the file version is the newest.
713 Int_t fileVersion = kMaxInt;
714 if (file) {
715 fileVersion = file->GetVersion();
716 }
717 // Write the class version to the buffer.
718 UInt_t pos = b.WriteVersion(this->IsA(), kTRUE);
719 if (fileVersion > 51508) {
720 // -- Newer versions allow polymorphic pointers to objects.
721 // Loop over the entries in the clones array or the STL container.
722 for (int k = 0; k < narr; ++k) {
723 // Get the counter for the varying length array.
724 Int_t vlen = *((Int_t*) (arr[k] /*entry pointer*/ + eoffset /*entry offset*/ + compinfo[i]->fMethod /*counter offset*/));
725 //b << vlen;
726 if (vlen) {
727 // Get a pointer to the array of pointers.
728 char** pp = (char**) (arr[k] /*entry pointer*/ + ioffset /*object offset*/);
729 // Loop over each element of the array of pointers to varying-length arrays.
730 for (Int_t ndx = 0; ndx < compinfo[i]->fLength; ++ndx) {
731 if (!pp[ndx]) {
732 // -- We do not have a pointer to a varying-length array.
733 Error("WriteBufferAux", "The pointer to element %s::%s type %d (%s) is null\n", GetName(), aElement->GetFullName(), compinfo[i]->fType, aElement->GetTypeName());
734 continue;
735 }
736 if (!isPtrPtr) {
737 // -- We are a varying-length array of objects.
738 // Write the entire array of objects to the buffer.
739 // Note: Polymorphism is not allowed here.
740 b.WriteFastArray(pp[ndx], cl, vlen, 0);
741 }
742 else {
743 // -- We are a varying-length array of pointers to objects.
744 // Write the entire array of object pointers to the buffer.
745 // Note: The object pointers are allowed to be polymorphic.
746 b.WriteFastArray((void**) pp[ndx], cl, vlen, kFALSE, 0);
747 } // isPtrPtr
748 } // ndx
749 } // vlen
750 } // k
751 }
752 else {
753 // -- Older versions do *not* allow polymorphic pointers to objects.
754 // Loop over the entries in the clones array or the STL container.
755 for (int k = 0; k < narr; ++k) {
756 // Get the counter for the varying length array.
757 Int_t vlen = *((Int_t*) (arr[k] /*entry pointer*/ + eoffset /*entry offset*/ + compinfo[i]->fMethod /*counter offset*/));
758 //b << vlen;
759 if (vlen) {
760 // Get a pointer to the array of pointers.
761 char** pp = (char**) (arr[k] /*entry pointer*/ + ioffset /*object offset*/);
762 // -- Older versions do *not* allow polymorphic pointers to objects.
763 // Loop over each element of the array of pointers to varying-length arrays.
764 for (Int_t ndx = 0; ndx < compinfo[i]->fLength; ++ndx) {
765 if (!pp[ndx]) {
766 // -- We do not have a pointer to a varying-length array.
767 Error("WriteBufferAux", "The pointer to element %s::%s type %d (%s) is null\n", GetName(), aElement->GetFullName(), compinfo[i]->fType, aElement->GetTypeName());
768 continue;
769 }
770 if (!isPtrPtr) {
771 // -- We are a varying-length array of objects.
772 // Loop over the elements of the varying length array.
773 for (Int_t v = 0; v < vlen; ++v) {
774 // Write the object to the buffer.
775 cl->Streamer(pp[ndx] + (v * cl->Size()), b);
776 } // v
777 }
778 else {
779 // -- We are a varying-length array of pointers to objects.
780 // Loop over the elements of the varying length array.
781 for (Int_t v = 0; v < vlen; ++v) {
782 // Get a pointer to the object pointer.
783 char** r = (char**) pp[ndx];
784 // Write the object to the buffer.
785 cl->Streamer(r[v], b);
786 } // v
787 } // isPtrPtr
788 } // ndx
789 } // vlen
790 } // k
791 } // fileVersion
792 // Backpatch the byte count into the buffer.
793 b.SetByteCount(pos, kTRUE);
794 continue;
795 }
796
798 ((TBufferFile&)b).PushDataCache( new TVirtualArray( aElement->GetClassPointer(), narr ) );
799 continue;
801 delete ((TBufferFile&)b).PopDataCache();
802 continue;
804#if 0
805 ROOT::TSchemaRule::WriteFuncPtr_t writefunc = ((TStreamerArtificial*)aElement)->GetWriteFunc();
806 if (writefunc) {
807 DOLOOP( writefunc(arr[k]+eoffset, b) );
808 }
809#endif
810 continue;
811 case -1:
812 // -- Skip an ignored TObject base class.
813 continue;
814 default:
815 Error("WriteBuffer","The element %s::%s type %d (%s) is not supported yet\n",GetName(),aElement->GetFullName(),compinfo[i]->fType,aElement->GetTypeName());
816 continue;
817 }
818 }
819
820 if (needIncrement) b.DecrementLevel(this);
821
822 return 0;
823}
824
825template 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);
826
827////////////////////////////////////////////////////////////////////////////////
828/// Write for STL container. ('first' is an id between -1 and fNfulldata).
829
831{
832 if (!nc) return 0;
833 R__ASSERT((unsigned int)nc==cont->Size());
834
835
836 int ret = WriteBufferAux(b,*cont,fCompFull,0,fNfulldata,nc,/* eoffset = */ 0,1);
837 return ret;
838}
839
840////////////////////////////////////////////////////////////////////////////////
841/// Write for STL container. ('first' is an id between -1 and fNfulldata).
842/// Note: This is no longer used.
843
845{
846 if (!nc) return 0;
847 R__ASSERT((unsigned int)nc==cont->Size());
848 int ret = WriteBufferAux(b, TPointerCollectionAdapter(cont),fCompFull,first==-1?0:first,first==-1?fNfulldata:first+1,nc,eoffset,1);
849 return ret;
850}
851
852
853////////////////////////////////////////////////////////////////////////////////
854/// General Write. ('first' is an id between -1 and fNdata).
855/// Note: This is no longer used.
856
858{
859 return WriteBufferAux(b,&ipointer,fCompOpt,first==-1?0:first,first==-1?fNdata:first+1,1,0,0);
860}
861
862////////////////////////////////////////////////////////////////////////////////
863/// Write for ClonesArray ('first' is an id between -1 and fNfulldata).
864/// Note: This is no longer used.
865
867 Int_t nc, Int_t first, Int_t eoffset)
868{
869 char **arr = reinterpret_cast<char**>(clones->GetObjectRef(0));
870 return WriteBufferAux(b,arr,fCompFull,first==-1?0:first,first==-1?fNfulldata:first+1,nc,eoffset,1);
871}
872
873
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:38
int Int_t
Definition: RtypesCore.h:43
const Int_t kMaxInt
Definition: RtypesCore.h:101
unsigned char UChar_t
Definition: RtypesCore.h:36
char Char_t
Definition: RtypesCore.h:31
const Bool_t kFALSE
Definition: RtypesCore.h:90
unsigned long ULong_t
Definition: RtypesCore.h:53
long Long_t
Definition: RtypesCore.h:52
bool Bool_t
Definition: RtypesCore.h:61
short Short_t
Definition: RtypesCore.h:37
double Double_t
Definition: RtypesCore.h:57
R__EXTERN Int_t gDebug
Definition: RtypesCore.h:117
long long Long64_t
Definition: RtypesCore.h:71
unsigned long long ULong64_t
Definition: RtypesCore.h:72
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
#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:42
@ kCannotHandleMemberWiseStreaming
Definition: TBuffer.h:75
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
Bool_t CanSplit() const
Return true if the data member of this TClass can be saved separately.
Definition: TClass.cxx:2300
Int_t Size() const
Return size of object of this class.
Definition: TClass.cxx:5667
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:4562
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Definition: TClass.cxx:2877
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=0) const
Definition: TClass.h:602
@ kHasCustomStreamerMember
Definition: TClass.h:105
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:53
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:69
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
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:877
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:891
@ 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 Int_t Add(Int_t uid, TProcessID *context=0)
Add a new uid to the table.
Definition: TRefTable.cxx:88
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:60
TMemberStreamer * fStreamer
Not Owned.
Definition: TStreamerInfo.h:63
Describe Streamer information for one class version.
Definition: TStreamerInfo.h:46
Int_t fNfulldata
!number of elements
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
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:27
virtual TStreamerInfoActions::TActionSequence * GetWriteMemberWiseActions()=0
virtual TClass * GetValueClass() const =0
virtual DeleteTwoIterators_t GetFunctionDeleteTwoIterators(Bool_t read=kTRUE)=0
virtual UInt_t Size() const =0
static const Int_t fgIteratorArenaSize
virtual CreateIterators_t GetFunctionCreateIterators(Bool_t read=kTRUE)=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
auto * l
Definition: textangle.C:4