Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TStreamerInfoActions.cxx
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Philippe Canal 05/2010
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 "TStreamerInfo.h"
14#include "TROOT.h"
15#include "TStreamerElement.h"
16#include "TVirtualMutex.h"
17#include "TInterpreter.h"
18#include "TError.h"
19#include "TVirtualArray.h"
20#include "TBufferFile.h"
21#include "TBufferText.h"
22#include "TMemberStreamer.h"
23#include "TClassEdit.h"
25#include "TProcessID.h"
26#include "TFile.h"
27
29
30// More possible optimizations:
31// Avoid call the virtual version of TBuffer::ReadInt and co.
32// Merge the Reading of the version and the looking up or the StreamerInfo
33// Avoid if (bytecnt) inside the CheckByteCount routines and avoid multiple (mostly useless nested calls)
34// Try to avoid if statement on onfile class being set (TBufferFile::ReadClassBuffer).
35
36using namespace TStreamerInfoActions;
37
39{
40 enum class EMode
41 {
42 kRead,
43 kWrite
44 };
45
47 {
48 const auto props = proxy.GetProperties();
49 const bool isVector = proxy.GetCollectionType() == ROOT::kSTLvector;
50 const bool hasDefaultAlloc = !(props & TVirtualCollectionProxy::kCustomAlloc);
51 const bool isEmulated = props & TVirtualCollectionProxy::kIsEmulated;
52
53 return isEmulated || (isVector && hasDefaultAlloc);
54 }
55
56 template <typename From>
58 typedef From Value_t;
59 };
60
61 template <typename From>
63 typedef From Value_t;
64 };
65
66 struct BitsMarker {
67 typedef UInt_t Value_t;
68 };
69
71 {
72 // Add the (potentially negative) delta to all the configuration's offset. This is used by
73 // TBranchElement in the case of split sub-object.
74
76 fOffset += delta;
77 }
78
80 {
81 // Add the (potentially negative) delta to all the configuration's offset. This is used by
82 // TBranchElement in the case of split sub-object.
83
85 }
86
87 void TConfiguredAction::PrintDebug(TBuffer &buf, void *addr) const
88 {
89 // Inform the user what we are about to stream.
90
91 // Idea, we should find a way to print the name of the function
93 }
94
96 {
97 // Inform the user what we are about to stream.
98
100 TStreamerElement *aElement = fCompInfo->fElem;
101 TString sequenceType;
102 aElement->GetSequenceType(sequenceType);
103
104 printf("StreamerInfoAction, class:%s, name=%s, fType[%d]=%d,"
105 " %s, offset=%d (%s), elemnId=%d \n",
106 info->GetClass()->GetName(), aElement->GetName(), fElemId, fCompInfo->fType,
107 aElement->ClassName(), fOffset, sequenceType.Data(), fElemId);
108 }
109
110 void TConfiguration::PrintDebug(TBuffer &buf, void *addr) const
111 {
112 // Inform the user what we are about to stream.
113
114 if (gDebug > 1) {
115 // Idea: We should print the name of the action function.
117 TStreamerElement *aElement = fCompInfo->fElem;
118 TString sequenceType;
119 aElement->GetSequenceType(sequenceType);
120
121 printf("StreamerInfoAction, class:%s, name=%s, fType[%d]=%d,"
122 " %s, bufpos=%d, arr=%p, offset=%d (%s)\n",
123 info->GetClass()->GetName(), aElement->GetName(), fElemId, fCompInfo->fType,
124 aElement->ClassName(), buf.Length(), addr, fOffset, sequenceType.Data());
125 }
126 }
127
129 {
130 // Inform the user what we are about to stream.
131
132 printf("TLoopConfiguration: unconfigured\n");
133 }
134
135
137 // Configuration of action using the legacy code.
138 // Mostly to cancel out the PrintDebug.
139 public:
141 void PrintDebug(TBuffer &, void *) const override {
142 // Since we call the old code, it will print the debug statement.
143 }
144
145 TConfiguration *Copy() override { return new TGenericConfiguration(*this); }
146 };
147
149 // Configuration of action handling kBits.
150 // In this case we need to know both the location
151 // of the member (fBits) and the start of the object
152 // (its TObject part to be exact).
153
154 Int_t fObjectOffset; // Offset of the TObject part within the object
155
157 void PrintDebug(TBuffer &, void *) const override
158 {
160 TStreamerElement *aElement = fCompInfo->fElem;
161 TString sequenceType;
162 aElement->GetSequenceType(sequenceType);
163
164 printf("StreamerInfoAction, class:%s, name=%s, fType[%d]=%d,"
165 " %s, offset=%d (%s)\n",
166 info->GetClass()->GetName(), aElement->GetName(), fElemId, fCompInfo->fType,
167 aElement->ClassName(), fOffset, sequenceType.Data());
168 }
169
170 void AddToOffset(Int_t delta) override
171 {
172 // Add the (potentially negative) delta to all the configuration's offset. This is used by
173 // TBranchElement in the case of split sub-object.
174
176 fOffset += delta;
177 fObjectOffset = 0;
178 }
179
180 void SetMissing() override
181 {
183 fObjectOffset = 0;
184 }
185
186 TConfiguration *Copy() override { return new TBitsConfiguration(*this); }
187
188 };
189
191 {
194
196 TClass *onfileClass, TClass *inMemoryClass) :
197 TConfiguration(info, id, compinfo, offset),
198 fOnfileClass(onfileClass),
199 fInMemoryClass(inMemoryClass ? inMemoryClass : onfileClass) {}
200 TConfiguration *Copy() override { return new TConfObject(*this); }
201 };
202
204 {
205 std::unique_ptr<TStreamerInfoActions::TActionSequence> fActions;
206
208 std::unique_ptr<TStreamerInfoActions::TActionSequence> actions) :
209 TConfiguration(info, id, compinfo, offset),
210 fActions(std::move(actions))
211 {}
212
216
217 void AddToOffset(Int_t delta) override
218 {
219 // Add the (potentially negative) delta to all the configuration's offset. This is used by
220 // TBranchElement in the case of split sub-object.
221
223 fOffset += delta;
224 if (fActions)
225 fActions->AddToOffset(delta);
226 }
227 }
228
229 TConfiguration *Copy() override { return new TConfSubSequence(*this); };
230 };
231
233 bool fIsPtrPtr = false; // Which are we, an array of objects or an array of pointers to objects?
234 Int_t fCounterOffset = 0; // Offset of the '//[n]' counter, relative to the streamed object.
235
237 : TConfiguration(info, id, compinfo, offset),
238 fIsPtrPtr(isPtrPtr),
239 fCounterOffset(static_cast<Int_t>(compinfo->fMethod))
240 {
241 }
242
243 void AddToOffset(Int_t delta) override
244 {
245 // Add the (potentially negative) delta to the configuration's offsets. This is used by
246 // TBranchElement in the case of a split sub-object and by the member-wise streaming of a
247 // base class, where the whole action sequence of the base is shifted by the base-class
248 // offset. fCounterOffset locates the '//[n]' counter inside the same object as fOffset,
249 // no matter if it's declared in that class or intherited from a base, so it takes the
250 // same shift. It is kept per configuration because fCompInfo->fMethod is shared by
251 // every sequence built from this streamerinfo and has to stay unshifted.
252
254 fOffset += delta;
256 fCounterOffset += delta;
257 }
258 }
259
260 TConfiguration *Copy() override { return new TConfStreamerLoop(*this); };
261 };
262
263 Int_t GenericReadAction(TBuffer &buf, void *addr, const TConfiguration *config)
264 {
265 char *obj = (char*)addr;
267 return ((TStreamerInfo*)conf->fInfo)->ReadBuffer(buf, &obj, &(conf->fCompInfo), /*first*/ 0, /*last*/ 1, /*narr*/ 1, config->fOffset, 2);
268 }
269
270 Int_t GenericWriteAction(TBuffer &buf, void *addr, const TConfiguration *config)
271 {
272 char *obj = (char*)addr;
274 return ((TStreamerInfo*)conf->fInfo)->WriteBufferAux(buf, &obj, &(conf->fCompInfo), /*first*/ 0, /*last*/ 1, /*narr*/ 1, config->fOffset, 2);
275 }
276
277 template <typename T>
278 inline Int_t ReadBasicType(TBuffer &buf, void *addr, const TConfiguration *config)
279 {
280 T *x = (T*)( ((char*)addr) + config->fOffset );
281 // Idea: Implement buf.ReadBasic/Primitive to avoid the return value
282 buf >> *x;
283 return 0;
284 }
285
286 void HandleReferencedTObject(TBuffer &buf, void *addr, const TConfiguration *config) {
287 TBitsConfiguration *conf = (TBitsConfiguration*)config;
288 UShort_t pidf;
289 buf >> pidf;
290 pidf += buf.GetPidOffset();
291 TProcessID *pid = buf.ReadProcessID(pidf);
292 if (pid!=0) {
293 TObject *obj = (TObject*)( ((char*)addr) + conf->fObjectOffset);
294 UInt_t gpid = pid->GetUniqueID();
295 UInt_t uid;
296 if (gpid>=0xff) {
297 uid = obj->GetUniqueID() | 0xff000000;
298 } else {
299 uid = ( obj->GetUniqueID() & 0xffffff) + (gpid<<24);
300 }
301 obj->SetUniqueID(uid);
302 pid->PutObjectWithID(obj);
303 }
304 }
305
306 inline Int_t ReadViaExtStreamer(TBuffer &buf, void *addr, const TConfiguration *config)
307 {
308 void *x = (void *)(((char *)addr) + config->fOffset);
309 TMemberStreamer *pstreamer = config->fCompInfo->fStreamer;
310 (*pstreamer)(buf, x, config->fCompInfo->fLength);
311 return 0;
312 }
313
314 inline Int_t WriteViaExtStreamer(TBuffer &buf, void *addr, const TConfiguration *config)
315 {
316 void *x = (void *)(((char *)addr) + config->fOffset);
317 TMemberStreamer *pstreamer = config->fCompInfo->fStreamer;
318 (*pstreamer)(buf, x, config->fCompInfo->fLength);
319 return 0;
320 }
321
322 Int_t ReadStreamerCase(TBuffer &buf, void *addr, const TConfiguration *config)
323 {
324 UInt_t start, count;
325 /* Version_t v = */ buf.ReadVersion(&start, &count, config->fInfo->IsA());
326
327 ReadViaExtStreamer(buf, addr, config);
328
329 buf.CheckByteCount(start, count, config->fCompInfo->fElem->GetFullName());
330 return 0;
331 }
332
333 Int_t WriteStreamerCase(TBuffer &buf, void *addr, const TConfiguration *config)
334 {
335 UInt_t pos = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
336
337 WriteViaExtStreamer(buf, addr, config);
338
339 buf.SetByteCount(pos, kTRUE);
340 return 0;
341 }
342
343 // Read a full object objectwise including reading the version and
344 // selecting any conversion.
345 Int_t ReadViaClassBuffer(TBuffer &buf, void *addr, const TConfiguration *config)
346 {
347 auto conf = (TConfObject*)config;
348 auto memoryClass = conf->fInMemoryClass;
349 auto onfileClass = conf->fOnfileClass;
350
351 char * const where = (((char*)addr)+config->fOffset);
352 buf.ReadClassBuffer( memoryClass, where, onfileClass );
353 return 0;
354 }
355
356 // Write a full object objectwise including reading the version and
357 // selecting any conversion.
358 Int_t WriteViaClassBuffer(TBuffer &buf, void *addr, const TConfiguration *config)
359 {
360 auto conf = (TConfObject*)config;
361 [[maybe_unused]] auto memoryClass = conf->fInMemoryClass;
362 auto onfileClass = conf->fOnfileClass;
363 assert((memoryClass == nullptr || memoryClass == onfileClass)
364 && "Need to new TBufferFile::WriteClassBuffer overload to support this case");
365
366 char * const where = (((char*)addr)+config->fOffset);
367 buf.WriteClassBuffer( onfileClass, where);
368 return 0;
369 }
370
371 template <>
372 inline Int_t ReadBasicType<BitsMarker>(TBuffer &buf, void *addr, const TConfiguration *config)
373 {
374 UInt_t *x = (UInt_t*)( ((char*)addr) + config->fOffset );
375 // Idea: Implement buf.ReadBasic/Primitive to avoid the return value
376 // Idea: This code really belongs inside TBuffer[File]
377 const UInt_t isonheap = *x & TObject::kIsOnHeap; // Record how this instance was actually allocated.
378 buf >> *x;
379 *x |= isonheap | TObject::kNotDeleted; // by definition de-serialized object are not yet deleted.
380
381 if ((*x & kIsReferenced) != 0) {
382 HandleReferencedTObject(buf,addr,config);
383 }
384 return 0;
385 }
386
387 template <typename T>
388 static inline Int_t WriteBasicZero(TBuffer &buf, void *, const TConfiguration *)
389 {
390 buf << T{0};
391 return 0;
392 }
393
394 template <typename T>
395 inline Int_t WriteBasicType(TBuffer &buf, void *addr, const TConfiguration *config)
396 {
397 T *x = (T *)(((char *)addr) + config->fOffset);
398 // Idea: Implement buf.ReadBasic/Primitive to avoid the return value
399 buf << *x;
400 return 0;
401 }
402
403 template <typename Onfile, typename Memory>
405 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
406 {
407 // Simple conversion from a 'From' on disk to a 'To' in memory.
408 Onfile temp;
409 temp = (Onfile)(*(Memory*)( ((char*)addr) + config->fOffset ));
410 buf << temp;
411 return 0;
412 }
413 };
414
415 inline Int_t WriteTextTNamed(TBuffer &buf, void *addr, const TConfiguration *config)
416 {
417 void *x = (void *)(((char *)addr) + config->fOffset);
418 // Idea: Implement buf.ReadBasic/Primitive to avoid the return value
420 return 0;
421 }
422
423 inline Int_t WriteTextTObject(TBuffer &buf, void *addr, const TConfiguration *config)
424 {
425 void *x = (void *)(((char *)addr) + config->fOffset);
426 // Idea: Implement buf.ReadBasic/Primitive to avoid the return value
428 return 0;
429 }
430
431 inline Int_t WriteTextBaseClass(TBuffer &buf, void *addr, const TConfiguration *config)
432 {
433 void *x = (void *)(((char *)addr) + config->fOffset);
434 // Idea: Implement buf.ReadBasic/Primitive to avoid the return value
435 ((TBufferText *)&buf)->WriteBaseClass(x, (TStreamerBase *)config->fCompInfo->fElem);
436 return 0;
437 }
438
439 inline Int_t ReadTextObject(TBuffer &buf, void *addr, const TConfiguration *config)
440 {
441 void *x = (void *)(((char *)addr) + config->fOffset);
442 buf.ReadFastArray(x, config->fCompInfo->fClass, config->fCompInfo->fLength, config->fCompInfo->fStreamer);
443 return 0;
444 }
445
446 inline Int_t ReadTextTObject(TBuffer &buf, void *addr, const TConfiguration *config)
447 {
448 void *x = (void *)(((char *)addr) + config->fOffset);
450 return 0;
451 }
452
453 inline Int_t ReadTextBaseClass(TBuffer &buf, void *addr, const TConfiguration *config)
454 {
455 void *x = (void *)(((char *)addr) + config->fOffset);
456 // Idea: Implement buf.ReadBasic/Primitive to avoid the return value
457 ((TBufferText *)&buf)->ReadBaseClass(x, (TStreamerBase *)config->fCompInfo->fElem);
458 return 0;
459 }
460
461 inline Int_t ReadTextTObjectBase(TBuffer &buf, void *addr, const TConfiguration *config)
462 {
463 // action required to call custom code for TObject as base class
464 void *x = (void *)(((char *)addr) + config->fOffset);
466 return 0;
467 }
468
469 inline Int_t ReadTextTNamed(TBuffer &buf, void *addr, const TConfiguration *config)
470 {
471 void *x = (void *)(((char *)addr) + config->fOffset);
473 return 0;
474 }
475
476 static inline void WriteCompressed(TBuffer &buf, float *addr, const TStreamerElement *elem)
477 {
478 buf.WriteFloat16(addr, const_cast<TStreamerElement*>(elem));
479 }
480
481 static inline void WriteCompressed(TBuffer &buf, double *addr, const TStreamerElement *elem)
482 {
483 buf.WriteDouble32(addr, const_cast<TStreamerElement*>(elem));
484 }
485
486 inline Int_t TextWriteSTLp(TBuffer &buf, void *addr, const TConfiguration *config)
487 {
488 TClass *cl = config->fCompInfo->fClass;
489 TMemberStreamer *pstreamer = config->fCompInfo->fStreamer;
490 UInt_t ioffset = config->fOffset;
491
492 UInt_t pos = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
493
494 // use same method which is used in kSTL
495 buf.WriteFastArray((void **)((char *)addr + ioffset), cl, config->fCompInfo->fLength, kFALSE, pstreamer);
496
497 buf.SetByteCount(pos, kTRUE);
498 return 0;
499 }
500
501 inline Int_t TextReadSTLp(TBuffer &buf, void *addr, const TConfiguration *config)
502 {
503 TClass *cle = config->fCompInfo->fClass;
504 TMemberStreamer *pstreamer = config->fCompInfo->fStreamer;
505 TStreamerElement *aElement = (TStreamerElement *)config->fCompInfo->fElem;
506 UInt_t ioffset = config->fOffset;
507 UInt_t start, count;
508 /* Version_t vers = */ buf.ReadVersion(&start, &count, cle);
509
510 // use same method which is used in kSTL
511 buf.ReadFastArray((void **)((char *)addr + ioffset), cle, config->fCompInfo->fLength, kFALSE, pstreamer);
512 buf.CheckByteCount(start, count, aElement->GetFullName());
513 return 0;
514 }
515
517 // Configuration object for the Float16/Double32 where a factor has been specified.
518 public:
522 TConfiguration *Copy() override { return new TConfWithFactor(*this); }
523 };
524
525 template <typename T>
526 inline Int_t ReadBasicType_WithFactor(TBuffer &buf, void *addr, const TConfiguration *config)
527 {
528 // Stream a Float16 or Double32 where a factor has been specified.
529 //a range was specified. We read an integer and convert it back to a double.
530
531 TConfWithFactor *conf = (TConfWithFactor *)config;
532 buf.ReadWithFactor((T*)( ((char*)addr) + config->fOffset ), conf->fFactor, conf->fXmin);
533 return 0;
534 }
535
537 // Configuration object for the Float16/Double32 where a factor has been specified.
538 public:
540 TConfNoFactor(TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, Int_t nbits) : TConfiguration(info,id,compinfo,offset),fNbits(nbits) {};
541 TConfiguration *Copy() override { return new TConfNoFactor(*this); }
542 };
543
544 template <typename T>
545 inline Int_t ReadBasicType_NoFactor(TBuffer &buf, void *addr, const TConfiguration *config)
546 {
547 // Stream a Float16 or Double32 where a factor has not been specified.
548
549 TConfNoFactor *conf = (TConfNoFactor *)config;
550 Int_t nbits = conf->fNbits;
551
552 buf.ReadWithNbits( (T*)( ((char*)addr) + config->fOffset ), nbits );
553 return 0;
554 }
555
556 inline Int_t ReadTString(TBuffer &buf, void *addr, const TConfiguration *config)
557 {
558 // Read in a TString object.
559
560 // Idea: We could separate the TString Streamer in its two parts and
561 // avoid the if (buf.IsReading()) and try having it inlined.
562 ((TString*)(((char*)addr)+config->fOffset))->TString::Streamer(buf);
563 return 0;
564 }
565
566 inline Int_t WriteTString(TBuffer &buf, void *addr, const TConfiguration *config)
567 {
568 // Read in a TString object.
569
570 // Idea: We could separate the TString Streamer in its two parts and
571 // avoid the if (buf.IsReading()) and try having it inlined.
572 ((TString*)(((char*)addr)+config->fOffset))->TString::Streamer(buf);
573 return 0;
574 }
575
576 inline Int_t ReadTObject(TBuffer &buf, void *addr, const TConfiguration *config)
577 {
578 // Read in a TObject object part.
579
580 // Idea: We could separate the TObject Streamer in its two parts and
581 // avoid the if (buf.IsReading()).
582 ((TObject*)(((char*)addr)+config->fOffset))->TObject::Streamer(buf);
583 return 0;
584 }
585
586 inline Int_t WriteTObject(TBuffer &buf, void *addr, const TConfiguration *config)
587 {
588 // Read in a TObject object part.
589
590 // Idea: We could separate the TObject Streamer in its two parts and
591 // avoid the if (buf.IsReading()).
592 ((TObject*)(((char*)addr)+config->fOffset))->TObject::Streamer(buf);
593 return 0;
594 }
595
596 inline Int_t ReadTNamed(TBuffer &buf, void *addr, const TConfiguration *config)
597 {
598 // Read in a TNamed object part.
599 // Since the TNamed streamer is solely delegating back to the StreamerInfo we
600 // can skip the streamer.
601
602 // Idea: We could extract the code from ReadClassBuffer and avoid one function
603 // code.
604 static const TClass *TNamed_cl = TNamed::Class();
605 return buf.ReadClassBuffer(TNamed_cl,(((char*)addr)+config->fOffset));
606 }
607
608 inline Int_t WriteTNamed(TBuffer &buf, void *addr, const TConfiguration *config)
609 {
610 // Read in a TNamed object part.
611 // Since the TNamed streamer is solely delegating back to the StreamerInfo we
612 // can skip the streamer.
613
614 // Idea: We could extract the code from ReadClassBuffer and avoid one function
615 // code.
616 static const TClass *TNamed_cl = TNamed::Class();
617 return buf.WriteClassBuffer(TNamed_cl,(((char*)addr)+config->fOffset));
618 }
619
620 class TConfigSTL : public TConfiguration {
621 // Configuration object for the kSTL case
622 private:
623 void Init(bool read) {
625 if (proxy) {
630 if (proxy->HasPointers()) {
632 } else {
633 fNext = proxy->GetFunctionNext(read);
634 }
635 }
636 }
637
638 public:
639 TClass *fOldClass; // Class of the content on file
640 TClass *fNewClass; // Class of the content in memory.
642 const char *fTypeName; // Type name of the member as typed by ther user.
643 Bool_t fIsSTLBase; // aElement->IsBase() && aElement->IsA()!=TStreamerBase::Class()
644
650
651
652 TConfigSTL(Bool_t read, TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, UInt_t length, TClass *oldClass, const char *type_name, Bool_t isbase) :
653 TConfiguration(info,id,compinfo,offset,length), fOldClass(oldClass), fNewClass(oldClass), fStreamer(0), fTypeName(type_name), fIsSTLBase(isbase),
655
656 TConfigSTL(Bool_t read, TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, UInt_t length, TClass *oldClass, TClass *newClass, const char *type_name, Bool_t isbase) :
657 TConfiguration(info,id,compinfo,offset,length), fOldClass(oldClass), fNewClass(newClass), fStreamer(0), fTypeName(type_name), fIsSTLBase(isbase),
659
660 TConfigSTL(Bool_t read, TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, UInt_t length, TClass *oldClass, TMemberStreamer* streamer, const char *type_name, Bool_t isbase) :
661 TConfiguration(info,id,compinfo,offset,length), fOldClass(oldClass), fNewClass(oldClass), fStreamer(streamer), fTypeName(type_name), fIsSTLBase(isbase),
663
664 TConfigSTL(Bool_t read, TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, UInt_t length, TClass *oldClass, TClass *newClass, TMemberStreamer* streamer, const char *type_name, Bool_t isbase) :
665 TConfiguration(info,id,compinfo,offset,length), fOldClass(oldClass), fNewClass(newClass), fStreamer(streamer), fTypeName(type_name), fIsSTLBase(isbase),
667
668 TConfiguration *Copy() override { return new TConfigSTL(*this); }
669 };
670
672 // Configuration object for the Float16/Double32 where a factor has been specified.
673 public:
677 TConfiguration *Copy() override { return new TConfSTLWithFactor(*this); }
678 };
679
681 // Configuration object for the Float16/Double32 where a factor has been specified.
682 public:
684 TConfSTLNoFactor(TConfigSTL *orig, Int_t nbits) : TConfigSTL(*orig),fNbits(nbits) {};
685 TConfiguration *Copy() override { return new TConfSTLNoFactor(*this); }
686 };
687
689 // Base class of the Configurations used in member wise streaming.
690 protected:
691 public:
692 Long_t fIncrement; // Either a value to increase the cursor by and
693 public:
694 TVectorLoopConfig(TVirtualCollectionProxy *proxy, Long_t increment, Bool_t /* read */) : TLoopConfiguration(proxy), fIncrement(increment) {};
695 //virtual void PrintDebug(TBuffer &buffer, void *);
696 ~TVectorLoopConfig() override {};
697 void Print() const override
698 {
699 printf("TVectorLoopConfig: increment=%ld\n",fIncrement);
700 }
701
702 void* GetFirstAddress(void *start, const void * /* end */) const override
703 {
704 // Return the address of the first element of the collection.
705
706 return start;
707 }
708
709 TLoopConfiguration* Copy() const override { return new TVectorLoopConfig(*this); }
710 };
711
713 // Base class of the Configurations used in member wise streaming.
714 public:
716 //virtual void PrintDebug(TBuffer &buffer, void *);
717 ~TAssocLoopConfig() override {};
718 void Print() const override
719 {
720 printf("TAssocLoopConfig: proxy=%s\n",fProxy->GetCollectionClass()->GetName());
721 }
722 TLoopConfiguration* Copy() const override { return new TAssocLoopConfig(*this); }
723
724 void* GetFirstAddress(void *start, const void * /* end */) const override
725 {
726 // Return the address of the first element of the collection.
727
728 R__ASSERT(0);
729// char iterator[TVirtualCollectionProxy::fgIteratorArenaSize];
730// void *iter = genloopconfig->fCopyIterator(&iterator,start_collection);
731// arr0 = genloopconfig->fNext(iter,end_collection);
732// if (iter != &iterator[0]) {
733// genloopconfig->fDeleteIterator(iter);
734// }
735 return start;
736 }
737 };
738
740 // Configuration object for the generic case of member wise streaming looping.
741 private:
755 public:
759
764 ~TGenericLoopConfig() override {};
765 void Print() const override
766 {
767 printf("TGenericLoopConfig: proxy=%s\n",fProxy->GetCollectionClass()->GetName());
768 }
769 TLoopConfiguration* Copy() const override { return new TGenericLoopConfig(*this); }
770
771 void* GetFirstAddress(void *start_collection, const void *end_collection) const override
772 {
773 // Return the address of the first element of the collection.
774
776 void *iter = fCopyIterator(&iterator,start_collection);
777 void *arr0 = fNext(iter,end_collection);
778 if (iter != &iterator[0]) {
779 fDeleteIterator(iter);
780 }
781 return arr0;
782 }
783 };
784
785 inline void ReadSTLMemberWiseSameClass(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers)
786 {
787 // Collection was saved member-wise
788
789 TConfigSTL *config = (TConfigSTL*)conf;
791
792 if( vers >= 8 ) {
793
794 TClass *oldClass = config->fOldClass;
795
796 TVirtualCollectionProxy *oldProxy = oldClass ? oldClass->GetCollectionProxy() : nullptr;
797 if (!oldProxy) {
798 // Missing information, broken file ... give up
799 return;
800 }
801 TClass *valueClass = oldProxy->GetValueClass();
802 Version_t vClVersion = buf.ReadVersionForMemberWise( valueClass );
803
804 TVirtualCollectionProxy::TPushPop helper( oldProxy, (char*)addr );
805 Int_t nobjects;
806 buf.ReadInt(nobjects);
807 void* alternative = oldProxy->Allocate(nobjects,true);
808 if (nobjects) {
809 TActionSequence *actions = oldProxy->GetReadMemberWiseActions( vClVersion );
810
813 void *begin = &(startbuf[0]);
814 void *end = &(endbuf[0]);
815 config->fCreateIterators(alternative, &begin, &end, oldProxy);
816 // We can not get here with a split vector of pointer, so we can indeed assume
817 // that actions->fConfiguration != null.
818 buf.ApplySequence(*actions, begin, end);
819 if (begin != &(startbuf[0])) {
820 // assert(end != endbuf);
821 config->fDeleteTwoIterators(begin,end);
822 }
823 }
824 oldProxy->Commit(alternative);
825
826 } else {
827
828 TClass *oldClass = config->fOldClass;
829
830 TVirtualCollectionProxy *oldProxy = oldClass ? oldClass->GetCollectionProxy() : nullptr;
831 if (!oldProxy) {
832 // Missing information, broken file ... give up
833 return;
834 }
835
836 TVirtualCollectionProxy::TPushPop helper( oldProxy, (char*)addr );
837 Int_t nobjects;
838 buf.ReadInt(nobjects);
839 void* env = oldProxy->Allocate(nobjects,true);
840
841 if (nobjects || vers < 7 ) {
842 // coverity[dereference] since this is a member streaming action by definition the collection contains objects.
843 TStreamerInfo *subinfo = (TStreamerInfo*)oldProxy->GetValueClass()->GetStreamerInfo( 0 );
844
845 subinfo->ReadBufferSTL(buf, oldProxy, nobjects, /* offset */ 0, /* v7 */ kFALSE);
846 }
847 oldProxy->Commit(env);
848 }
849 }
850
851 inline void ReadArraySTLMemberWiseSameClass(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers)
852 {
853 // Collection was saved member-wise
854
855 TConfigSTL *config = (TConfigSTL*)conf;
857
858 if( vers >= 8 ) {
859
860 TClass *oldClass = config->fOldClass;
861
862 TVirtualCollectionProxy *oldProxy = oldClass ? oldClass->GetCollectionProxy() : nullptr;
863 if (!oldProxy) {
864 // Missing information, broken file ... give up
865 return;
866 }
867 TClass *valueClass = oldProxy->GetValueClass();
868 Version_t vClVersion = buf.ReadVersionForMemberWise( valueClass );
869
870 TActionSequence *actions = oldProxy->GetReadMemberWiseActions( vClVersion );
871
872 int objectSize = oldClass->Size();
873 char *obj = (char*)addr;
874 char *endobj = obj + conf->fLength*objectSize;
875
876 for(; obj<endobj; obj+=objectSize) {
877 Int_t nobjects;
878 buf.ReadInt(nobjects);
879 TVirtualCollectionProxy::TPushPop helper( oldProxy, (char*)obj );
880 void* alternative = oldProxy->Allocate(nobjects,true);
881 if (nobjects) {
884 void *begin = &(startbuf[0]);
885 void *end = &(endbuf[0]);
886 config->fCreateIterators(alternative, &begin, &end, oldProxy);
887 // We can not get here with a split vector of pointer, so we can indeed assume
888 // that actions->fConfiguration != null.
889 buf.ApplySequence(*actions, begin, end);
890 if (begin != &(startbuf[0])) {
891 // assert(end != endbuf);
892 config->fDeleteTwoIterators(begin,end);
893 }
894 }
895 oldProxy->Commit(alternative);
896 }
897
898 } else {
899
900 TClass *oldClass = config->fOldClass;
901
902 TVirtualCollectionProxy *oldProxy = oldClass ? oldClass->GetCollectionProxy() : nullptr;
903 if (!oldProxy) {
904 // Missing information, broken file ... give up
905 return;
906 }
907
908 int objectSize = oldClass->Size();
909 char *obj = (char*)addr;
910 char *endobj = obj + conf->fLength*objectSize;
911
912 for(; obj<endobj; obj+=objectSize) {
913 TVirtualCollectionProxy::TPushPop helper( oldProxy, (char*)obj );
914 Int_t nobjects;
915 buf.ReadInt(nobjects);
916 void* env = oldProxy->Allocate(nobjects,true);
917
918 if (nobjects || vers < 7 ) {
919 // coverity[dereference] since this is a member streaming action by definition the collection contains objects.
920 TStreamerInfo *subinfo = (TStreamerInfo*)oldProxy->GetValueClass()->GetStreamerInfo( 0 );
921
922 subinfo->ReadBufferSTL(buf, oldProxy, nobjects, /* offset */ 0, /* v7 */ kFALSE);
923 }
924 oldProxy->Commit(env);
925 }
926 }
927 }
928
929 inline void ReadSTLMemberWiseChangedClass(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers)
930 {
931 // Collection was saved member-wise
932
933 TConfigSTL *config = (TConfigSTL*)conf;
934
936
937 TClass *newClass = config->fNewClass;
938 TClass *oldClass = config->fOldClass;
939
940 if( vers < 8 ) {
941 Error( "ReadSTLMemberWiseChangedClass", "Unfortunately, version %d of TStreamerInfo (used in %s) did not record enough information to convert a %s into a %s.",
942 vers, buf.GetParent() ? buf.GetParent()->GetName() : "memory/socket", oldClass ? oldClass->GetName() : "(could not find the origin TClass)", newClass ? newClass->GetName() : "(could not find the destination TClass)" );
943 } else if (newClass && oldClass){
944
945 Version_t vClVersion = buf.ReadVersionForMemberWise( oldClass->GetCollectionProxy()->GetValueClass() );
946
947 TVirtualCollectionProxy *newProxy = newClass->GetCollectionProxy();
948 TVirtualCollectionProxy *oldProxy = oldClass->GetCollectionProxy();
949
950 TVirtualCollectionProxy::TPushPop helper( newProxy, (char*)addr );
951 Int_t nobjects;
952 buf.ReadInt(nobjects);
953 void* alternative = newProxy->Allocate(nobjects,true);
954 if (nobjects) {
955 TActionSequence *actions = newProxy->GetConversionReadMemberWiseActions( oldProxy->GetValueClass(), vClVersion );
958 void *begin = &(startbuf[0]);
959 void *end = &(endbuf[0]);
960 config->fCreateIterators( alternative, &begin, &end, newProxy);
961 // We can not get here with a split vector of pointer, so we can indeed assume
962 // that actions->fConfiguration != null.
963 buf.ApplySequence(*actions, begin, end);
964 if (begin != &(startbuf[0])) {
965 // assert(end != endbuf);
966 config->fDeleteTwoIterators(begin,end);
967 }
968 }
969 newProxy->Commit(alternative);
970 }
971 }
972
973 inline void ReadArraySTLMemberWiseChangedClass(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers)
974 {
975 // Collection was saved member-wise
976
977 TConfigSTL *config = (TConfigSTL*)conf;
978
980
981 TClass *newClass = config->fNewClass;
982 TClass *oldClass = config->fOldClass;
983
984 if( vers < 8 ) {
985 Error( "ReadSTLMemberWiseChangedClass", "Unfortunately, version %d of TStreamerInfo (used in %s) did not record enough information to convert a %s into a %s.",
986 vers, buf.GetParent() ? buf.GetParent()->GetName() : "memory/socket", oldClass ? oldClass->GetName() : "(could not find the origin TClass)", newClass ? newClass->GetName() : "(could not find the destination TClass)" );
987 } else if (newClass && oldClass) {
988
989 Version_t vClVersion = buf.ReadVersionForMemberWise( oldClass->GetCollectionProxy()->GetValueClass() );
990
991 TVirtualCollectionProxy *newProxy = newClass->GetCollectionProxy();
992 TVirtualCollectionProxy *oldProxy = oldClass->GetCollectionProxy();
993
994 int objectSize = newClass->Size();
995 char *obj = (char*)addr;
996 char *endobj = obj + conf->fLength*objectSize;
997
998 for(; obj<endobj; obj+=objectSize) {
999 TVirtualCollectionProxy::TPushPop helper( newProxy, (char*)obj );
1000 Int_t nobjects;
1001 buf.ReadInt(nobjects);
1002 void* alternative = newProxy->Allocate(nobjects,true);
1003 if (nobjects) {
1004 TActionSequence *actions = newProxy->GetConversionReadMemberWiseActions( oldProxy->GetValueClass(), vClVersion );
1007 void *begin = &(startbuf[0]);
1008 void *end = &(endbuf[0]);
1009 config->fCreateIterators( alternative, &begin, &end, newProxy);
1010 // We can not get here with a split vector of pointer, so we can indeed assume
1011 // that actions->fConfiguration != null.
1012 buf.ApplySequence(*actions, begin, end);
1013 if (begin != &(startbuf[0])) {
1014 // assert(end != endbuf);
1015 config->fDeleteTwoIterators(begin,end);
1016 }
1017 }
1018 newProxy->Commit(alternative);
1019 }
1020 }
1021 }
1022
1023 inline void ReadSTLObjectWiseFastArray(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t /* vers */, UInt_t /* start */)
1024 {
1025 TConfigSTL *config = (TConfigSTL*)conf;
1026 // Idea: This needs to be unrolled, it currently calls the TGenCollectionStreamer ....
1027 buf.ReadFastArray(addr,config->fNewClass,conf->fLength,(TMemberStreamer*)0,config->fOldClass);
1028 }
1029 inline void ReadSTLObjectWiseStreamer(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t /* vers */, UInt_t /* start */)
1030 {
1031 TConfigSTL *config = (TConfigSTL*)conf;
1032 (*config->fStreamer)(buf,addr,conf->fLength);
1033 }
1034 inline void ReadSTLObjectWiseFastArrayV2(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers, UInt_t start)
1035 {
1036 // case of old TStreamerInfo
1037
1038 TConfigSTL *config = (TConfigSTL*)conf;
1039 // Backward compatibility. Some TStreamerElement's where without
1040 // Streamer but were not removed from element list
1041 if (config->fIsSTLBase || vers == 0) {
1042 buf.SetBufferOffset(start); //there is no byte count
1043 }
1044 // Idea: This needs to be unrolled, it currently calls the TGenCollectionStreamer ....
1045 buf.ReadFastArray(addr,config->fNewClass,conf->fLength,(TMemberStreamer*)0,config->fOldClass);
1046 }
1047 inline void ReadSTLObjectWiseStreamerV2(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers, UInt_t start)
1048 {
1049 // case of old TStreamerInfo
1050
1051 TConfigSTL *config = (TConfigSTL*)conf;
1052 // Backward compatibility. Some TStreamerElement's where without
1053 // Streamer but were not removed from element list
1054 if (config->fIsSTLBase || vers == 0) {
1055 buf.SetBufferOffset(start); //there is no byte count
1056 }
1057 (*config->fStreamer)(buf,addr,conf->fLength);
1058 }
1059
1060 // To Upgrade this to WriteSTLMemberWiseChangedClass (see ReadSTLMemberWiseChangedClass)
1061 // we would need to a TVirtualCollectionProxy::GetConversionWriteMemberWiseActions
1062 inline void WriteSTLMemberWise(TBuffer &buf, void *addr, const TConfiguration *conf)
1063 {
1064 // Collection was saved member-wise
1065 // newClass -> in memory representation
1066 // oldClass -> onfile representation
1067
1068 TConfigSTL *config = (TConfigSTL*)conf;
1069 TClass *newClass = config->fNewClass;
1070 TClass *onfileClass = config->fOldClass;
1071
1072 // Until the writing of TVirtualCollectionProxy::GetConversionWriteMemberWiseActions
1073 assert(newClass && onfileClass && newClass == onfileClass &&
1074 "Class level transformation while writing is not yet supported");
1075
1076 if (newClass && onfileClass) {
1077
1078 buf.WriteVersion( onfileClass->GetCollectionProxy()->GetValueClass(), kFALSE );
1079
1080 TVirtualCollectionProxy *newProxy = newClass->GetCollectionProxy();
1081 TVirtualCollectionProxy *onfileProxy = onfileClass->GetCollectionProxy();
1082
1083 TVirtualCollectionProxy::TPushPop helper( newProxy, (char*)addr );
1084 Int_t nobjects = newProxy->Size();
1085 buf.WriteInt(nobjects);
1086 if (nobjects) {
1087 TActionSequence *actions = onfileProxy->GetWriteMemberWiseActions();
1090 void *begin = &(startbuf[0]);
1091 void *end = &(endbuf[0]);
1092 config->fCreateIterators( addr, &begin, &end, newProxy);
1093 // We can not get here with a split vector of pointer, so we can indeed assume
1094 // that actions->fConfiguration != null.
1095 buf.ApplySequence(*actions, begin, end);
1096 if (begin != &(startbuf[0])) {
1097 // assert(end != endbuf);
1098 config->fDeleteTwoIterators(begin,end);
1099 }
1100 }
1101 }
1102 }
1103
1104 // This routine could/should be merge with WriteSTLMemberWise, the only difference
1105 // is the for loop over the objects. We are not using this version for the case
1106 // where `conf->fLength is 1` as we know this information at StreamerInfo build time
1107 // and thus we can avoid the 'waste' of CPU cycles involved in doing a loop of length 1
1108 inline void WriteArraySTLMemberWise(TBuffer &buf, void *addr, const TConfiguration *conf)
1109 {
1110 // Collection was saved member-wise
1111 // newClass -> in memory representation
1112 // oldClass -> onfile representation
1113
1114 TConfigSTL *config = (TConfigSTL*)conf;
1115 TClass *newClass = config->fNewClass;
1116 TClass *onfileClass = config->fOldClass;
1117
1118 // Until the writing of TVirtualCollectionProxy::GetConversionWriteMemberWiseActions
1119 assert(newClass && onfileClass && newClass == onfileClass &&
1120 "Class level transformation while writing is not yet supported");
1121
1122 if (newClass && onfileClass) {
1123
1124 buf.WriteVersion( onfileClass->GetCollectionProxy()->GetValueClass(), kFALSE );
1125
1126 TVirtualCollectionProxy *newProxy = newClass->GetCollectionProxy();
1127 TVirtualCollectionProxy *onfileProxy = onfileClass->GetCollectionProxy();
1128
1129 int objectSize = newClass->Size();
1130 char *obj = (char*)addr;
1131 char *endobj = obj + conf->fLength * objectSize;
1132
1133 for (; obj < endobj; obj += objectSize) {
1134 TVirtualCollectionProxy::TPushPop helper( newProxy, (char*)obj );
1135 Int_t nobjects = newProxy->Size();
1136 buf.WriteInt(nobjects);
1137 if (nobjects) {
1138 TActionSequence *actions = onfileProxy->GetWriteMemberWiseActions();
1141 void *begin = &(startbuf[0]);
1142 void *end = &(endbuf[0]);
1143 config->fCreateIterators( addr, &begin, &end, newProxy);
1144 // We can not get here with a split vector of pointer, so we can indeed assume
1145 // that actions->fConfiguration != null.
1146 buf.ApplySequence(*actions, begin, end);
1147 if (begin != &(startbuf[0])) {
1148 // assert(end != endbuf);
1149 config->fDeleteTwoIterators(begin,end);
1150 }
1151 }
1152 }
1153 }
1154 }
1155
1156 inline void WriteSTLObjectWiseFastArray(TBuffer &buf, void *addr, const TConfiguration *conf)
1157 {
1158 TConfigSTL *config = (TConfigSTL*)conf;
1159 // Idea: This needs to be unrolled, it currently calls the TGenCollectionStreamer ....
1160 buf.WriteFastArray(addr,config->fNewClass,conf->fLength,(TMemberStreamer*)0);
1161 }
1162 inline void WriteSTLObjectWiseStreamer(TBuffer &buf, void *addr, const TConfiguration *conf)
1163 {
1164 TConfigSTL *config = (TConfigSTL*)conf;
1165 (*config->fStreamer)(buf,addr,conf->fLength);
1166 }
1167
1168 template <void (*memberwise)(TBuffer&,void *,const TConfiguration*, Version_t),
1169 void (*objectwise)(TBuffer&,void *,const TConfiguration*, Version_t, UInt_t)>
1170 inline Int_t ReadSTL(TBuffer &buf, void *addr, const TConfiguration *conf)
1171 {
1172 TConfigSTL *config = (TConfigSTL*)conf;
1173 UInt_t start, count;
1174 Version_t vers = buf.ReadVersion(&start, &count, config->fOldClass);
1175 if ( vers & TBufferFile::kStreamedMemberWise ) {
1176 memberwise(buf,((char*)addr)+config->fOffset,config, vers);
1177 } else {
1178 objectwise(buf,((char*)addr)+config->fOffset,config, vers, start);
1179 }
1180 buf.CheckByteCount(start,count,config->fTypeName);
1181 return 0;
1182 }
1183
1184 template <void (*memberwise)(TBuffer&,void *,const TConfiguration*),
1185 void (*objectwise)(TBuffer&,void *,const TConfiguration*)>
1186 inline Int_t WriteSTL(TBuffer &buf, void *addr, const TConfiguration *conf)
1187 {
1188 TConfigSTL *config = (TConfigSTL*)conf;
1189 UInt_t start;
1190 TClass *onfileClass = config->fOldClass;
1191 TStreamerElement *aElement = config->fCompInfo->fElem;
1192 TVirtualCollectionProxy *proxy = onfileClass->GetCollectionProxy();
1193 TClass* vClass = proxy ? proxy->GetValueClass() : 0;
1194
1195 // See test in TStreamerInfo::kSTL case in TStreamerInfoWriteBuffer.cxx
1197 && proxy && vClass
1198 && config->fInfo->GetStreamMemberWise() && onfileClass->CanSplit()
1199 && !(strspn(aElement->GetTitle(),"||") == 2)
1200 && !(vClass->HasCustomStreamerMember()) )
1201 {
1202 start = buf.WriteVersionMemberWise(config->fInfo->IsA(), kTRUE);
1203 memberwise(buf, ((char *)addr) + config->fOffset, config);
1204 } else {
1205 start = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
1206 objectwise(buf, ((char *)addr) + config->fOffset, config);
1207 }
1208 buf.SetByteCount(start);
1209 return 0;
1210 }
1211
1212 template <typename From, typename To>
1214 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
1215 {
1216 // Simple conversion from a 'From' on disk to a 'To' in memory.
1217 From temp;
1218 buf >> temp;
1219 *(To*)( ((char*)addr) + config->fOffset ) = (To)temp;
1220 return 0;
1221 }
1222 };
1223
1224 template <typename To>
1226 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
1227 {
1228 // Simple conversion from a 'From' on disk to a 'To' in memory
1229 UInt_t temp;
1230 buf >> temp;
1231
1232 if ((temp & kIsReferenced) != 0) {
1233 HandleReferencedTObject(buf,addr,config);
1234 }
1235
1236 *(To*)( ((char*)addr) + config->fOffset ) = (To)temp;
1237 return 0;
1238 }
1239 };
1240
1241 template <typename From, typename To>
1243 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
1244 {
1245 // Simple conversion from a 'From' on disk to a 'To' in memory.
1246 TConfWithFactor *conf = (TConfWithFactor *)config;
1247 From temp;
1248 buf.ReadWithFactor(&temp, conf->fFactor, conf->fXmin);
1249 *(To*)( ((char*)addr) + config->fOffset ) = (To)temp;
1250 return 0;
1251 }
1252 };
1253
1254 template <typename From, typename To>
1256 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
1257 {
1258 // Simple conversion from a 'From' on disk to a 'To' in memory.
1259 TConfNoFactor *conf = (TConfNoFactor *)config;
1260 From temp;
1261 buf.ReadWithNbits(&temp, conf->fNbits);
1262 *(To*)( ((char*)addr) + config->fOffset ) = (To)temp;
1263 return 0;
1264 }
1265 };
1266
1268 // Configuration object for the PushDataCache case.
1269 public:
1271
1273 TConfiguration(info, -1, nullptr, offset), fOnfileObject(onfileObject)
1274 {}
1275
1276 void Print() const override
1277 {
1279 if (fOnfileObject)
1280 printf("StreamerInfoAction, class:%s, PushDataCache offset=%d\n",
1281 info->GetClass()->GetName(), fOffset);
1282 else
1283 printf("StreamerInfoAction, class:%s, PopDataCache offset=%d\n",
1284 info->GetClass()->GetName(), fOffset);
1285 }
1286 void PrintDebug(TBuffer &buffer, void *object) const override
1287 {
1288 if (gDebug > 1) {
1290 printf("StreamerInfoAction, class:%s, %sDataCache, bufpos=%d, arr=%p, offset=%d, onfileObject=%p\n",
1291 info->GetClass()->GetName(), fOnfileObject ? "Push" : "Pop", buffer.Length(), object, fOffset, fOnfileObject);
1292
1293 }
1294 }
1295 };
1296
1298 {
1300 auto onfileObject = config->fOnfileObject;
1301
1302 // onfileObject->SetSize(1);
1303 b.PushDataCache( onfileObject );
1304
1305 return 0;
1306 }
1307
1308 Int_t PushDataCacheVectorPtr(TBuffer &b, void *, const void *, const TConfiguration *conf)
1309 {
1311 auto onfileObject = config->fOnfileObject;
1312
1313 // onfileObject->SetSize(n);
1314 b.PushDataCache( onfileObject );
1315
1316 return 0;
1317 }
1318
1319 Int_t PushDataCacheGenericCollection(TBuffer &b, void *, const void *, const TLoopConfiguration *loopconfig, const TConfiguration *conf)
1320 {
1322 auto onfileObject = config->fOnfileObject;
1323
1324 TVirtualCollectionProxy *proxy = ((TGenericLoopConfig*)loopconfig)->fProxy;
1325 UInt_t n = proxy->Size();
1326
1327 onfileObject->SetSize(n);
1328 b.PushDataCache( onfileObject );
1329
1330 return 0;
1331 }
1332
1334 {
1335 b.PopDataCache();
1336 return 0;
1337 }
1338
1339 Int_t PopDataCacheVectorPtr(TBuffer &b, void *, const void *, const TConfiguration *)
1340 {
1341 b.PopDataCache();
1342 return 0;
1343 }
1344
1346 {
1347 b.PopDataCache();
1348 return 0;
1349 }
1350
1352 // Configuration object for the UseCache case.
1353 public:
1356
1358 TConfiguration(info,action.fConfiguration->fElemId,action.fConfiguration->fCompInfo,action.fConfiguration->fOffset),fAction(action),fNeedRepeat(repeat) {};
1359 void PrintDebug(TBuffer &b, void *addr) const override
1360 {
1361 if (gDebug > 1) {
1362 // Idea: We should print the name of the action function.
1364 TStreamerElement *aElement = fCompInfo->fElem;
1365 fprintf(stdout,"StreamerInfoAction, class:%s, name=%s, fType[%d]=%d,"
1366 " %s, bufpos=%d, arr=%p, eoffset=%d, Redirect=%p\n",
1367 info->GetClass()->GetName(),aElement->GetName(),fElemId,fCompInfo->fType,
1368 aElement->ClassName(),b.Length(),addr, 0,b.PeekDataCache() ? b.PeekDataCache()->GetObjectAt(0) : 0);
1369 }
1370
1371 }
1374 {
1376 fAction.fConfiguration = copy->fAction.fConfiguration->Copy(); // since the previous allocation did a 'move' of fAction we need to fix it.
1377 return copy;
1378 }
1379 };
1380
1381 inline Int_t UseCache(TBuffer &b, void *addr, const TConfiguration *conf)
1382 {
1384
1385 Int_t bufpos = b.Length();
1386 TVirtualArray *cached = b.PeekDataCache();
1387 if (cached==0) {
1388 TStreamerElement *aElement = conf->fCompInfo->fElem;
1389 TStreamerInfo *info = (TStreamerInfo*)conf->fInfo;
1390 Warning("ReadBuffer","Skipping %s::%s because the cache is missing.",info->GetName(),aElement->GetName());
1391 char *ptr = (char*)addr;
1392 info->ReadBufferSkip(b,&ptr,config->fCompInfo,config->fCompInfo->fType+TStreamerInfo::kSkip,aElement,1,0);
1393 } else {
1394 config->fAction(b, (*cached)[0]);
1395 }
1396 // Idea: Factor out this 'if' to a UseCacheRepeat function
1397 if (config->fNeedRepeat) {
1398 b.SetBufferOffset(bufpos);
1399 }
1400 return 0;
1401 }
1402
1403 inline Int_t UseCacheVectorPtrLoop(TBuffer &b, void *start, const void *end, const TConfiguration *conf)
1404 {
1406 Int_t bufpos = b.Length();
1407
1408 TVirtualArray *cached = b.PeekDataCache();
1409 if (cached==0) {
1410 TStreamerElement *aElement = config->fCompInfo->fElem;
1411 TStreamerInfo *info = (TStreamerInfo*)config->fInfo;
1412 Warning("ReadBuffer","Skipping %s::%s because the cache is missing.",info->GetName(),aElement->GetName());
1413 char *ptr = (char*)start;
1414 UInt_t n = (((void**)end)-((void**)start));
1415 info->ReadBufferSkip(b,&ptr,config->fCompInfo,conf->fCompInfo->fType+TStreamerInfo::kSkip,aElement,n,0);
1416 } else {
1417 TVectorLoopConfig cached_config( nullptr, cached->fClass->Size(), /* read */ kTRUE );
1418 void *cached_start = (*cached)[0];
1419 void *cached_end = ((char*)cached_start) + cached->fSize * cached_config.fIncrement;
1420 config->fAction(b,cached_start,cached_end,&cached_config);
1421 }
1422 // Idea: Factor out this 'if' to a UseCacheRepeat function
1423 if (config->fNeedRepeat) {
1424 b.SetBufferOffset(bufpos);
1425 }
1426 return 0;
1427 }
1428
1429 inline Int_t UseCacheVectorLoop(TBuffer &b, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *conf)
1430 {
1432
1433 Int_t bufpos = b.Length();
1434 TVirtualArray *cached = b.PeekDataCache();
1435 if (cached==0) {
1436 TStreamerElement *aElement = config->fCompInfo->fElem;
1437 TStreamerInfo *info = (TStreamerInfo*)config->fInfo;
1438 Warning("ReadBuffer","Skipping %s::%s because the cache is missing.",info->GetName(),aElement->GetName());
1439 char *ptr = (char*)start;
1440 UInt_t n = (((char*)end)-((char*)start))/((TVectorLoopConfig*)loopconf)->fIncrement;
1441 info->ReadBufferSkip(b,&ptr,config->fCompInfo,config->fCompInfo->fType+TStreamerInfo::kSkip,aElement,n,0);
1442 } else {
1443 TVectorLoopConfig cached_config( nullptr, cached->fClass->Size(), /* read */ kTRUE );
1444 void *cached_start = (*cached)[0];
1445 void *cached_end = ((char*)cached_start) + cached->fSize * cached_config.fIncrement;
1446 config->fAction(b,cached_start,cached_end,&cached_config);
1447 }
1448 // Idea: Factor out this 'if' to a UseCacheRepeat function
1449 if (config->fNeedRepeat) {
1450 b.SetBufferOffset(bufpos);
1451 }
1452 return 0;
1453 }
1454
1455 inline Int_t UseCacheGenericCollection(TBuffer &b, void *, const void *, const TLoopConfiguration *loopconfig, const TConfiguration *conf)
1456 {
1458
1459 Int_t bufpos = b.Length();
1460 TVirtualArray *cached = b.PeekDataCache();
1461 if (cached==0) {
1462 TStreamerElement *aElement = config->fCompInfo->fElem;
1463 TStreamerInfo *info = (TStreamerInfo*)config->fInfo;
1464
1465 TVirtualCollectionProxy *proxy = ((TGenericLoopConfig*)loopconfig)->fProxy;
1466 Warning("ReadBuffer","Skipping %s::%s because the cache is missing.",info->GetName(),aElement->GetName());
1467 UInt_t n = proxy->Size();
1468 info->ReadBufferSkip(b, *proxy,config->fCompInfo,config->fCompInfo->fType+TStreamerInfo::kSkip,aElement,n,0);
1469 } else {
1470 TVectorLoopConfig cached_config( nullptr, cached->fClass->Size(), /* read */ kTRUE );
1471 void *cached_start = (*cached)[0];
1472 void *cached_end = ((char*)cached_start) + cached->fSize * cached_config.fIncrement;
1473 config->fAction(b,cached_start,cached_end,&cached_config);
1474 }
1475 // Idea: Factor out this 'if' to a UseCacheRepeat function
1476 if (config->fNeedRepeat) {
1477 b.SetBufferOffset(bufpos);
1478 }
1479 return 0;
1480 }
1481
1482 // Support for collections.
1483
1484 Int_t ReadLoopInvalid(TBuffer &, void *, const void *, const TConfiguration *config)
1485 {
1486 Fatal("ApplySequence","The sequence of actions to read %s:%d member-wise was not initialized.",config->fInfo->GetName(),config->fInfo->GetClassVersion());
1487 return 0;
1488 }
1489
1490 Int_t WriteLoopInvalid(TBuffer &, void *, const void *, const TConfiguration *config)
1491 {
1492 Fatal("ApplySequence","The sequence of actions to write %s:%d member-wise was not initialized.",config->fInfo->GetName(),config->fInfo->GetClassVersion());
1493 return 0;
1494 }
1495
1497
1499 {
1501 return kVectorLooper;
1502 } else if ( (proxy.GetCollectionType() == ROOT::kSTLvector)) {
1504 return kGenericLooper;
1505 else
1506 return kVectorLooper;
1511 || proxy.GetCollectionType() == ROOT::kSTLbitset) {
1512 return kAssociativeLooper;
1513 } else {
1514 return kGenericLooper;
1515 }
1516 }
1517
1519 {
1520 if (proxy)
1521 return SelectLooper(*proxy);
1522 else
1523 return kVectorPtrLooper;
1524 }
1525
1526
1527 template<typename Looper>
1529
1530 /// \param loopConfig pointer ownership stays at the caller, a copy is performed and transferred to the
1531 /// TActionSequence class (stored as public fLoopConfig internally, will be deleted in destructor) \return unique
1532 /// pointer of type TActionSequence
1533 static std::unique_ptr<TStreamerInfoActions::TActionSequence>
1535 {
1536 std::unique_ptr<TLoopConfiguration> localLoopConfig{ loopConfig ? loopConfig->Copy() : nullptr };
1537 std::unique_ptr<TStreamerInfoActions::TActionSequence> actions(
1538 TActionSequence::CreateReadMemberWiseActions(info, std::move(localLoopConfig)));
1539 return actions;
1540 }
1541
1542 /// \param loopConfig pointer ownership stays at the caller, a copy is performed and transferred to the
1543 /// TActionSequence class (stored as public fLoopConfig internally, will be deleted in destructor) \return unique
1544 /// pointer of type TActionSequence
1545 static std::unique_ptr<TStreamerInfoActions::TActionSequence>
1547 {
1548 std::unique_ptr<TLoopConfiguration> localLoopConfig{ loopConfig ? loopConfig->Copy() : nullptr };
1549 std::unique_ptr<TStreamerInfoActions::TActionSequence> actions(
1550 TActionSequence::CreateWriteMemberWiseActions(info, std::move(localLoopConfig)));
1551 return actions;
1552 }
1553
1554 static inline Int_t SubSequenceAction(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * /* loopconfig */, const TConfiguration *config)
1555 {
1556 auto conf = (TConfSubSequence*)config;
1557 auto actions = conf->fActions.get();
1558 // FIXME: need to update the signature of ApplySequence.
1559 buf.ApplySequence(*actions, start, const_cast<void*>(end));
1560 return 0;
1561 }
1562
1563 static inline Int_t ReadStreamerCase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * loopconfig, const TConfiguration *config)
1564 {
1565 UInt_t pos, count;
1566 /* Version_t v = */ buf.ReadVersion(&pos, &count, config->fInfo->IsA());
1567
1568 Looper::template LoopOverCollection< ReadViaExtStreamer >(buf, start, end, loopconfig, config);
1569
1570 buf.CheckByteCount(pos, count, config->fCompInfo->fElem->GetFullName());
1571 return 0;
1572 }
1573
1574 static inline Int_t WriteStreamerCase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * loopconfig, const TConfiguration *config)
1575 {
1576 UInt_t pos = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
1577
1578 Looper::template LoopOverCollection< WriteViaExtStreamer >(buf, start, end, loopconfig, config);
1579
1580 buf.SetByteCount(pos, kTRUE);
1581 return 0;
1582 }
1583
1584 static inline Int_t StreamerLoopExternal(TBuffer &buf, void *addr, const TConfiguration *actionConfig) {
1585 UInt_t ioffset = actionConfig->fOffset;
1586 // Get any private streamer which was set for the data member.
1587 TMemberStreamer* pstreamer = actionConfig->fCompInfo->fStreamer;
1588 Int_t *counter = (Int_t *)((char *)addr /*entry pointer*/ +
1589 ((const TConfStreamerLoop *)actionConfig)->fCounterOffset /*counter offset*/);
1590 // And call the private streamer, passing it the buffer, the object, and the counter.
1591 (*pstreamer)(buf, (char *) addr /*entry pointer*/ + ioffset /*object offset*/, *counter);
1592 return 0;
1593 };
1594
1595 template<bool kIsTextT>
1596 static Int_t WriteStreamerLoopPoly(TBuffer &buf, void *addr, const TConfiguration *config) {
1597 // Get the class of the data member.
1598 TClass* cl = config->fCompInfo->fClass;
1599 UInt_t ioffset = config->fOffset;
1600 bool isPtrPtr = ((TConfStreamerLoop*)config)->fIsPtrPtr;
1601
1602 // Get the counter for the varying length array.
1603 Int_t vlen = *((Int_t *)((char *)addr /*entry pointer*/ +
1604 ((const TConfStreamerLoop *)config)->fCounterOffset /*counter offset*/));
1605
1606 //b << vlen;
1607 if (vlen) {
1608 // Get a pointer to the array of pointers.
1609 char** pp = (char**) ((char *) addr /*entry pointer*/ + ioffset /*object offset*/);
1610 // Loop over each element of the array of pointers to varying-length arrays.
1611 for (Int_t ndx = 0; ndx < config->fCompInfo->fLength; ++ndx) {
1612 if (!pp[ndx]) {
1613 // -- We do not have a pointer to a varying-length array.
1614 // Error("WriteBufferAux", "The pointer to element %s::%s type %d (%s) is null\n", GetName(), aElement->GetFullName(), compinfo[i]->fType, aElement->GetTypeName());
1615 // ::ErrorHandler(kError, "::WriteStreamerLoop", Form("The pointer to element %s::%s type %d (%s) is null\n", config->fInfo->GetName(), config->fCompInfo->fElem->GetFullName(), config->fCompInfo->fType, config->fCompInfo->fElem->GetTypeName()));
1616 printf("WriteStreamerLoop - The pointer to element %s::%s type %d (%s) is null\n", config->fInfo->GetName(), config->fCompInfo->fElem->GetFullName(), config->fCompInfo->fType, config->fCompInfo->fElem->GetTypeName());
1617 continue;
1618 }
1619 if (!isPtrPtr) {
1620 // -- We are a varying-length array of objects.
1621 // Write the entire array of objects to the buffer.
1622 // Note: Polymorphism is not allowed here.
1623 buf.WriteFastArray(pp[ndx], cl, vlen, nullptr);
1624 } else {
1625 // -- We are a varying-length array of pointers to objects.
1626 // Write the entire array of object pointers to the buffer.
1627 // Note: The object pointers are allowed to be polymorphic.
1628 buf.WriteFastArray((void **)pp[ndx], cl, vlen, kFALSE, nullptr);
1629 } // isPtrPtr
1630 } // ndx
1631 } else // vlen
1632 if (kIsTextT) {
1633 // special handling for the text-based streamers
1634 for (Int_t ndx = 0; ndx < config->fCompInfo->fLength; ++ndx)
1635 buf.WriteFastArray((void *)nullptr, cl, -1, nullptr);
1636 }
1637 return 0;
1638 }
1639
1640 static Int_t WriteStreamerLoopStatic(TBuffer &buf, void *addr, const TConfiguration *config) {
1641 // Get the class of the data member.
1642 TClass* cl = config->fCompInfo->fClass;
1643 UInt_t ioffset = config->fOffset;
1644 bool isPtrPtr = ((TConfStreamerLoop*)config)->fIsPtrPtr;
1645
1646 // Get the counter for the varying length array.
1647 Int_t vlen = *((Int_t *)((char *)addr /*entry pointer*/ +
1648 ((const TConfStreamerLoop *)config)->fCounterOffset /*counter offset*/));
1649 //b << vlen;
1650 if (vlen) {
1651 // Get a pointer to the array of pointers.
1652 char** pp = (char**) ((char *) addr /*entry pointer*/ + ioffset /*object offset*/);
1653 // -- Older versions do *not* allow polymorphic pointers to objects.
1654 // Loop over each element of the array of pointers to varying-length arrays.
1655 for (Int_t ndx = 0; ndx < config->fCompInfo->fLength; ++ndx) {
1656 if (!pp[ndx]) {
1657 // -- We do not have a pointer to a varying-length array.
1658 //Error("WriteBufferAux", "The pointer to element %s::%s type %d (%s) is null\n", GetName(), aElement->GetFullName(), compinfo[i]->fType, aElement->GetTypeName());
1659 // ::ErrorHandler(kError, "::WriteTextStreamerLoop", Form("The pointer to element %s::%s type %d (%s) is null\n", config->fInfo->GetName(), config->fCompInfo->fElem->GetFullName(), config->fCompInfo->fType, config->fCompInfo->fElem->GetTypeName()));
1660 printf("WriteStreamerLoop - The pointer to element %s::%s type %d (%s) is null\n", config->fInfo->GetName(), config->fCompInfo->fElem->GetFullName(), config->fCompInfo->fType, config->fCompInfo->fElem->GetTypeName());
1661 continue;
1662 }
1663 if (!isPtrPtr) {
1664 // -- We are a varying-length array of objects.
1665 // Loop over the elements of the varying length array.
1666 for (Int_t v = 0; v < vlen; ++v) {
1667 // Write the object to the buffer.
1668 cl->Streamer(pp[ndx] + (v * cl->Size()), buf);
1669 } // v
1670 }
1671 else {
1672 // -- We are a varying-length array of pointers to objects.
1673 // Loop over the elements of the varying length array.
1674 for (Int_t v = 0; v < vlen; ++v) {
1675 // Get a pointer to the object pointer.
1676 char** r = (char**) pp[ndx];
1677 // Write the object to the buffer.
1678 cl->Streamer(r[v], buf);
1679 } // v
1680 } // isPtrPtr
1681 } // ndx
1682 } // vlen
1683 return 0;
1684 }
1685
1686 template<bool kIsTextT, typename... Ts>
1688 static inline Int_t Action(TBuffer &buf, void *start, Ts... args, const TConfiguration *config)
1689 {
1690 if (!kIsTextT && config->fCompInfo->fStreamer) {
1691 // -- We have a private streamer.
1692 UInt_t pos = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
1693
1694 // Loop over the entries in the clones array or the STL container.
1695 Looper::template LoopOverCollection< StreamerLoopExternal > (buf, start, args..., config);
1696
1697 buf.SetByteCount(pos, kTRUE);
1698 // We are done, next streamer element.
1699 return 0;
1700 }
1701
1702 // By default assume the file version is the newest.
1703 Int_t fileVersion = kMaxInt;
1704
1705 if (!kIsTextT) {
1706 // At this point we do *not* have a private streamer.
1707 // Get the version of the file we are writing to.
1708 TFile* file = (TFile*) buf.GetParent();
1709 if (file) {
1710 fileVersion = file->GetVersion();
1711 }
1712 }
1713 // Write the class version to the buffer.
1714 UInt_t pos = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
1715 if (fileVersion > 51508) {
1716 // -- Newer versions allow polymorphic pointers to objects.
1717 // Loop over the entries in the clones array or the STL container.
1718 Looper::template LoopOverCollection< WriteStreamerLoopPoly<kIsTextT> > (buf, start, args..., config);
1719 }
1720 else {
1721 // -- Older versions do *not* allow polymorphic pointers to objects.
1722 // Loop over the entries in the clones array or the STL container.
1723 Looper::template LoopOverCollection< ReadStreamerLoopStatic > (buf, start, args..., config);
1724 } // fileVersion
1725 // Backpatch the byte count into the buffer.
1726 buf.SetByteCount(pos, kTRUE);
1727
1728 return 0;
1729 }
1730 };
1731
1732 template<bool kIsTextT>
1733 static Int_t ReadStreamerLoopPoly(TBuffer &buf, void *addr, const TConfiguration *config) {
1734 // Get the class of the data member.
1735 TClass* cl = config->fCompInfo->fClass;
1736 UInt_t ioffset = config->fOffset;
1737 // Which are we, an array of objects or an array of pointers to objects?
1738 bool isPtrPtr = ((TConfStreamerLoop*)config)->fIsPtrPtr;
1739
1740 // Get the counter for the varying length array.
1741 Int_t vlen = *((Int_t *)((char *)addr /*entry pointer*/ +
1742 ((const TConfStreamerLoop *)config)->fCounterOffset /*counter offset*/));
1743 // Int_t realLen;
1744 // b >> realLen;
1745 // if (realLen != vlen) {
1746 // fprintf(stderr, "read vlen: %d realLen: %s\n", vlen, realLen);
1747 //}
1748 // Get a pointer to the array of pointers.
1749 char **pp = (char **)((char *)addr /*entry pointer*/ + ioffset /*object offset*/);
1750 // Loop over each element of the array of pointers to varying-length arrays.
1751 // if (!pp) {
1752 // continue;
1753 // }
1754
1755 if (pp) // SL: place it here instead of continue, which is related to for(k) loop
1756 for (Int_t ndx = 0; ndx < config->fCompInfo->fLength; ++ndx) {
1757 // if (!pp[ndx]) {
1758 // -- We do not have a pointer to a varying-length array.
1759 // Error("ReadBuffer", "The pointer to element %s::%s type %d (%s) is null\n", thisVar->GetName(),
1760 // aElement->GetFullName(), compinfo[i]->fType, aElement->GetTypeName());
1761 // continue;
1762 //}
1763 // Delete any memory at pp[ndx].
1764 if (!isPtrPtr) {
1765 cl->DeleteArray(pp[ndx]);
1766 pp[ndx] = 0;
1767 } else {
1768 // Using vlen is wrong here because it has already
1769 // been overwritten with the value needed to read
1770 // the current record. Fixing this will require
1771 // doing a pass over the object at the beginning
1772 // of the I/O and releasing all the buffer memory
1773 // for varying length arrays before we overwrite
1774 // the counter values.
1775 //
1776 // For now we will just leak memory, just as we
1777 // have always done in the past. Fix this.
1778 //
1779 // char** r = (char**) pp[ndx];
1780 // if (r) {
1781 // for (Int_t v = 0; v < vlen; ++v) {
1782 // cl->Destructor(r[v]);
1783 // r[v] = 0;
1784 // }
1785 //}
1786 delete[] pp[ndx];
1787 pp[ndx] = 0;
1788 }
1789 if (!vlen) {
1790 if (kIsTextT) {
1791 // special handling for the text-based streamers - keep calling to shift array index
1792 buf.ReadFastArray((void *)nullptr, cl, -1, nullptr);
1793 }
1794 continue;
1795 }
1796 // Note: We now have pp[ndx] is null.
1797 // Allocate memory to read into.
1798 if (!isPtrPtr) {
1799 // -- We are a varying-length array of objects.
1800 // Note: Polymorphism is not allowed here.
1801 // Allocate a new array of objects to read into.
1802 pp[ndx] = (char *)cl->NewArray(vlen);
1803 if (!pp[ndx]) {
1804 Error("ReadBuffer", "Memory allocation failed!\n");
1805 continue;
1806 }
1807 } else {
1808 // -- We are a varying-length array of pointers to objects.
1809 // Note: The object pointers are allowed to be polymorphic.
1810 // Allocate a new array of pointers to objects to read into.
1811 pp[ndx] = (char *)new char *[vlen];
1812 if (!pp[ndx]) {
1813 Error("ReadBuffer", "Memory allocation failed!\n");
1814 continue;
1815 }
1816 // And set each pointer to null.
1817 memset(pp[ndx], 0, vlen * sizeof(char *)); // This is the right size we really have a char**: pp[ndx]
1818 // = (char*) new char*[vlen];
1819 }
1820 if (!isPtrPtr) {
1821 // -- We are a varying-length array of objects.
1822 buf.ReadFastArray(pp[ndx], cl, vlen, nullptr);
1823 } else {
1824 // -- We are a varying-length array of object pointers.
1825 buf.ReadFastArray((void **)pp[ndx], cl, vlen, kFALSE, nullptr);
1826 } // isPtrPtr
1827 } // ndx
1828 return 0;
1829 }; // StreamerLoopPoly
1830
1831 static Int_t ReadStreamerLoopStatic(TBuffer &buf, void *addr, const TConfiguration *config) {
1832 // Get the class of the data member.
1833 TClass* cl = config->fCompInfo->fClass;
1834 UInt_t ioffset = config->fOffset;
1835 // Which are we, an array of objects or an array of pointers to objects?
1836 bool isPtrPtr = ((TConfStreamerLoop*)config)->fIsPtrPtr;
1837
1838 // Get the counter for the varying length array.
1839 Int_t vlen = *((Int_t *)((char *)addr /*entry pointer*/ +
1840 ((const TConfStreamerLoop *)config)->fCounterOffset /*counter offset*/));
1841 // Int_t realLen;
1842 // b >> realLen;
1843 // if (realLen != vlen) {
1844 // fprintf(stderr, "read vlen: %d realLen: %s\n", vlen, realLen);
1845 //}
1846 // Get a pointer to the array of pointers.
1847 char **pp = (char **)((char *)addr /*entry pointer*/ + ioffset /*object offset*/);
1848 // if (!pp) {
1849 // continue;
1850 //}
1851
1852 if (pp) // SL: place it here instead of continue, which is related to for(k) loop
1853
1854 // Loop over each element of the array of pointers to varying-length arrays.
1855 for (Int_t ndx = 0; ndx < config->fCompInfo->fLength; ++ndx) {
1856 // if (!pp[ndx]) {
1857 // -- We do not have a pointer to a varying-length array.
1858 // Error("ReadBuffer", "The pointer to element %s::%s type %d (%s) is null\n", thisVar->GetName(),
1859 // aElement->GetFullName(), compinfo[i]->fType, aElement->GetTypeName());
1860 // continue;
1861 //}
1862 // Delete any memory at pp[ndx].
1863 if (!isPtrPtr) {
1864 cl->DeleteArray(pp[ndx]);
1865 pp[ndx] = 0;
1866 } else {
1867 // Using vlen is wrong here because it has already
1868 // been overwritten with the value needed to read
1869 // the current record. Fixing this will require
1870 // doing a pass over the object at the beginning
1871 // of the I/O and releasing all the buffer memory
1872 // for varying length arrays before we overwrite
1873 // the counter values.
1874 //
1875 // For now we will just leak memory, just as we
1876 // have always done in the past. Fix this.
1877 //
1878 // char** r = (char**) pp[ndx];
1879 // if (r) {
1880 // for (Int_t v = 0; v < vlen; ++v) {
1881 // cl->Destructor(r[v]);
1882 // r[v] = 0;
1883 // }
1884 //}
1885 delete[] pp[ndx];
1886 pp[ndx] = 0;
1887 }
1888 if (!vlen) {
1889 continue;
1890 }
1891 // Note: We now have pp[ndx] is null.
1892 // Allocate memory to read into.
1893 if (!isPtrPtr) {
1894 // -- We are a varying-length array of objects.
1895 // Note: Polymorphism is not allowed here.
1896 // Allocate a new array of objects to read into.
1897 pp[ndx] = (char *)cl->NewArray(vlen);
1898 if (!pp[ndx]) {
1899 Error("ReadBuffer", "Memory allocation failed!\n");
1900 continue;
1901 }
1902 } else {
1903 // -- We are a varying-length array of pointers to objects.
1904 // Note: The object pointers are allowed to be polymorphic.
1905 // Allocate a new array of pointers to objects to read into.
1906 pp[ndx] = (char *)new char *[vlen];
1907 if (!pp[ndx]) {
1908 Error("ReadBuffer", "Memory allocation failed!\n");
1909 continue;
1910 }
1911 // And set each pointer to null.
1912 memset(pp[ndx], 0, vlen * sizeof(char *)); // This is the right size we really have a char**: pp[ndx]
1913 // = (char*) new char*[vlen];
1914 }
1915 if (!isPtrPtr) {
1916 // -- We are a varying-length array of objects.
1917 // Loop over the elements of the varying length array.
1918 for (Int_t v = 0; v < vlen; ++v) {
1919 // Read the object from the buffer.
1920 cl->Streamer(pp[ndx] + (v * cl->Size()), buf);
1921 } // v
1922 } else {
1923 // -- We are a varying-length array of object pointers.
1924 // Get a pointer to the object pointer array.
1925 char **r = (char **)pp[ndx];
1926 // Loop over the elements of the varying length array.
1927 for (Int_t v = 0; v < vlen; ++v) {
1928 // Allocate an object to read into.
1929 r[v] = (char *)cl->New();
1930 if (!r[v]) {
1931 // Do not print a second error message here.
1932 // Error("ReadBuffer", "Memory allocation failed!\n");
1933 continue;
1934 }
1935 // Read the object from the buffer.
1936 cl->Streamer(r[v], buf);
1937 } // v
1938 } // isPtrPtr
1939 } // ndx
1940 return 0;
1941 }; // action
1942
1943 template<bool kIsTextT, typename... Ts>
1945 static inline Int_t Action(TBuffer &buf, void *start, Ts... args, const TConfiguration *config)
1946 {
1947 // Check for a private streamer.
1948 if (!kIsTextT && config->fCompInfo->fStreamer) {
1949 // -- We have a private streamer.
1950 // Read the class version and byte count from the buffer.
1951 UInt_t pos = 0;
1952 UInt_t count = 0;
1953 buf.ReadVersion(&pos, &count, config->fInfo->IsA());
1954
1955 // Loop over the entries in the clones array or the STL container.
1956 Looper::template LoopOverCollection< StreamerLoopExternal > (buf, start, args..., config);
1957
1958 buf.CheckByteCount(pos, count, config->fCompInfo->fElem->GetFullName());
1959 // We are done, next streamer element.
1960 return 0;
1961 }
1962
1963 // By default assume the file version is the newest.
1964 Int_t fileVersion = kMaxInt;
1965 if (!kIsTextT) {
1966 // At this point we do *not* have a private streamer.
1967 // Get the version of the file we are reading from.
1968 TFile* file = (TFile*) buf.GetParent();
1969 if (file) {
1970 fileVersion = file->GetVersion();
1971 }
1972 }
1973 // Read the class version and byte count from the buffer.
1974 UInt_t pos = 0;
1975 UInt_t count = 0;
1976 buf.ReadVersion(&pos, &count, config->fInfo->IsA());
1977 if (fileVersion > 51508) {
1978 // -- Newer versions allow polymorphic pointers.
1979
1980 // Loop over the entries in the clones array or the STL container.
1981 Looper::template LoopOverCollection< ReadStreamerLoopPoly<kIsTextT> > (buf, start, args..., config);
1982 } else {
1983 // -- Older versions do *not* allow polymorphic pointers.
1984
1985 // Loop over the entries in the clones array or the STL container.
1986 Looper::template LoopOverCollection< ReadStreamerLoopStatic > (buf, start, args..., config);
1987 } // fileVersion
1988 buf.CheckByteCount(pos, count, config->fCompInfo->fElem->GetFullName());
1989 return 0;
1990 }
1991 };
1992
1993 };
1994
1995 // The Scalar 'looper' only process one element.
1996 struct ScalarLooper : public CollectionLooper<ScalarLooper>
1997 {
1998 using LoopAction_t = Int_t (*)(TBuffer &, void*, const TConfiguration*);
1999
2000 template <Int_t (*iter_action)(TBuffer&,void *,const TConfiguration*)>
2001 static inline Int_t LoopOverCollection(TBuffer &buf, void *start, const TConfiguration *config)
2002 {
2003 iter_action(buf, start, config);
2004 return 0;
2005 }
2006 };
2007
2008 struct VectorLooper : public CollectionLooper<VectorLooper>
2009 {
2010 using LoopAction_t = Int_t (*)(TBuffer &, void*, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration*);
2011
2012 template <bool kIsText>
2014 template <bool kIsText>
2016
2017 template <Int_t (*iter_action)(TBuffer&,void *,const TConfiguration*)>
2018 static inline Int_t LoopOverCollection(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2019 {
2020 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2021 //Idea: can we factor out the addition of fOffset
2022 // iter = (char*)iter + config->fOffset;
2023 for(void *iter = start; iter != end; iter = (char*)iter + incr ) {
2024 iter_action(buf, iter, config);
2025 }
2026 return 0;
2027 }
2028
2029 template <typename T>
2030 static inline Int_t ReadBasicType(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2031 {
2032 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2033 iter = (char*)iter + config->fOffset;
2034 end = (char*)end + config->fOffset;
2035 for(; iter != end; iter = (char*)iter + incr ) {
2036 T *x = (T*) ((char*) iter);
2037 buf >> *x;
2038 }
2039 return 0;
2040 }
2041
2042 template <typename From, typename To>
2044 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2045 {
2046 // Simple conversion from a 'From' on disk to a 'To' in memory.
2047 From temp;
2048 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2049 iter = (char*)iter + config->fOffset;
2050 end = (char*)end + config->fOffset;
2051 for(; iter != end; iter = (char*)iter + incr ) {
2052 buf >> temp;
2053 *(To*)( ((char*)iter) ) = (To)temp;
2054 }
2055 return 0;
2056 }
2057 };
2058
2059 template <typename To>
2061 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2062 {
2063 // Simple conversion from a 'From' on disk to a 'To' in memory.
2064 UInt_t temp;
2065 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2066 iter = (char*)iter + config->fOffset;
2067 end = (char*)end + config->fOffset;
2068 for(; iter != end; iter = (char*)iter + incr ) {
2069 buf >> temp;
2070
2071 if ((temp & kIsReferenced) != 0) {
2072 HandleReferencedTObject(buf, (char*)iter - config->fOffset, config);
2073 }
2074
2075 *(To*)( ((char*)iter) ) = (To)temp;
2076 }
2077 return 0;
2078 }
2079 };
2080
2081 template <typename From, typename To>
2083 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2084 {
2085 // Simple conversion from a 'From' on disk to a 'To' in memory.
2086 TConfWithFactor *conf = (TConfWithFactor *)config;
2087 From temp;
2088 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2089 iter = (char*)iter + config->fOffset;
2090 end = (char*)end + config->fOffset;
2091 for(; iter != end; iter = (char*)iter + incr ) {
2092 buf.ReadWithFactor(&temp, conf->fFactor, conf->fXmin);
2093 *(To*)( ((char*)iter) ) = (To)temp;
2094 }
2095 return 0;
2096 }
2097 };
2098
2099 template <typename From, typename To>
2101 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2102 {
2103 // Simple conversion from a 'From' on disk to a 'To' in memory.
2104 TConfNoFactor *conf = (TConfNoFactor *)config;
2105 From temp;
2106 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2107 iter = (char*)iter + config->fOffset;
2108 end = (char*)end + config->fOffset;
2109 for(; iter != end; iter = (char*)iter + incr ) {
2110 buf.ReadWithNbits(&temp, conf->fNbits);
2111 *(To*)( ((char*)iter) ) = (To)temp;
2112 }
2113 return 0;
2114 }
2115 };
2116
2117 template <typename T>
2118 static inline Int_t WriteBasicType(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2119 {
2120 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2121 iter = (char*)iter + config->fOffset;
2122 end = (char*)end + config->fOffset;
2123 for(; iter != end; iter = (char*)iter + incr ) {
2124 T *x = (T*) ((char*) iter);
2125 buf << *x;
2126 }
2127 return 0;
2128 }
2129
2130 template <typename Onfile, typename Memory>
2132 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2133 {
2134 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2135 iter = (char*)iter + config->fOffset;
2136 end = (char*)end + config->fOffset;
2137 for(; iter != end; iter = (char*)iter + incr ) {
2138 // Simple conversion from a 'From' on disk to a 'To' in memory.
2139 Onfile temp = (Onfile)(*(Memory*)((char*) iter));
2140 buf << temp;
2141 }
2142 return 0;
2143 }
2144 };
2145
2146 template <typename Onfile, typename Memory>
2147 struct WriteConvertBasicType<WithFactorMarker<Onfile>, Memory> {
2148 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2149 {
2150 const TStreamerElement *elem = config->fCompInfo->fElem;
2151 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2152 iter = (char*)iter + config->fOffset;
2153 end = (char*)end + config->fOffset;
2154 for(; iter != end; iter = (char*)iter + incr ) {
2155 // Simple conversion from a 'From' on disk to a 'To' in memory.
2156 Onfile temp = (Onfile)(*(Memory*)((char*) iter));
2157 WriteCompressed(buf, &temp, elem);
2158 }
2159 return 0;
2160 }
2161 };
2162
2163 template <typename Onfile, typename Memory>
2164 struct WriteConvertBasicType<NoFactorMarker<Onfile>, Memory> {
2165 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
2166 {
2167 const TStreamerElement *elem = config->fCompInfo->fElem;
2168 const Int_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2169 iter = (char*)iter + config->fOffset;
2170 end = (char*)end + config->fOffset;
2171 for(; iter != end; iter = (char*)iter + incr ) {
2172 // Simple conversion from a 'From' on disk to a 'To' in memory.
2173 Onfile temp = (Onfile)(*(Memory*)((char*) iter));
2174 WriteCompressed(buf, &temp, elem);
2175 }
2176 return 0;
2177 }
2178 };
2179
2180 static inline Int_t ReadBase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * loopconfig, const TConfiguration *config)
2181 {
2182 // Well the implementation is non trivial since we do not have a proxy for the container of _only_ the base class. For now
2183 // punt.
2184
2185 UInt_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2186 UInt_t n = (((char*)end)-((char*)start))/incr;
2187 char **arrptr = new char*[n];
2188 UInt_t i = 0;
2189 for(void *iter = start; iter != end; iter = (char*)iter + incr, ++i ) {
2190 arrptr[i] = (char*)iter;
2191 }
2192 ((TStreamerInfo*)config->fInfo)->ReadBuffer(buf, arrptr, &(config->fCompInfo), /*first*/ 0, /*last*/ 1, /*narr*/ n, config->fOffset, 1|2 );
2193 delete [] arrptr;
2194 return 0;
2195 }
2196
2197 static inline Int_t WriteBase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * loopconfig, const TConfiguration *config)
2198 {
2199 // Well the implementation is non trivial since we do not have a proxy for the container of _only_ the base class. For now
2200 // punt.
2201
2202 UInt_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2203 UInt_t n = (((char*)end)-((char*)start))/incr;
2204 char **arrptr = new char*[n];
2205 UInt_t i = 0;
2206 for(void *iter = start; iter != end; iter = (char*)iter + incr, ++i ) {
2207 arrptr[i] = (char*)iter;
2208 }
2209 ((TStreamerInfo*)config->fInfo)->WriteBufferAux(buf, arrptr, &(config->fCompInfo), /*first*/ 0, /*last*/ 1, /*narr*/ n, config->fOffset, 1|2 );
2210 delete [] arrptr;
2211 return 0;
2212 }
2213
2214 static inline Int_t GenericRead(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * loopconfig, const TConfiguration *config)
2215 {
2216 // Well the implementation is non trivial. For now punt.
2217
2218 UInt_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2219 UInt_t n = (((char*)end)-((char*)start))/incr;
2220 char **arrptr = new char*[n];
2221 UInt_t i = 0;
2222 for(void *iter = start; iter != end; iter = (char*)iter + incr, ++i ) {
2223 arrptr[i] = (char*)iter;
2224 }
2225 ((TStreamerInfo*)config->fInfo)->ReadBuffer(buf, arrptr, &(config->fCompInfo), /*first*/ 0, /*last*/ 1, /*narr*/ n, config->fOffset, 1|2 );
2226 delete [] arrptr;
2227 return 0;
2228 }
2229
2230 static inline Int_t GenericWrite(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * loopconfig, const TConfiguration *config)
2231 {
2232 // Well the implementation is non trivial. For now punt.
2233
2234 UInt_t incr = ((TVectorLoopConfig*)loopconfig)->fIncrement;
2235 UInt_t n = (((char*)end)-((char*)start))/incr;
2236 char **arrptr = new char*[n];
2237 UInt_t i = 0;
2238 for(void *iter = start; iter != end; iter = (char*)iter + incr, ++i ) {
2239 arrptr[i] = (char*)iter;
2240 }
2241 ((TStreamerInfo*)config->fInfo)->WriteBufferAux(buf, arrptr, &(config->fCompInfo), /*first*/ 0, /*last*/ 1, n, config->fOffset, 1|2 );
2242 delete [] arrptr;
2243 return 0;
2244 }
2245
2246 template <typename T>
2247 static inline Int_t ReadCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
2248 {
2249 // Collection of numbers. Memberwise or not, it is all the same.
2250
2251 TConfigSTL *config = (TConfigSTL*)conf;
2252 UInt_t start, count;
2253 /* Version_t vers = */ buf.ReadVersion(&start, &count, config->fOldClass);
2254
2255 std::vector<T> *const vec = (std::vector<T>*)(((char*)addr)+config->fOffset);
2256 Int_t nvalues;
2257 buf.ReadInt(nvalues);
2258 vec->resize(nvalues);
2259
2260#ifdef R__VISUAL_CPLUSPLUS
2261 if (nvalues <= 0) {
2262 buf.CheckByteCount(start,count,config->fTypeName);
2263 return 0;
2264 }
2265#endif
2266 T *begin = vec->data();
2267 buf.ReadFastArray(begin, nvalues);
2268
2269 buf.CheckByteCount(start,count,config->fTypeName);
2270 return 0;
2271 }
2272
2273 template <typename T>
2274 static inline Int_t WriteCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
2275 {
2276 // Collection of numbers. Memberwise or not, it is all the same.
2277
2278 TConfigSTL *config = (TConfigSTL*)conf;
2279 UInt_t start = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
2280
2281 std::vector<T> *const vec = (std::vector<T>*)(((char*)addr)+config->fOffset);
2282 Int_t nvalues = vec->size();
2283 buf.WriteInt(nvalues);
2284
2285 T *begin = vec->data();
2286 buf.WriteFastArray(begin, nvalues);
2287
2288 buf.SetByteCount(start);
2289 return 0;
2290 }
2291
2292 static inline Int_t ReadCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
2293 {
2294 // Collection of numbers. Memberwise or not, it is all the same.
2295
2296 TConfigSTL *config = (TConfigSTL*)conf;
2297 UInt_t start, count;
2298 /* Version_t vers = */ buf.ReadVersion(&start, &count, config->fOldClass);
2299
2300 std::vector<float> *const vec = (std::vector<float>*)(((char*)addr)+config->fOffset);
2301 Int_t nvalues;
2302 buf.ReadInt(nvalues);
2303 vec->resize(nvalues);
2304
2305#ifdef R__VISUAL_CPLUSPLUS
2306 if (nvalues <= 0) {
2307 buf.CheckByteCount(start,count,config->fTypeName);
2308 return 0;
2309 }
2310#endif
2311 float *begin = vec->data();
2312 buf.ReadFastArrayFloat16(begin, nvalues);
2313
2314 buf.CheckByteCount(start,count,config->fTypeName);
2315 return 0;
2316 }
2317
2318 static inline Int_t WriteCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
2319 {
2320 // Collection of numbers. Memberwise or not, it is all the same.
2321
2322 TConfigSTL *config = (TConfigSTL*)conf;
2323 UInt_t start = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
2324
2325 std::vector<float> *const vec = (std::vector<float>*)(((char*)addr)+config->fOffset);
2326 Int_t nvalues = vec->size();
2327 buf.WriteInt(nvalues);
2328
2329 float *begin = vec->data();
2330 buf.WriteFastArrayFloat16(begin, nvalues);
2331
2332 buf.SetByteCount(start);
2333 return 0;
2334 }
2335
2336 static inline Int_t ReadCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
2337 {
2338 // Collection of numbers. Memberwise or not, it is all the same.
2339
2340 TConfigSTL *config = (TConfigSTL*)conf;
2341 UInt_t start, count;
2342 /* Version_t vers = */ buf.ReadVersion(&start, &count, config->fOldClass);
2343
2344 std::vector<double> *const vec = (std::vector<double>*)(((char*)addr)+config->fOffset);
2345 Int_t nvalues;
2346 buf.ReadInt(nvalues);
2347 vec->resize(nvalues);
2348
2349#ifdef R__VISUAL_CPLUSPLUS
2350 if (nvalues <= 0) {
2351 buf.CheckByteCount(start,count,config->fTypeName);
2352 return 0;
2353 }
2354#endif
2355 double *begin = vec->data();
2356 buf.ReadFastArrayDouble32(begin, nvalues);
2357
2358 buf.CheckByteCount(start,count,config->fTypeName);
2359 return 0;
2360 }
2361
2362 static inline Int_t WriteCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
2363 {
2364 // Collection of numbers. Memberwise or not, it is all the same.
2365
2366 TConfigSTL *config = (TConfigSTL*)conf;
2367 UInt_t start = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
2368
2369 std::vector<double> *const vec = (std::vector<double>*)(((char*)addr)+config->fOffset);
2370 Int_t nvalues = vec->size();
2371 buf.WriteInt(nvalues);
2372
2373 double *begin = vec->data();
2374 buf.WriteFastArrayDouble32(begin, nvalues);
2375
2376 buf.SetByteCount(start);
2377 return 0;
2378 }
2379
2380 template <typename From, typename To>
2382 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
2383 {
2384 // Collection of numbers. Memberwise or not, it is all the same.
2385
2386 TConfigSTL *config = (TConfigSTL*)conf;
2387 UInt_t start, count;
2388 /* Version_t vers = */ buf.ReadVersion(&start, &count, config->fOldClass);
2389
2390 std::vector<To> *const vec = (std::vector<To>*)(((char*)addr)+config->fOffset);
2391 Int_t nvalues;
2392 buf.ReadInt(nvalues);
2393 vec->resize(nvalues);
2394
2395 From *temp = new From[nvalues];
2396 buf.ReadFastArray(temp, nvalues);
2397 for(Int_t ind = 0; ind < nvalues; ++ind) {
2398 (*vec)[ind] = (To)temp[ind];
2399 }
2400 delete [] temp;
2401
2402 buf.CheckByteCount(start,count,config->fTypeName);
2403 return 0;
2404 }
2405 };
2406
2407 template <typename From, typename To>
2409 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
2410 {
2411 // Collection of numbers. Memberwise or not, it is all the same.
2412
2413 TConfigSTL *config = (TConfigSTL*)conf;
2414 UInt_t start, count;
2415 /* Version_t vers = */ buf.ReadVersion(&start, &count, config->fOldClass);
2416
2417 std::vector<To> *const vec = (std::vector<To>*)(((char*)addr)+config->fOffset);
2418 Int_t nvalues;
2419 buf.ReadInt(nvalues);
2420 vec->resize(nvalues);
2421
2422 From *temp = new From[nvalues];
2423 buf.ReadFastArrayWithNbits(temp, nvalues, 0);
2424 for(Int_t ind = 0; ind < nvalues; ++ind) {
2425 (*vec)[ind] = (To)temp[ind];
2426 }
2427 delete [] temp;
2428
2429 buf.CheckByteCount(start,count,config->fTypeName);
2430 return 0;
2431 }
2432 };
2433
2434 template <typename To>
2435 static inline Int_t ConvertCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
2436 {
2437 // Collection of numbers. Memberwise or not, it is all the same.
2438
2439 TConfigSTL *config = (TConfigSTL*)conf;
2440 UInt_t start, count;
2441 /* Version_t vers = */ buf.ReadVersion(&start, &count, config->fOldClass);
2442
2443 std::vector<To> *const vec = (std::vector<To>*)(((char*)addr)+config->fOffset);
2444 Int_t nvalues;
2445 buf.ReadInt(nvalues);
2446 vec->resize(nvalues);
2447
2448 Double32_t *temp = new Double32_t[nvalues];
2449 buf.ReadFastArrayDouble32(temp, nvalues);
2450 for(Int_t ind = 0; ind < nvalues; ++ind) {
2451 (*vec)[ind] = (To)temp[ind];
2452 }
2453 delete [] temp;
2454
2455 buf.CheckByteCount(start,count,config->fTypeName);
2456 return 0;
2457 }
2458
2459 template <typename Memory, typename Onfile>
2461 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
2462 {
2463 // Collection of numbers. Memberwise or not, it is all the same.
2464
2465 TConfigSTL *config = (TConfigSTL*)conf;
2466 UInt_t start = buf.WriteVersion( config->fInfo->IsA(), kTRUE );
2467
2468 std::vector<Memory> *const vec = (std::vector<Memory>*)(((char*)addr)+config->fOffset);
2469 Int_t nvalues = vec->size();
2470 buf.WriteInt(nvalues);
2471
2472 // We have to call WriteFastArray for proper JSON writing
2473 // So we need to convert before hand :(
2474 Onfile *temp = new Onfile[nvalues];
2475 for(Int_t ind = 0; ind < nvalues; ++ind) {
2476 temp[ind] = (Onfile)((*vec)[ind]);
2477 }
2478 buf.WriteFastArray(temp, nvalues);
2479 delete [] temp;
2480
2481 buf.SetByteCount(start, kTRUE);
2482 return 0;
2483 }
2484 };
2485 };
2486
2487 struct VectorPtrLooper : public CollectionLooper<VectorPtrLooper> {
2488 // Can not inherit/use CollectionLooper<VectorPtrLooper>, because this looper's
2489 // function do not take a `TLoopConfiguration`.
2490
2491 using LoopAction_t = Int_t (*)(TBuffer &, void *start, const void *end, const TConfiguration*);
2492
2493 template <bool kIsText>
2495 template <bool kIsText>
2497
2498 static std::unique_ptr<TStreamerInfoActions::TActionSequence>
2500 {
2501 using unique_ptr = std::unique_ptr<TStreamerInfoActions::TActionSequence>;
2502 return unique_ptr(info.GetReadMemberWiseActions(kTRUE)->CreateCopy());
2503 }
2504
2505 static std::unique_ptr<TStreamerInfoActions::TActionSequence>
2507 {
2508 using unique_ptr = std::unique_ptr<TStreamerInfoActions::TActionSequence>;
2509 return unique_ptr(info.GetWriteMemberWiseActions(kTRUE)->CreateCopy());
2510 }
2511
2512 template <Int_t (*action)(TBuffer&,void *,const TConfiguration*)>
2513 static inline Int_t LoopOverCollection(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
2514 {
2515 for(void *iter = start; iter != end; iter = (char*)iter + sizeof(void*) ) {
2516 action(buf, *(void**)iter, config);
2517 }
2518 return 0;
2519 }
2520
2521 static inline Int_t SubSequenceAction(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
2522 {
2523 auto conf = (TConfSubSequence*)config;
2524 auto actions = conf->fActions.get();
2525 // FIXME: need to update the signature of ApplySequence.
2526 buf.ApplySequenceVecPtr(*actions, start, const_cast<void*>(end));
2527 return 0;
2528 }
2529
2530 template <typename T>
2531 static inline Int_t ReadBasicType(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2532 {
2533 const Int_t offset = config->fOffset;
2534
2535 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2536 T *x = (T*)( ((char*) (*(void**)iter) ) + offset );
2537 buf >> *x;
2538 }
2539 return 0;
2540 }
2541
2542 template <typename From, typename To>
2544 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2545 {
2546 // Simple conversion from a 'From' on disk to a 'To' in memory.
2547 From temp;
2548 const Int_t offset = config->fOffset;
2549 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2550 buf >> temp;
2551 To *x = (To*)( ((char*) (*(void**)iter) ) + offset );
2552 *x = (To)temp;
2553 }
2554 return 0;
2555 }
2556 };
2557
2558 template <typename To>
2560 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2561 {
2562 // Simple conversion from a 'From' on disk to a 'To' in memory.
2563 UInt_t temp;
2564 const Int_t offset = config->fOffset;
2565 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2566 buf >> temp;
2567
2568 if ((temp & kIsReferenced) != 0) {
2569 HandleReferencedTObject(buf,*(void**)iter,config);
2570 }
2571
2572 To *x = (To*)( ((char*) (*(void**)iter) ) + offset );
2573 *x = (To)temp;
2574 }
2575 return 0;
2576 }
2577 };
2578
2579 template <typename From, typename To>
2581 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2582 {
2583 // Simple conversion from a 'From' on disk to a 'To' in memory.
2584 TConfWithFactor *conf = (TConfWithFactor *)config;
2585 From temp;
2586 const Int_t offset = config->fOffset;
2587 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2588 buf.ReadWithFactor(&temp, conf->fFactor, conf->fXmin);
2589 To *x = (To*)( ((char*) (*(void**)iter) ) + offset );
2590 *x = (To)temp;
2591 }
2592 return 0;
2593 }
2594 };
2595
2596 template <typename From, typename To>
2598 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2599 {
2600 // Simple conversion from a 'From' on disk to a 'To' in memory.
2601 TConfNoFactor *conf = (TConfNoFactor *)config;
2602 From temp;
2603 const Int_t offset = config->fOffset;
2604 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2605 buf.ReadWithNbits(&temp, conf->fNbits);
2606 To *x = (To*)( ((char*) (*(void**)iter) ) + offset );
2607 *x = (To)temp;
2608 }
2609 return 0;
2610 }
2611 };
2612
2613 template <typename T>
2614 static inline Int_t WriteBasicType(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2615 {
2616 const Int_t offset = config->fOffset;
2617
2618 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2619 T *x = (T*)( ((char*) (*(void**)iter) ) + offset );
2620 buf << *x;
2621 }
2622 return 0;
2623 }
2624
2625 template <typename To, typename From>
2627 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2628 {
2629 const Int_t offset = config->fOffset;
2630
2631 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2632 From *from = (From*)( ((char*) (*(void**)iter) ) + offset );
2633 To to = (To)(*from);
2634 buf << to;
2635 }
2636 return 0;
2637 }
2638 };
2639
2640 template <typename To, typename From>
2642 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2643 {
2644 const Int_t offset = config->fOffset;
2645 const TStreamerElement *elem = config->fCompInfo->fElem;
2646
2647 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2648 From *from = (From*)( ((char*) (*(void**)iter) ) + offset );
2649 To to = (To)(*from);
2650 WriteCompressed(buf, &to, elem);
2651 }
2652 return 0;
2653 }
2654 };
2655 template <typename To, typename From>
2657 static inline Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2658 {
2659 const Int_t offset = config->fOffset;
2660 const TStreamerElement *elem = config->fCompInfo->fElem;
2661
2662 for(; iter != end; iter = (char*)iter + sizeof(void*) ) {
2663 From *from = (From*)( ((char*) (*(void**)iter) ) + offset );
2664 To to = (To)(*from);
2665 WriteCompressed(buf, &to, elem);
2666 }
2667 return 0;
2668 }
2669 };
2670
2671 static inline Int_t ReadBase(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
2672 {
2673 // Well the implementation is non trivial since we do not have a proxy for the container of _only_ the base class. For now
2674 // punt.
2675
2676 return GenericRead(buf,start,end,config);
2677 }
2678
2679 static inline Int_t WriteBase(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
2680 {
2681 // Well the implementation is non trivial since we do not have a proxy for the container of _only_ the base class. For now
2682 // punt.
2683
2684 return GenericWrite(buf,start,end,config);
2685 }
2686
2687 static inline Int_t ReadStreamerCase(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
2688 {
2689 UInt_t pos, count;
2690 /* Version_t v = */ buf.ReadVersion(&pos, &count, config->fInfo->IsA());
2691
2692 LoopOverCollection< ReadViaExtStreamer >(buf, start, end, config);
2693
2694 buf.CheckByteCount(pos, count, config->fCompInfo->fElem->GetFullName());
2695 return 0;
2696 }
2697
2698 static inline Int_t WriteStreamerCase(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
2699 {
2700 UInt_t pos = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
2701
2702 LoopOverCollection< WriteViaExtStreamer >(buf, start, end, config);
2703
2704 buf.SetByteCount(pos, kTRUE);
2705 return 0;
2706 }
2707
2708 static inline Int_t GenericRead(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2709 {
2710 Int_t n = ( ((void**)end) - ((void**)iter) );
2711 char **arr = (char**)iter;
2712 return ((TStreamerInfo*)config->fInfo)->ReadBuffer(buf, arr, &(config->fCompInfo), /*first*/ 0, /*last*/ 1, /*narr*/ n, config->fOffset, 1|2 );
2713 }
2714
2715 static inline Int_t GenericWrite(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
2716 {
2717 Int_t n = ( ((void**)end) - ((void**)iter) );
2718 char **arr = (char**)iter;
2719 return ((TStreamerInfo*)config->fInfo)->WriteBufferAux(buf, arr, &(config->fCompInfo), /*first*/ 0, /*last*/ 1, n, config->fOffset, 1|2 );
2720 }
2721
2722 };
2723
2725 using LoopAction_t = void (*)(TBuffer&, void *, const void *, Next_t, Int_t, const TStreamerElement *elem);
2726
2727protected:
2728
2729 template <typename T>
2730 static inline void SimpleRead(TBuffer &buf, void *addr, Int_t nvalues)
2731 {
2732 buf.ReadFastArray((T*)addr, nvalues);
2733 }
2734
2735 static inline void SimpleReadFloat16(TBuffer &buf, void *addr, Int_t nvalues)
2736 {
2737 buf.ReadFastArrayFloat16((float*)addr, nvalues);
2738 }
2739
2740 static inline void SimpleReadDouble32(TBuffer &buf, void *addr, Int_t nvalues)
2741 {
2742 buf.ReadFastArrayDouble32((double*)addr, nvalues);
2743 }
2744
2745 template <typename T>
2746 static inline void SimpleWrite(TBuffer &buf, void *addr, const TStreamerElement *)
2747 {
2748 buf << *(T*)addr;
2749 }
2750
2751 static inline void SimpleWriteFloat16(TBuffer &buf, void *addr, const TStreamerElement *elem)
2752 {
2753 buf.WriteFloat16((float*)addr, const_cast<TStreamerElement*>(elem));
2754 }
2755
2756 static inline void SimpleWriteDouble32(TBuffer &buf, void *addr, const TStreamerElement *elem)
2757 {
2758 buf.WriteDouble32((double*)addr, const_cast<TStreamerElement*>(elem));
2759 }
2760
2761 template <typename T>
2762 static inline void ArrayWrite(TBuffer &buf, void *addr, Int_t nvalues, const TStreamerElement *)
2763 {
2764 buf.WriteFastArray((T*)addr, nvalues);
2765 }
2766
2767 static inline void ArrayWriteCompressed(TBuffer &buf, float *addr, Int_t nvalues, const TStreamerElement *elem)
2768 {
2769 buf.WriteFastArrayFloat16((float*)addr, nvalues, const_cast<TStreamerElement*>(elem));
2770 }
2771
2772 static inline void ArrayWriteCompressed(TBuffer &buf, double *addr, Int_t nvalues, const TStreamerElement *elem)
2773 {
2774 buf.WriteFastArrayDouble32((double*)addr, nvalues, const_cast<TStreamerElement*>(elem));
2775 }
2776
2777 template <typename T,void (*action)(TBuffer&,void *,Int_t)>
2778 static inline Int_t ReadNumericalCollection(TBuffer &buf, void *addr, const TConfiguration *conf)
2779 {
2780 // Collection of numbers. Memberwise or not, it is all the same.
2781
2782 TConfigSTL *config = (TConfigSTL*)conf;
2783 UInt_t start, count;
2784 /* Version_t vers = */ buf.ReadVersion(&start, &count, config->fOldClass);
2785
2786 TClass *newClass = config->fNewClass;
2787 TVirtualCollectionProxy *newProxy = newClass->GetCollectionProxy();
2788 TVirtualCollectionProxy::TPushPop helper( newProxy, ((char*)addr)+config->fOffset );
2789
2790 Int_t nvalues;
2791 buf.ReadInt(nvalues);
2792 void* alternative = newProxy->Allocate(nvalues,true);
2793 if (nvalues) {
2796 void *begin = &(startbuf[0]);
2797 void *end = &(endbuf[0]);
2798 config->fCreateIterators(alternative, &begin, &end, newProxy);
2799 // We can not get here with a split vector of pointer, so we can indeed assume
2800 // that actions->fConfiguration != null.
2801
2802 action(buf,begin,nvalues);
2803
2804 if (begin != &(startbuf[0])) {
2805 // assert(end != endbuf);
2806 config->fDeleteTwoIterators(begin,end);
2807 }
2808 }
2809 newProxy->Commit(alternative);
2810
2811 buf.CheckByteCount(start,count,config->fTypeName);
2812 return 0;
2813 }
2814
2815 template <void (*action)(TBuffer&, void*, const TStreamerElement*)>
2816 static inline void LoopOverCollection(TBuffer &buf, void *iter, const void *end, Next_t next, Int_t /* nvalues */, const TStreamerElement *elem)
2817 {
2818 void *addr;
2819 while( (addr = next(iter, end)) )
2820 {
2821 action(buf, addr, elem);
2822 }
2823 }
2824
2825 template <typename Memory, typename Onfile, void (*action)(TBuffer&, void*, Int_t, const TStreamerElement *elem)>
2826 static inline void ConvertLoopOverCollection(TBuffer &buf, void *iter, const void *end, Next_t next, Int_t nvalues, const TStreamerElement *elem)
2827 {
2828 Onfile *temp = new Onfile[nvalues];
2829 Int_t ind = 0;
2830 void *addr;
2831 while( (addr = next(iter, end)) )
2832 {
2833 temp[ind] = (Onfile)*(Memory*)addr;
2834 ++ind;
2835 }
2836 action(buf, temp, nvalues, elem);
2837 delete [] temp;
2838 }
2839
2840 template <typename T, void (*action)(TBuffer&, void *, const void *, Next_t, Int_t, const TStreamerElement *elem)>
2841 static inline Int_t WriteNumericalCollection(TBuffer &buf, void *addr, const TConfiguration *conf)
2842 {
2843 // Collection of numbers. Memberwise or not, it is all the same.
2844
2845 TConfigSTL *config = (TConfigSTL*)conf;
2846 UInt_t start = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
2847
2848 TClass *newClass = config->fNewClass;
2849 TVirtualCollectionProxy *newProxy = newClass->GetCollectionProxy();
2850 void *collection = ((char*)addr)+config->fOffset;
2851 TVirtualCollectionProxy::TPushPop helper( newProxy, collection);
2852
2853 Int_t nvalues = newProxy->Size();
2854 buf.WriteInt(nvalues);
2855 if (nvalues) {
2858 void *begin = &(startbuf[0]);
2859 void *end = &(endbuf[0]);
2860 config->fCreateIterators(collection, &begin, &end, newProxy);
2861
2862 action(buf, begin, end, config->fNext, nvalues, config->fCompInfo->fElem);
2863
2864 if (begin != &(startbuf[0])) {
2865 // assert(end != endbuf);
2866 config->fDeleteTwoIterators(begin, end);
2867 }
2868 }
2869 buf.SetByteCount(start);
2870 return 0;
2871 }
2872
2873public:
2874 static inline Int_t ReadCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
2875 {
2876 return ReadNumericalCollection<Float_t,SimpleReadFloat16 >(buf,addr,conf);
2877 }
2878
2879 static inline Int_t WriteCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
2880 {
2881 return WriteNumericalCollection<Float_t,LoopOverCollection<SimpleWriteFloat16> >(buf,addr,conf);
2882 }
2883
2884 static inline Int_t ReadCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
2885 {
2886 return ReadNumericalCollection<Double_t,SimpleReadDouble32 >(buf,addr,conf);
2887 }
2888
2889 static inline Int_t WriteCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
2890 {
2891 return WriteNumericalCollection<Double_t,LoopOverCollection<SimpleWriteDouble32> >(buf,addr,conf);
2892 }
2893
2894 template <typename T>
2895 static inline Int_t ReadCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
2896 {
2897 return ReadNumericalCollection<T,SimpleRead<T> >(buf,addr,conf);
2898 }
2899
2900 template <typename T>
2901 static inline Int_t WriteCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
2902 {
2903 return WriteNumericalCollection<T, LoopOverCollection<SimpleWrite<T>> >(buf,addr,conf);
2904 }
2905
2906 template <typename From, typename To>
2908 static inline void Action(TBuffer &buf, void *addr, Int_t nvalues)
2909 {
2910 From *temp = new From[nvalues];
2911 buf.ReadFastArray(temp, nvalues);
2912 To *vec = (To*)addr;
2913 for(Int_t ind = 0; ind < nvalues; ++ind) {
2914 vec[ind] = (To)temp[ind];
2915 }
2916 delete [] temp;
2917 }
2918 };
2919
2920 template <typename From, typename To>
2921 struct ConvertRead<NoFactorMarker<From>,To> {
2922 static inline void Action(TBuffer &buf, void *addr, Int_t nvalues)
2923 {
2924 From *temp = new From[nvalues];
2925 buf.ReadFastArrayWithNbits(temp, nvalues,0);
2926 To *vec = (To*)addr;
2927 for(Int_t ind = 0; ind < nvalues; ++ind) {
2928 vec[ind] = (To)temp[ind];
2929 }
2930 delete [] temp;
2931 }
2932 };
2933
2934 template <typename From, typename To>
2936 static inline void Action(TBuffer &buf, void *addr, Int_t nvalues)
2937 {
2938 From *temp = new From[nvalues];
2939 double factor,min; // needs to be initialized.
2940 buf.ReadFastArrayWithFactor(temp, nvalues, factor, min);
2941 To *vec = (To*)addr;
2942 for(Int_t ind = 0; ind < nvalues; ++ind) {
2943 vec[ind] = (To)temp[ind];
2944 }
2945 delete [] temp;
2946 }
2947 };
2948 template <typename From, typename To>
2950 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
2951 {
2952 return ReadNumericalCollection<To,ConvertRead<From,To>::Action >(buf,addr,conf);
2953 }
2954 };
2955
2956 template <typename Memory, typename Onfile>
2958 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
2959 {
2960 return WriteNumericalCollection<Memory, ConvertLoopOverCollection<Memory, Onfile, ArrayWrite<Onfile>> >(buf,addr,conf);
2961 }
2962 };
2963 template <typename Memory, typename Onfile>
2965 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
2966 {
2967 return WriteNumericalCollection<Memory, ConvertLoopOverCollection<Memory,Onfile, ArrayWriteCompressed> >(buf,addr,conf);
2968 }
2969 };
2970
2971 template <typename Memory, typename Onfile>
2973 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
2974 {
2975 return WriteNumericalCollection<Memory, ConvertLoopOverCollection<Memory,Onfile, ArrayWriteCompressed> >(buf,addr,conf);
2976 }
2977 };
2978
2979 };
2980
2981 struct GenericLooper : public CollectionLooper<GenericLooper> {
2982 using LoopAction_t = Int_t (*)(TBuffer &, void*, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration*);
2983
2984 template <bool kIsText>
2986 template <bool kIsText>
2988
2989 template <typename T>
2990 static inline Int_t ReadBasicType(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
2991 {
2992 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
2993
2994 Next_t next = loopconfig->fNext;
2995 const Int_t offset = config->fOffset;
2996
2998 void *iter = loopconfig->fCopyIterator(iterator,start);
2999 void *addr;
3000 while( (addr = next(iter,end)) ) {
3001 T *x = (T*)( ((char*)addr) + offset );
3002 buf >> *x;
3003 }
3004 if (iter != &iterator[0]) {
3005 loopconfig->fDeleteIterator(iter);
3006 }
3007 return 0;
3008 }
3009
3010 template <typename T>
3011 static inline Int_t WriteBasicType(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3012 {
3013 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3014
3015 Next_t next = loopconfig->fNext;
3016 const Int_t offset = config->fOffset;
3017
3019 void *iter = loopconfig->fCopyIterator(iterator,start);
3020 void *addr;
3021 while( (addr = next(iter,end)) ) {
3022 T *x = (T*)( ((char*)addr) + offset );
3023 buf << *x;
3024 }
3025 if (iter != &iterator[0]) {
3026 loopconfig->fDeleteIterator(iter);
3027 }
3028 return 0;
3029 }
3030
3031 template <typename To, typename From>
3033 static inline Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3034 {
3035 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3036
3037 Next_t next = loopconfig->fNext;
3038 const Int_t offset = config->fOffset;
3039
3041 void *iter = loopconfig->fCopyIterator(iterator,start);
3042 void *addr;
3043 while( (addr = next(iter,end)) ) {
3044 From *x = (From*)( ((char*)addr) + offset );
3045 To t = (To)(*x);
3046 buf << t;
3047 }
3048 if (iter != &iterator[0]) {
3049 loopconfig->fDeleteIterator(iter);
3050 }
3051 return 0;
3052 }
3053 };
3054
3055 template <Int_t (*iter_action)(TBuffer&,void *,const TConfiguration*)>
3056 static inline Int_t LoopOverCollection(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3057 {
3058 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3059
3060 // const Int_t offset = config->fOffset;
3061 Next_t next = loopconfig->fNext;
3062
3064 void *iter = loopconfig->fCopyIterator(&iterator,start);
3065 void *addr;
3066 while( (addr = next(iter,end)) ) {
3067 iter_action(buf, addr, config);
3068 }
3069 if (iter != &iterator[0]) {
3070 loopconfig->fDeleteIterator(iter);
3071 }
3072 return 0;
3073 }
3074
3075 template <typename From, typename To>
3076 struct Generic {
3077 static void ConvertAction(From *items, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3078 {
3079 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3080
3081 const Int_t offset = config->fOffset;
3082 Next_t next = loopconfig->fNext;
3083
3085 void *iter = loopconfig->fCopyIterator(&iterator,start);
3086 void *addr;
3087 while( (addr = next(iter,end)) ) {
3088 To *x = (To*)( ((char*)addr) + offset );
3089 *x = (To)(*items);
3090 ++items;
3091 }
3092 if (iter != &iterator[0]) {
3093 loopconfig->fDeleteIterator(iter);
3094 }
3095 }
3096 // ConvertAction used for writing.
3097 static void WriteConvertAction(void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config, To *items)
3098 {
3099 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3100
3101 const Int_t offset = config->fOffset;
3102 Next_t next = loopconfig->fNext;
3103
3105 void *iter = loopconfig->fCopyIterator(&iterator,start);
3106 void *addr;
3107
3108 while( (addr = next(iter,end)) ) {
3109 From *x = (From*)( ((char*)addr) + offset );
3110 *items = (To)*x;
3111 ++items;
3112 }
3113 if (iter != &iterator[0]) {
3114 loopconfig->fDeleteIterator(iter);
3115 }
3116 }
3117 };
3118
3119 template <typename From, typename To>
3120 struct Numeric {
3121 // ConvertAction used for reading.
3122 static void ConvertAction(From *items, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration * /* config */)
3123 {
3124 // The difference with ConvertAction is that we can modify the start
3125 // iterator and skip the copy. We also never have an offset.
3126
3127 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3128 Next_t next = loopconfig->fNext;
3129
3130 void *iter = start;
3131 void *addr;
3132 while( (addr = next(iter,end)) ) {
3133 To *x = (To*)(addr);
3134 *x = (To)(*items);
3135 ++items;
3136 }
3137 }
3138 // ConvertAction used for writing.
3139 static void WriteConvertAction(void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration * /* config */, To *items)
3140 {
3141 // The difference with ConvertAction is that we can modify the start
3142 // iterator and skip the copy. We also never have an offset.
3143
3144 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3145 Next_t next = loopconfig->fNext;
3146
3147 void *iter = start;
3148 void *addr;
3149 while( (addr = next(iter,end)) ) {
3150 From *x = (From*)(addr);
3151 *items = (To)*x;
3152 ++items;
3153 }
3154 }
3155 };
3156
3157 template <typename From, typename To, template <typename F, typename T> class Converter = Generic >
3159 static inline Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3160 {
3161 // Simple conversion from a 'From' on disk to a 'To' in memory.
3162
3163 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3164 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3165 Int_t nvalues = proxy->Size();
3166
3167 From *items = new From[nvalues];
3168 buf.ReadFastArray(items, nvalues);
3169 Converter<From,To>::ConvertAction(items,start,end,loopconfig,config);
3170 delete [] items;
3171 return 0;
3172 }
3173 };
3174
3175 template <typename To>
3177 static inline Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3178 {
3179 // Simple conversion from a 'From' on disk to a 'To' in memory.
3180
3181 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3182 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3183 Int_t nvalues = proxy->Size();
3184
3185 UInt_t *items_storage = new UInt_t[nvalues];
3186 UInt_t *items = items_storage;
3187
3188 const Int_t offset = config->fOffset;
3189 Next_t next = loopconfig->fNext;
3190
3192 void *iter = loopconfig->fCopyIterator(&iterator,start);
3193 void *addr;
3194 while( (addr = next(iter,end)) ) {
3195 buf >> (*items);
3196 if (((*items) & kIsReferenced) != 0) {
3197 HandleReferencedTObject(buf, addr, config);
3198 }
3199 To *x = (To*)( ((char*)addr) + offset );
3200 *x = (To)(*items);
3201 ++items;
3202 }
3203 if (iter != &iterator[0]) {
3204 loopconfig->fDeleteIterator(iter);
3205 }
3206
3207 delete [] items_storage;
3208 return 0;
3209 }
3210 };
3211
3212 template <typename From, typename To, template <typename F, typename T> class Converter >
3213 struct ConvertBasicType<WithFactorMarker<From>,To,Converter > {
3214 static inline Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3215 {
3216 // Simple conversion from a 'From' on disk to a 'To' in memory.
3217
3218 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3219 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3220 Int_t nvalues = proxy->Size();
3221
3222 TConfSTLWithFactor *conf = (TConfSTLWithFactor *)config;
3223
3224 From *items = new From[nvalues];
3225 buf.ReadFastArrayWithFactor(items, nvalues, conf->fFactor, conf->fXmin);
3226 Converter<From,To>::ConvertAction(items,start,end,loopconfig,config);
3227 delete [] items;
3228 return 0;
3229 }
3230 };
3231
3232 template <typename From, typename To, template <typename F, typename T> class Converter >
3233 struct ConvertBasicType<NoFactorMarker<From>,To,Converter > {
3234 static inline Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3235 {
3236 // Simple conversion from a 'From' on disk to a 'To' in memory.
3237
3238 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3239 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3240 Int_t nvalues = proxy->Size();
3241
3242 TConfSTLNoFactor *conf = (TConfSTLNoFactor *)config;
3243
3244 From *items = new From[nvalues];
3245 buf.ReadFastArrayWithNbits(items, nvalues, conf->fNbits);
3246 Converter<From,To>::ConvertAction(items,start,end,loopconfig,config);
3247 delete [] items;
3248 return 0;
3249 }
3250 };
3251
3252 template <typename Onfile, typename Memory, template <typename F, typename T> class Converter = Generic >
3254 static inline Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3255 {
3256 // Simple conversion from a 'From' on disk to a 'To' in memory.
3257
3258 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3259 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3260 Int_t nvalues = proxy->Size();
3261
3262 Onfile *items = new Onfile[nvalues];
3263 Converter<Memory,Onfile>::WriteConvertAction(start, end, loopconfig, config, items);
3264 buf.WriteFastArray(items, nvalues);
3265 delete [] items;
3266 return 0;
3267 }
3268 };
3269
3270 template <typename Onfile, typename Memory, template <typename F, typename T> class Converter >
3271 struct WriteConvertBasicType<WithFactorMarker<Onfile>, Memory, Converter > {
3272 static inline Int_t Action(TBuffer & /* buf */, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3273 {
3274 // Simple conversion from a 'From' on disk to a 'To' in memory.
3275
3276 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3277 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3278 Int_t nvalues = proxy->Size();
3279
3280 TConfSTLNoFactor *conf = (TConfSTLNoFactor *)config;
3281
3282 Onfile *items = new Onfile[nvalues];
3283 Converter<Memory,Onfile>::WriteConvertAction(start, end, loopconfig, config, items);
3284 R__ASSERT(false && "Not yet implemented");
3285 (void)conf;
3286 // buf.WriteFastArrayWithNbits(items, nvalues, conf->fNbits);
3287 delete [] items;
3288 return 0;
3289 }
3290 };
3291
3292 template <typename Onfile, typename Memory, template <typename F, typename T> class Converter >
3293 struct WriteConvertBasicType<NoFactorMarker<Onfile>, Memory, Converter > {
3294 static inline Int_t Action(TBuffer & /* buf */, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
3295 {
3296 // Simple conversion from a 'From' on disk to a 'To' in memory.
3297
3298 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3299 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3300 Int_t nvalues = proxy->Size();
3301
3302 TConfSTLNoFactor *conf = (TConfSTLNoFactor *)config;
3303
3304 Onfile *items = new Onfile[nvalues];
3305 Converter<Memory,Onfile>::WriteConvertAction(start, end, loopconfig, config, items);
3306 R__ASSERT(false && "Not yet implemented");
3307 (void)conf;
3308 // buf.WriteFastArrayWithNbits(items, nvalues, conf->fNbits);
3309 delete [] items;
3310 return 0;
3311 }
3312 };
3313
3314 static inline Int_t ReadBase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * loopconfig, const TConfiguration *config)
3315 {
3316 // Well the implementation is non trivial since we do not have a proxy for the container of _only_ the base class. For now
3317 // punt.
3318
3319 return GenericRead(buf,start,end,loopconfig, config);
3320 }
3321
3322 static inline Int_t WriteBase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration * loopconfig, const TConfiguration *config)
3323 {
3324 // Well the implementation is non trivial since we do not have a proxy for the container of _only_ the base class. For now
3325 // punt.
3326
3327 return GenericWrite(buf,start,end,loopconfig, config);
3328 }
3329
3330 static inline Int_t GenericRead(TBuffer &buf, void *, const void *, const TLoopConfiguration * loopconf, const TConfiguration *config)
3331 {
3332 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3333 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3334 return ((TStreamerInfo*)config->fInfo)->ReadBuffer(buf, *proxy, &(config->fCompInfo), /*first*/ 0, /*last*/ 1, /*narr*/ proxy->Size(), config->fOffset, 1|2 );
3335 }
3336
3337 static inline Int_t GenericWrite(TBuffer &buf, void *, const void *, const TLoopConfiguration * loopconf, const TConfiguration *config)
3338 {
3339 TGenericLoopConfig *loopconfig = (TGenericLoopConfig*)loopconf;
3340 TVirtualCollectionProxy *proxy = loopconfig->fProxy;
3341 return ((TStreamerInfo*)config->fInfo)->WriteBufferAux(buf, *proxy, &(config->fCompInfo), /*first*/ 0, /*last*/ 1, proxy->Size(), config->fOffset, 1|2 );
3342 }
3343
3344 template <typename T>
3345 static inline void SimpleRead(TBuffer &buf, void *addr)
3346 {
3347 buf >> *(T*)addr;
3348 }
3349
3350 static inline void SimpleReadFloat16(TBuffer &buf, void *addr)
3351 {
3352 buf.ReadWithNbits((float*)addr,12);
3353 }
3354
3355 static inline void SimpleWriteFloat16(TBuffer &buf, void *addr)
3356 {
3357 buf.WriteFloat16((float*)addr, nullptr);
3358 }
3359
3360 static inline void SimpleReadDouble32(TBuffer &buf, void *addr)
3361 {
3362 //we read a float and convert it to double
3363 Float_t afloat;
3364 buf >> afloat;
3365 *(double*)addr = (Double_t)afloat;
3366 }
3367
3368 static inline void SimpleWriteDouble32(TBuffer &buf, void *addr)
3369 {
3370 //we read a float and convert it to double
3371 Float_t afloat = (Float_t)*(double*)addr;
3372 buf << afloat;
3373 }
3374
3375 template <typename ActionHolder>
3376 static inline Int_t ReadNumericalCollection(TBuffer &buf, void *addr, const TConfiguration *conf)
3377 {
3378 // Collection of numbers. Memberwise or not, it is all the same.
3379
3380 TConfigSTL *config = (TConfigSTL*)conf;
3381 UInt_t start, count;
3382 /* Version_t vers = */ buf.ReadVersion(&start, &count, config->fOldClass);
3383
3384 TClass *newClass = config->fNewClass;
3385 TVirtualCollectionProxy *newProxy = newClass->GetCollectionProxy();
3386 TVirtualCollectionProxy::TPushPop helper( newProxy, ((char*)addr)+config->fOffset );
3387
3388 Int_t nvalues;
3389 buf.ReadInt(nvalues);
3390 void* alternative = newProxy->Allocate(nvalues,true);
3391 if (nvalues) {
3394 void *begin = &(startbuf[0]);
3395 void *end = &(endbuf[0]);
3396 config->fCreateIterators(alternative, &begin, &end, newProxy);
3397 // We can not get here with a split vector of pointer, so we can indeed assume
3398 // that actions->fConfiguration != null.
3399
3400 TGenericLoopConfig loopconf(newProxy, /* read */ kTRUE);
3401 ActionHolder::Action(buf,begin,end,&loopconf,config);
3402
3403 if (begin != &(startbuf[0])) {
3404 // assert(end != endbuf);
3405 config->fDeleteTwoIterators(begin,end);
3406 }
3407 }
3408 newProxy->Commit(alternative);
3409
3410 buf.CheckByteCount(start,count,config->fTypeName);
3411 return 0;
3412 }
3413
3414 template <typename ActionHolder>
3415 static inline Int_t WriteNumericalCollection(TBuffer &buf, void *addr, const TConfiguration *conf)
3416 {
3417 // Collection of numbers. Memberwise or not, it is all the same.
3418
3419 TConfigSTL *config = (TConfigSTL*)conf;
3420 UInt_t start = buf.WriteVersion(config->fInfo->IsA(), kTRUE);
3421
3422 TClass *newClass = config->fNewClass;
3423 TVirtualCollectionProxy *newProxy = newClass->GetCollectionProxy();
3424 void *collection = ((char*)addr)+config->fOffset;
3425 TVirtualCollectionProxy::TPushPop helper( newProxy, collection );
3426
3427 Int_t nvalues = newProxy->Size();
3428 buf.WriteInt(nvalues);
3429 if (nvalues) {
3432 void *begin = &(startbuf[0]);
3433 void *end = &(endbuf[0]);
3434 config->fCreateIterators(collection, &begin, &end, newProxy);
3435 // We can not get here with a split vector of pointer, so we can indeed assume
3436 // that actions->fConfiguration != null.
3437
3438 TGenericLoopConfig loopconf(newProxy, /* read */ kTRUE);
3439 ActionHolder::Action(buf,begin,end,&loopconf,config);
3440
3441 if (begin != &(startbuf[0])) {
3442 // assert(end != endbuf);
3443 config->fDeleteTwoIterators(begin,end);
3444 }
3445 }
3446
3447 buf.SetByteCount(start);
3448 return 0;
3449 }
3450
3451 static inline Int_t ReadCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
3452 {
3453 return ReadNumericalCollection<ConvertBasicType<NoFactorMarker<float>, float, Numeric > >(buf,addr,conf);
3454 }
3455
3456 static inline Int_t WriteCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
3457 {
3458 return WriteNumericalCollection<WriteConvertBasicType<NoFactorMarker<float>, float, Numeric > >(buf,addr,conf);
3459 }
3460
3461 static inline Int_t ReadCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
3462 {
3463 return ReadNumericalCollection<ConvertBasicType<float,double,Numeric > >(buf,addr,conf);
3464 // Could also use:
3465 // return ReadNumericalCollection<ConvertBasicType<NoFactorMarker<double>,double,Numeric > >(buf,addr,conf);
3466 }
3467
3468 static inline Int_t WriteCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
3469 {
3470 return WriteNumericalCollection<WriteConvertBasicType<float, double ,Numeric > >(buf,addr,conf);
3471 // Could also use:
3472 // return ReadNumericalCollection<WriteConvertBasicType<NoFactorMarker<double>, double, Numeric > >(buf,addr,conf);
3473 }
3474
3475 template <typename T>
3476 static inline Int_t ReadCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
3477 {
3478 //TODO: Check whether we can implement this without loading the data in
3479 // a temporary variable and whether this is noticeably faster.
3480 return ReadNumericalCollection<ConvertBasicType<T,T,Numeric > >(buf,addr,conf);
3481 }
3482
3483 template <typename T>
3484 static inline Int_t WriteCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
3485 {
3486 //TODO: Check whether we can implement this without loading the data in
3487 // a temporary variable and whether this is noticeably faster.
3488 return WriteNumericalCollection<WriteConvertBasicType<T,T,Numeric > >(buf,addr,conf);
3489 }
3490
3491 template <typename From, typename To>
3493 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
3494 {
3495 // return ReadNumericalCollection<To,ConvertRead<From,To>::Action >(buf,addr,conf);
3496 return ReadNumericalCollection<ConvertBasicType<From,To,Numeric > >(buf,addr,conf);
3497 }
3498 };
3499
3500 template <typename Memory, typename Onfile>
3502 static inline Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
3503 {
3504 // return ReadNumericalCollection<To,ConvertRead<From,To>::Action >(buf,addr,conf);
3505 return WriteNumericalCollection<WriteConvertBasicType<Memory,Onfile,Numeric > >(buf,addr,conf);
3506 }
3507 };
3508 };
3509}
3510
3511// Used in GetCollectionReadAction for the kConv cases within a collection
3512// Not to be confused with GetConvertCollectionReadAction
3513template <typename Looper, typename From>
3515{
3516 switch (newtype) {
3517 case TStreamerInfo::kBool: return TConfiguredAction( Looper::template ConvertBasicType<From,bool>::Action, conf );
3518 case TStreamerInfo::kChar: return TConfiguredAction( Looper::template ConvertBasicType<From,char>::Action, conf );
3520 case TStreamerInfo::kInt: return TConfiguredAction( Looper::template ConvertBasicType<From,Int_t>::Action, conf );
3533 default:
3534 return TConfiguredAction( Looper::GenericRead, conf );
3535 }
3536 R__ASSERT(0); // We should never be here
3537 return TConfiguredAction();
3538}
3539
3540template <class Looper>
3542{
3543 // If we ever support std::vector<Double32_t> fValues; //[...] we would get the info from the StreamerElement for fValues.
3544
3545 switch (type) {
3546 // Read basic types.
3547
3548 // Because of std::vector of bool is not backed up by an array of bool we have to converted it first.
3549 case TStreamerInfo::kBool: return TConfiguredAction( Looper::template ConvertCollectionBasicType<bool,bool>::Action, conf );
3550 case TStreamerInfo::kChar: return TConfiguredAction( Looper::template ReadCollectionBasicType<Char_t>, conf );
3551 case TStreamerInfo::kShort: return TConfiguredAction( Looper::template ReadCollectionBasicType<Short_t>,conf );
3552 case TStreamerInfo::kInt: return TConfiguredAction( Looper::template ReadCollectionBasicType<Int_t>, conf );
3553 case TStreamerInfo::kLong: return TConfiguredAction( Looper::template ReadCollectionBasicType<Long_t>, conf );
3554 case TStreamerInfo::kLong64: return TConfiguredAction( Looper::template ReadCollectionBasicType<Long64_t>, conf );
3555 case TStreamerInfo::kFloat: return TConfiguredAction( Looper::template ReadCollectionBasicType<Float_t>, conf );
3556 case TStreamerInfo::kDouble: return TConfiguredAction( Looper::template ReadCollectionBasicType<Double_t>, conf );
3557 case TStreamerInfo::kUChar: return TConfiguredAction( Looper::template ReadCollectionBasicType<UChar_t>, conf );
3558 case TStreamerInfo::kUShort: return TConfiguredAction( Looper::template ReadCollectionBasicType<UShort_t>, conf );
3559 case TStreamerInfo::kUInt: return TConfiguredAction( Looper::template ReadCollectionBasicType<UInt_t>, conf );
3560 case TStreamerInfo::kULong: return TConfiguredAction( Looper::template ReadCollectionBasicType<ULong_t>, conf );
3561 case TStreamerInfo::kULong64: return TConfiguredAction( Looper::template ReadCollectionBasicType<ULong64_t>, conf );
3562 case TStreamerInfo::kBits: Error("GetNumericCollectionReadAction","There is no support for kBits outside of a TObject."); break;
3564 TConfigSTL *alternate = new TConfSTLNoFactor(conf,12);
3565 delete conf;
3566 return TConfiguredAction( Looper::ReadCollectionFloat16, alternate );
3567 // if (element->GetFactor() != 0) {
3568 // return TConfiguredAction( Looper::template LoopOverCollection<ReadBasicType_WithFactor<float> >, new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
3569 // } else {
3570 // Int_t nbits = (Int_t)element->GetXmin();
3571 // if (!nbits) nbits = 12;
3572 // return TConfiguredAction( Looper::template LoopOverCollection<ReadBasicType_NoFactor<float> >, new TConfNoFactor(info,i,compinfo,offset,nbits) );
3573 // }
3574 }
3576 TConfigSTL *alternate = new TConfSTLNoFactor(conf,0);
3577 delete conf;
3578 return TConfiguredAction( Looper::ReadCollectionDouble32, alternate );
3579 // if (element->GetFactor() != 0) {
3580 // return TConfiguredAction( Looper::template LoopOverCollection<ReadBasicType_WithFactor<double> >, new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
3581 // } else {
3582 // Int_t nbits = (Int_t)element->GetXmin();
3583 // if (!nbits) {
3584 // return TConfiguredAction( Looper::template LoopOverCollection<ConvertBasicType<float,double> >, new TConfiguration(info,i,compinfo,offset) );
3585 // } else {
3586 // return TConfiguredAction( Looper::template LoopOverCollection<ReadBasicType_NoFactor<double> >, new TConfNoFactor(info,i,compinfo,offset,nbits) );
3587 // }
3588 // }
3589 }
3590 }
3591 Fatal("GetNumericCollectionReadAction","Is confused about %d",type);
3592 R__ASSERT(0); // We should never be here
3593 return TConfiguredAction();
3594}
3595
3596template <typename Looper, typename From>
3598{
3599 switch (newtype) {
3600 case TStreamerInfo::kBool: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,bool>::Action, conf );
3601 case TStreamerInfo::kChar: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,char>::Action, conf );
3602 case TStreamerInfo::kShort: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,short>::Action, conf );
3603 case TStreamerInfo::kInt: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,Int_t>::Action, conf );
3604 case TStreamerInfo::kLong: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,Long_t>::Action, conf );
3605 case TStreamerInfo::kLong64: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,Long64_t>::Action, conf );
3606 case TStreamerInfo::kFloat: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,float>::Action, conf );
3607 case TStreamerInfo::kFloat16: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,float>::Action, conf );
3608 case TStreamerInfo::kDouble: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,double>::Action, conf );
3609 case TStreamerInfo::kDouble32:return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,double>::Action, conf );
3610 case TStreamerInfo::kUChar: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,UChar_t>::Action, conf );
3611 case TStreamerInfo::kUShort: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,UShort_t>::Action, conf );
3612 case TStreamerInfo::kUInt: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,UInt_t>::Action, conf );
3613 case TStreamerInfo::kULong: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,ULong_t>::Action, conf );
3614 case TStreamerInfo::kULong64: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,ULong64_t>::Action, conf );
3615 case TStreamerInfo::kBits: return TConfiguredAction( Looper::template ConvertCollectionBasicType<From,UInt_t>::Action, conf );
3616 default:
3617 break;
3618 }
3619 Error("GetConvertCollectionReadActionFrom", "UNEXPECTED: newtype == %d", newtype);
3620 R__ASSERT(0); // We should never be here
3621 return TConfiguredAction();
3622}
3623
3624// Used in AddReadAction to implement the kSTL cases
3625// Not to be confused with GetCollectionReadConvertAction
3626// nor with GetConvertCollectionReadActionFrom (used to implement this function)
3627template <typename Looper>
3629{
3630 switch (oldtype) {
3632 return GetConvertCollectionReadActionFrom<Looper,Bool_t>(newtype, conf );
3634 return GetConvertCollectionReadActionFrom<Looper,Char_t>(newtype, conf );
3636 return GetConvertCollectionReadActionFrom<Looper,Short_t>(newtype, conf );
3638 return GetConvertCollectionReadActionFrom<Looper,Int_t>(newtype, conf );
3640 return GetConvertCollectionReadActionFrom<Looper,Long_t>(newtype, conf );
3642 return GetConvertCollectionReadActionFrom<Looper,Long64_t>(newtype, conf );
3644 return GetConvertCollectionReadActionFrom<Looper,Float_t>( newtype, conf );
3646 return GetConvertCollectionReadActionFrom<Looper,Double_t>(newtype, conf );
3648 return GetConvertCollectionReadActionFrom<Looper,UChar_t>(newtype, conf );
3650 return GetConvertCollectionReadActionFrom<Looper,UShort_t>(newtype, conf );
3652 return GetConvertCollectionReadActionFrom<Looper,UInt_t>(newtype, conf );
3654 return GetConvertCollectionReadActionFrom<Looper,ULong_t>(newtype, conf );
3656 return GetConvertCollectionReadActionFrom<Looper,ULong64_t>(newtype, conf );
3658 return GetConvertCollectionReadActionFrom<Looper,NoFactorMarker<Float16_t> >( newtype, conf );
3660 return GetConvertCollectionReadActionFrom<Looper,NoFactorMarker<Double32_t> >( newtype, conf );
3662 Error("GetConvertCollectionReadAction","There is no support for kBits outside of a TObject.");
3663 break;
3664 default:
3665 break;
3666 }
3667 Error("GetConvertCollectionReadAction", "UNEXPECTED: oldtype == %d", oldtype);
3668 R__ASSERT(0); // We should never be here
3669 return TConfiguredAction();
3670}
3671
3672template <class Looper>
3673static TConfiguredAction
3676{
3677 switch (type) {
3678 // Read basic types.
3679 case TStreamerInfo::kBool: return TConfiguredAction( Looper::template ReadBasicType<Bool_t>, new TConfiguration(info,i,compinfo,offset) );
3680 case TStreamerInfo::kChar: return TConfiguredAction( Looper::template ReadBasicType<Char_t>, new TConfiguration(info,i,compinfo,offset) );
3681 case TStreamerInfo::kShort: return TConfiguredAction( Looper::template ReadBasicType<Short_t>,new TConfiguration(info,i,compinfo,offset) );
3682 case TStreamerInfo::kInt: return TConfiguredAction( Looper::template ReadBasicType<Int_t>, new TConfiguration(info,i,compinfo,offset) );
3683 case TStreamerInfo::kLong: return TConfiguredAction( Looper::template ReadBasicType<Long_t>, new TConfiguration(info,i,compinfo,offset) );
3684 case TStreamerInfo::kLong64: return TConfiguredAction( Looper::template ReadBasicType<Long64_t>, new TConfiguration(info,i,compinfo,offset) );
3685 case TStreamerInfo::kFloat: return TConfiguredAction( Looper::template ReadBasicType<Float_t>, new TConfiguration(info,i,compinfo,offset) );
3686 case TStreamerInfo::kDouble: return TConfiguredAction( Looper::template ReadBasicType<Double_t>, new TConfiguration(info,i,compinfo,offset) );
3687 case TStreamerInfo::kUChar: return TConfiguredAction( Looper::template ReadBasicType<UChar_t>, new TConfiguration(info,i,compinfo,offset) );
3688 case TStreamerInfo::kUShort: return TConfiguredAction( Looper::template ReadBasicType<UShort_t>, new TConfiguration(info,i,compinfo,offset) );
3689 case TStreamerInfo::kUInt: return TConfiguredAction( Looper::template ReadBasicType<UInt_t>, new TConfiguration(info,i,compinfo,offset) );
3690 case TStreamerInfo::kULong: return TConfiguredAction( Looper::template ReadBasicType<ULong_t>, new TConfiguration(info,i,compinfo,offset) );
3691 case TStreamerInfo::kULong64: return TConfiguredAction( Looper::template ReadBasicType<ULong64_t>, new TConfiguration(info,i,compinfo,offset) );
3692 case TStreamerInfo::kBits: return TConfiguredAction( Looper::template LoopOverCollection<TStreamerInfoActions::ReadBasicType<BitsMarker> > , new TBitsConfiguration(info,i,compinfo,offset) );
3694 if (element->GetFactor() != 0) {
3695 return TConfiguredAction( Looper::template LoopOverCollection<ReadBasicType_WithFactor<float> >, new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
3696 } else {
3697 Int_t nbits = (Int_t)element->GetXmin();
3698 if (!nbits) nbits = 12;
3699 return TConfiguredAction( Looper::template LoopOverCollection<ReadBasicType_NoFactor<float> >, new TConfNoFactor(info,i,compinfo,offset,nbits) );
3700 }
3701 }
3703 if (element->GetFactor() != 0) {
3704 return TConfiguredAction( Looper::template LoopOverCollection<ReadBasicType_WithFactor<double> >, new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
3705 } else {
3706 Int_t nbits = (Int_t)element->GetXmin();
3707 if (!nbits) {
3708 return TConfiguredAction( Looper::template LoopOverCollection<ConvertBasicType<float,double>::Action >, new TConfiguration(info,i,compinfo,offset) );
3709 } else {
3710 return TConfiguredAction( Looper::template LoopOverCollection<ReadBasicType_NoFactor<double> >, new TConfNoFactor(info,i,compinfo,offset,nbits) );
3711 }
3712 }
3713 }
3715 return TConfiguredAction( Looper::template LoopOverCollection<ReadTNamed >, new TConfiguration(info, i, compinfo, offset) );
3716 // Idea: We should calculate the CanIgnoreTObjectStreamer here and avoid calling the
3717 // Streamer alltogether.
3719 return TConfiguredAction( Looper::template LoopOverCollection<ReadTObject >, new TConfiguration(info, i, compinfo,offset) );
3721 return TConfiguredAction( Looper::template LoopOverCollection<ReadTString >, new TConfiguration(info, i, compinfo,offset) );
3725 case TStreamerInfo::kSTL: return TConfiguredAction( Looper::GenericRead, new TGenericConfiguration(info, i, compinfo) );
3726 case TStreamerInfo::kBase: {
3727 TStreamerBase *baseEl = dynamic_cast<TStreamerBase*>(element);
3728 if (baseEl) {
3729 auto baseinfo = (TStreamerInfo *)baseEl->GetBaseStreamerInfo();
3730 assert(baseinfo);
3731 auto baseActions = Looper::CreateReadActionSequence(*baseinfo, loopConfig);
3732 baseActions->AddToOffset(baseEl->GetOffset());
3733 return TConfiguredAction( Looper::SubSequenceAction, new TConfSubSequence(info, i, compinfo, 0, std::move(baseActions)));
3734
3735 } else
3736 return TConfiguredAction( Looper::ReadBase, new TGenericConfiguration(info, i, compinfo) );
3737 }
3740 bool isPtrPtr = (strstr(compinfo->fElem->GetTypeName(), "**") != 0);
3741 return TConfiguredAction(Looper::template ReadStreamerLoop<false>::Action,
3742 new TConfStreamerLoop(info, i, compinfo, offset, isPtrPtr));
3743 }
3745 if (info->GetOldVersion() >= 3)
3746 return TConfiguredAction( Looper::ReadStreamerCase, new TGenericConfiguration(info, i, compinfo) );
3747 else
3748 return TConfiguredAction( Looper::GenericRead, new TGenericConfiguration(info, i, compinfo) );
3750 if (compinfo->fStreamer)
3751 return TConfiguredAction( Looper::template LoopOverCollection<ReadViaExtStreamer >, new TConfiguration(info, i, compinfo,offset) );
3752 else {
3753 if (compinfo->fNewClass && compinfo->fNewClass->HasDirectStreamerInfoUse())
3754 return TConfiguredAction( Looper::template LoopOverCollection<ReadViaClassBuffer>,
3755 new TConfObject(info, i, compinfo, compinfo->fOffset, compinfo->fClass, compinfo->fNewClass) );
3756 else if (compinfo->fClass && compinfo->fClass->HasDirectStreamerInfoUse())
3757 return TConfiguredAction( Looper::template LoopOverCollection<ReadViaClassBuffer>,
3758 new TConfObject(info, i, compinfo, compinfo->fOffset, compinfo->fClass, nullptr) );
3759 else // Use the slower path for unusual cases
3760 return TConfiguredAction( Looper::GenericRead, new TGenericConfiguration(info, i, compinfo) );
3761 }
3762
3763 // Conversions.
3765 return GetCollectionReadConvertAction<Looper,Bool_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3767 return GetCollectionReadConvertAction<Looper,Char_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3769 return GetCollectionReadConvertAction<Looper,Short_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3771 return GetCollectionReadConvertAction<Looper,Int_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3773 return GetCollectionReadConvertAction<Looper,Long_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3775 return GetCollectionReadConvertAction<Looper,Long64_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3777 return GetCollectionReadConvertAction<Looper,Float_t>( element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3779 return GetCollectionReadConvertAction<Looper,Double_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3781 return GetCollectionReadConvertAction<Looper,UChar_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3783 return GetCollectionReadConvertAction<Looper,UShort_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3785 return GetCollectionReadConvertAction<Looper,UInt_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3787 return GetCollectionReadConvertAction<Looper,ULong_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3789 return GetCollectionReadConvertAction<Looper,ULong64_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3791 return GetCollectionReadConvertAction<Looper,BitsMarker>(element->GetNewType(), new TBitsConfiguration(info,i,compinfo,offset) );
3793 if (element->GetFactor() != 0) {
3794 return GetCollectionReadConvertAction<Looper,WithFactorMarker<float> >(element->GetNewType(), new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
3795 } else {
3796 Int_t nbits = (Int_t)element->GetXmin();
3797 if (!nbits) nbits = 12;
3798 return GetCollectionReadConvertAction<Looper,NoFactorMarker<float> >(element->GetNewType(), new TConfNoFactor(info,i,compinfo,offset,nbits) );
3799 }
3800 }
3802 if (element->GetFactor() != 0) {
3803 return GetCollectionReadConvertAction<Looper,WithFactorMarker<double> >(element->GetNewType(), new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
3804 } else {
3805 Int_t nbits = (Int_t)element->GetXmin();
3806 if (!nbits) {
3807 return GetCollectionReadConvertAction<Looper,Float_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3808 } else {
3809 return GetCollectionReadConvertAction<Looper,NoFactorMarker<double> >(element->GetNewType(), new TConfNoFactor(info,i,compinfo,offset,nbits) );
3810 }
3811 }
3812 }
3813 default:
3814 return TConfiguredAction( Looper::GenericRead, new TGenericConfiguration(info,i,compinfo) );
3815 }
3816 R__ASSERT(0); // We should never be here
3817 return TConfiguredAction();
3818}
3819
3820template <typename Looper, typename From>
3822{
3823 switch (onfileType) {
3824 case TStreamerInfo::kBool: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,bool>::Action, conf );
3825 case TStreamerInfo::kChar: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,char>::Action, conf );
3826 case TStreamerInfo::kShort: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,short>::Action, conf );
3827 case TStreamerInfo::kInt: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,Int_t>::Action, conf );
3828 case TStreamerInfo::kLong: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,Long_t>::Action, conf );
3829 case TStreamerInfo::kLong64: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,Long64_t>::Action, conf );
3830 case TStreamerInfo::kFloat: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,float>::Action, conf );
3831 case TStreamerInfo::kDouble: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,double>::Action, conf );
3832 case TStreamerInfo::kUChar: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,UChar_t>::Action, conf );
3833 case TStreamerInfo::kUShort: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,UShort_t>::Action, conf );
3834 case TStreamerInfo::kUInt: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,UInt_t>::Action, conf );
3835 case TStreamerInfo::kULong: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,ULong_t>::Action, conf );
3836 case TStreamerInfo::kULong64: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,ULong64_t>::Action, conf );
3837 case TStreamerInfo::kBits: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,UInt_t>::Action, conf );
3838
3839 // Supporting this requires adding TBuffer::WiteFastArrayWithNbits
3840 // and the proper struct WriteConvertCollectionBasicType<Memory, NoFactorMarker<Onfile>> here
3842 Error("GetConvertCollectionWriteActionFrom", "Write Conversion to Float16_t not yet supported");
3843 return TConfiguredAction();
3844 // return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,NoFactorMarker<Float16_t>>::Action, conf );
3846 Error("GetConvertCollectionWriteActionFrom", "Write Conversion to Double32_t not yet supported");
3847 return TConfiguredAction();
3848 // return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<From,NoFactorMarker<Double32_t>>::Action, conf );
3849 default:
3850 break;
3851 }
3852 Error("GetConvertCollectionWriteActionFrom", "UNEXPECTED: onfileType/oldtype == %d", onfileType);
3853 R__ASSERT(0); // We should never be here
3854 return TConfiguredAction();
3855}
3856
3857// Used in to implement the kSTL case
3858// Not to be confused with GetCollectionWriteConvertAction
3859// nor with GetConvertCollectionWriteActionFrom (used to implement this function)
3860template <typename Looper>
3862{
3863 switch (memoryType) {
3865 return GetConvertCollectionWriteActionFrom<Looper,Bool_t>(onfileType, conf );
3867 return GetConvertCollectionWriteActionFrom<Looper,Char_t>(onfileType, conf );
3869 return GetConvertCollectionWriteActionFrom<Looper,Short_t>(onfileType, conf );
3871 return GetConvertCollectionWriteActionFrom<Looper,Int_t>(onfileType, conf );
3873 return GetConvertCollectionWriteActionFrom<Looper,Long_t>(onfileType, conf );
3875 return GetConvertCollectionWriteActionFrom<Looper,Long64_t>(onfileType, conf );
3877 return GetConvertCollectionWriteActionFrom<Looper,Float_t>(onfileType, conf );
3879 return GetConvertCollectionWriteActionFrom<Looper,Double_t>(onfileType, conf );
3881 return GetConvertCollectionWriteActionFrom<Looper,UChar_t>(onfileType, conf );
3883 return GetConvertCollectionWriteActionFrom<Looper,UShort_t>(onfileType, conf );
3885 return GetConvertCollectionWriteActionFrom<Looper,UInt_t>(onfileType, conf );
3887 return GetConvertCollectionWriteActionFrom<Looper,ULong_t>(onfileType, conf );
3889 return GetConvertCollectionWriteActionFrom<Looper,ULong64_t>(onfileType, conf );
3891 return GetConvertCollectionWriteActionFrom<Looper,Float16_t>(onfileType, conf );
3893 return GetConvertCollectionWriteActionFrom<Looper,Double32_t>(onfileType, conf );
3895 Error("GetConvertCollectionWriteActionFrom","There is no support for kBits outside of a TObject.");
3896 break;
3897 default:
3898 break;
3899 }
3900 Error("GetConvertCollectionWriteActionFrom", "UNEXPECTED: memoryType/newype == %d", memoryType);
3901 R__ASSERT(0); // We should never be here
3902 return TConfiguredAction();
3903}
3904
3905// Used in GetCollectionWriteAction for the kConv cases within a collection
3906// Not to be confused with GetConvertCollectionWriteAction
3907// Note the read and write version could be merged (using yet another template parameter)
3908template <typename Looper, typename Onfile>
3910{
3911 switch (newtype) {
3928 default:
3929 return TConfiguredAction( Looper::GenericRead, conf );
3930 }
3931 R__ASSERT(0); // We should never be here
3932 return TConfiguredAction();
3933}
3934
3935template <class Looper>
3936static TConfiguredAction
3939{
3940 switch (type) {
3941 // write basic types
3942 case TStreamerInfo::kBool: return TConfiguredAction( Looper::template WriteBasicType<Bool_t>, new TConfiguration(info,i,compinfo,offset) );
3943 case TStreamerInfo::kChar: return TConfiguredAction( Looper::template WriteBasicType<Char_t>, new TConfiguration(info,i,compinfo,offset) );
3944 case TStreamerInfo::kShort: return TConfiguredAction( Looper::template WriteBasicType<Short_t>, new TConfiguration(info,i,compinfo,offset) );
3945 case TStreamerInfo::kInt: return TConfiguredAction( Looper::template WriteBasicType<Int_t>, new TConfiguration(info,i,compinfo,offset) );
3946 case TStreamerInfo::kLong: return TConfiguredAction( Looper::template WriteBasicType<Long_t>, new TConfiguration(info,i,compinfo,offset) );
3947 case TStreamerInfo::kLong64: return TConfiguredAction( Looper::template WriteBasicType<Long64_t>, new TConfiguration(info,i,compinfo,offset) );
3948 case TStreamerInfo::kFloat: return TConfiguredAction( Looper::template WriteBasicType<Float_t>, new TConfiguration(info,i,compinfo,offset) );
3949 case TStreamerInfo::kDouble: return TConfiguredAction( Looper::template WriteBasicType<Double_t>, new TConfiguration(info,i,compinfo,offset) );
3950 case TStreamerInfo::kUChar: return TConfiguredAction( Looper::template WriteBasicType<UChar_t>, new TConfiguration(info,i,compinfo,offset) );
3951 case TStreamerInfo::kUShort: return TConfiguredAction( Looper::template WriteBasicType<UShort_t>, new TConfiguration(info,i,compinfo,offset) );
3952 case TStreamerInfo::kUInt: return TConfiguredAction( Looper::template WriteBasicType<UInt_t>, new TConfiguration(info,i,compinfo,offset) );
3953 case TStreamerInfo::kULong: return TConfiguredAction( Looper::template WriteBasicType<ULong_t>, new TConfiguration(info,i,compinfo,offset) );
3954 case TStreamerInfo::kULong64: return TConfiguredAction( Looper::template WriteBasicType<ULong64_t>,new TConfiguration(info,i,compinfo,offset) );
3955 // the simple type missing are kBits and kCounter.
3956
3957 // Handling of the error case where we are asked to write a missing data member.
3959 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<Bool_t>>, new TConfiguration(info,i,compinfo,offset) );
3961 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<Char_t>>, new TConfiguration(info,i,compinfo,offset) );
3963 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<Short_t>>, new TConfiguration(info,i,compinfo,offset) );
3965 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<Int_t>>, new TConfiguration(info,i,compinfo,offset) );
3967 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<Long_t>>, new TConfiguration(info,i,compinfo,offset) );
3969 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<Long64_t>>, new TConfiguration(info,i,compinfo,offset) );
3971 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<Float_t>>, new TConfiguration(info,i,compinfo,offset) );
3973 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<Double_t>>, new TConfiguration(info,i,compinfo,offset) );
3975 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<UChar_t>>, new TConfiguration(info,i,compinfo,offset) );
3977 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<UShort_t>>, new TConfiguration(info,i,compinfo,offset) );
3979 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<UInt_t>>, new TConfiguration(info,i,compinfo,offset) );
3981 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<ULong_t>>, new TConfiguration(info,i,compinfo,offset) );
3983 return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicZero<ULong64_t>>, new TConfiguration(info,i,compinfo,offset) );
3984
3985 // Conversions.
3987 return GetCollectionWriteConvertAction<Looper,Bool_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3989 return GetCollectionWriteConvertAction<Looper,Char_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3991 return GetCollectionWriteConvertAction<Looper,Short_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3993 return GetCollectionWriteConvertAction<Looper,Int_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3995 return GetCollectionWriteConvertAction<Looper,Long_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3997 return GetCollectionWriteConvertAction<Looper,Long64_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
3999 return GetCollectionWriteConvertAction<Looper,Float_t>( element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
4001 return GetCollectionWriteConvertAction<Looper,Double_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
4003 return GetCollectionWriteConvertAction<Looper,UChar_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
4005 return GetCollectionWriteConvertAction<Looper,UShort_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
4007 return GetCollectionWriteConvertAction<Looper,UInt_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
4009 return GetCollectionWriteConvertAction<Looper,ULong_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
4011 return GetCollectionWriteConvertAction<Looper,ULong64_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
4012#ifdef NOT_YET
4013 /* The conversion writing acceleration was not yet written for kBits */
4015 return GetCollectionWriteConvertAction<Looper,BitsMarker>(element->GetNewType(), new TBitsConfiguration(info,i,compinfo,offset) );
4016#endif
4018 if (element->GetFactor() != 0) {
4019 return GetCollectionWriteConvertAction<Looper,WithFactorMarker<float> >(element->GetNewType(), new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
4020 } else {
4021 Int_t nbits = (Int_t)element->GetXmin();
4022 if (!nbits) nbits = 12;
4023 return GetCollectionWriteConvertAction<Looper,NoFactorMarker<float> >(element->GetNewType(), new TConfNoFactor(info,i,compinfo,offset,nbits) );
4024 }
4025 break;
4026 }
4028 if (element->GetFactor() != 0) {
4029 return GetCollectionWriteConvertAction<Looper,WithFactorMarker<double> >(element->GetNewType(), new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
4030 } else {
4031 Int_t nbits = (Int_t)element->GetXmin();
4032 if (!nbits) {
4033 return GetCollectionWriteConvertAction<Looper,Float_t>(element->GetNewType(), new TConfiguration(info,i,compinfo,offset) );
4034 } else {
4035 return GetCollectionWriteConvertAction<Looper,NoFactorMarker<double> >(element->GetNewType(), new TConfNoFactor(info,i,compinfo,offset,nbits) );
4036 }
4037 }
4038 break;
4039 }
4040 case TStreamerInfo::kTNamed: return TConfiguredAction( Looper::template LoopOverCollection<WriteTNamed >, new TConfiguration(info,i,compinfo,offset) );
4041 // Idea: We should calculate the CanIgnoreTObjectStreamer here and avoid calling the
4042 // Streamer alltogether.
4043 case TStreamerInfo::kTObject: return TConfiguredAction( Looper::template LoopOverCollection<WriteTObject >, new TConfiguration(info,i,compinfo,offset) );
4044 case TStreamerInfo::kTString: return TConfiguredAction( Looper::template LoopOverCollection<WriteTString >, new TConfiguration(info,i,compinfo,offset) );
4045 case TStreamerInfo::kBase: {
4046 TStreamerBase *baseEl = dynamic_cast<TStreamerBase*>(element);
4047 if (baseEl) {
4048 auto baseinfo = (TStreamerInfo *)baseEl->GetBaseStreamerInfo();
4049 assert(baseinfo);
4050 auto baseActions = Looper::CreateWriteActionSequence(*baseinfo, loopConfig);
4051 baseActions->AddToOffset(baseEl->GetOffset());
4052 return TConfiguredAction( Looper::SubSequenceAction, new TConfSubSequence(info, i, compinfo, 0, std::move(baseActions)));
4053
4054 } else
4055 return TConfiguredAction( Looper::WriteBase, new TGenericConfiguration(info, i, compinfo) );
4056 }
4059 bool isPtrPtr = (strstr(compinfo->fElem->GetTypeName(), "**") != 0);
4060 return TConfiguredAction(Looper::template WriteStreamerLoop<false>::Action,
4061 new TConfStreamerLoop(info, i, compinfo, offset, isPtrPtr));
4062 }
4064 if (info->GetOldVersion() >= 3)
4065 return TConfiguredAction( Looper::WriteStreamerCase, new TGenericConfiguration(info, i, compinfo) );
4066 else
4067 return TConfiguredAction( Looper::GenericWrite, new TGenericConfiguration(info, i, compinfo) );
4069 if (compinfo->fStreamer)
4070 return TConfiguredAction( Looper::template LoopOverCollection<WriteViaExtStreamer >, new TConfiguration(info, i, compinfo,offset) );
4071 else {
4072 if (compinfo->fNewClass && compinfo->fNewClass->HasDirectStreamerInfoUse())
4073 return TConfiguredAction( Looper::template LoopOverCollection<WriteViaClassBuffer>,
4074 new TConfObject(info, i, compinfo, compinfo->fOffset, compinfo->fClass, compinfo->fNewClass) );
4075 else if (compinfo->fClass && compinfo->fClass->HasDirectStreamerInfoUse())
4076 return TConfiguredAction( Looper::template LoopOverCollection<WriteViaClassBuffer>,
4077 new TConfObject(info, i, compinfo, compinfo->fOffset, compinfo->fClass, nullptr) );
4078 else // Use the slower path for unusual cases
4079 return TConfiguredAction( Looper::GenericWrite, new TGenericConfiguration(info, i, compinfo) );
4080 }
4081 default:
4082 return TConfiguredAction( Looper::GenericWrite, new TConfiguration(info,i,compinfo,0 /* 0 because we call the legacy code */) );
4083 }
4084 R__ASSERT(0); // We should never be here
4085 return TConfiguredAction();
4086}
4087
4088template <class Looper>
4090{
4091 // If we ever support std::vector<Double32_t> fValues; //[...] we would get the info from the StreamerElement for fValues.
4092
4093 switch (type) {
4094 // Write basic types.
4095 // Because of std::vector of bool is not backed up by an array of bool we have to converted it first.
4096 case TStreamerInfo::kBool: return TConfiguredAction( Looper::template WriteConvertCollectionBasicType<bool,bool>::Action, conf );
4097 case TStreamerInfo::kChar: return TConfiguredAction( Looper::template WriteCollectionBasicType<Char_t>, conf );
4098 case TStreamerInfo::kShort: return TConfiguredAction( Looper::template WriteCollectionBasicType<Short_t>,conf );
4099 case TStreamerInfo::kInt: return TConfiguredAction( Looper::template WriteCollectionBasicType<Int_t>, conf );
4100 case TStreamerInfo::kLong: return TConfiguredAction( Looper::template WriteCollectionBasicType<Long_t>, conf );
4101 case TStreamerInfo::kLong64: return TConfiguredAction( Looper::template WriteCollectionBasicType<Long64_t>, conf );
4102 case TStreamerInfo::kFloat: return TConfiguredAction( Looper::template WriteCollectionBasicType<Float_t>, conf );
4103 case TStreamerInfo::kDouble: return TConfiguredAction( Looper::template WriteCollectionBasicType<Double_t>, conf );
4104 case TStreamerInfo::kUChar: return TConfiguredAction( Looper::template WriteCollectionBasicType<UChar_t>, conf );
4105 case TStreamerInfo::kUShort: return TConfiguredAction( Looper::template WriteCollectionBasicType<UShort_t>, conf );
4106 case TStreamerInfo::kUInt: return TConfiguredAction( Looper::template WriteCollectionBasicType<UInt_t>, conf );
4107 case TStreamerInfo::kULong: return TConfiguredAction( Looper::template WriteCollectionBasicType<ULong_t>, conf );
4108 case TStreamerInfo::kULong64: return TConfiguredAction( Looper::template WriteCollectionBasicType<ULong64_t>, conf );
4109 case TStreamerInfo::kBits: Error("GetNumericCollectionWriteAction","There is no support for kBits outside of a TObject."); break;
4111 TConfigSTL *alternate = new TConfSTLNoFactor(conf,12);
4112 delete conf;
4113 return TConfiguredAction( Looper::WriteCollectionFloat16, alternate );
4114 // if (element->GetFactor() != 0) {
4115 // return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicType_WithFactor<float> >, new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
4116 // } else {
4117 // Int_t nbits = (Int_t)element->GetXmin();
4118 // if (!nbits) nbits = 12;
4119 // return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicType_NoFactor<float> >, new TConfNoFactor(info,i,compinfo,offset,nbits) );
4120 // }
4121 }
4123 TConfigSTL *alternate = new TConfSTLNoFactor(conf,0);
4124 delete conf;
4125 return TConfiguredAction( Looper::WriteCollectionDouble32, alternate );
4126 // if (element->GetFactor() != 0) {
4127 // return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicType_WithFactor<double> >, new TConfWithFactor(info,i,compinfo,offset,element->GetFactor(),element->GetXmin()) );
4128 // } else {
4129 // Int_t nbits = (Int_t)element->GetXmin();
4130 // if (!nbits) {
4131 // return TConfiguredAction( Looper::template LoopOverCollection<ConvertBasicType<float,double> >, new TConfiguration(info,i,compinfo,offset) );
4132 // } else {
4133 // return TConfiguredAction( Looper::template LoopOverCollection<WriteBasicType_NoFactor<double> >, new TConfNoFactor(info,i,compinfo,offset,nbits) );
4134 // }
4135 // }
4136 }
4137 }
4138 Fatal("GetNumericCollectionWriteAction","Is confused about %d",type);
4139 R__ASSERT(0); // We should never be here
4140 return TConfiguredAction();
4141}
4142
4143////////////////////////////////////////////////////////////////////////////////
4144/// loop on the TStreamerElement list
4145/// regroup members with same type
4146/// Store predigested information into local arrays. This saves a huge amount
4147/// of time compared to an explicit iteration on all elements.
4148
4150{
4151 if (IsCompiled()) {
4152 //Error("Compile","can only be called once; this first call generates both the optimized and memberwise actions.");
4153 return;
4154 }
4156
4157 // fprintf(stderr,"Running Compile for %s %d %d req=%d,%d\n",GetName(),fClassVersion,fOptimized,CanOptimize(),TestBit(kCannotOptimize));
4158
4159 // if (IsCompiled() && (!fOptimized || (CanOptimize() && !TestBit(kCannotOptimize)))) return;
4161 fNdata = 0;
4162 fNfulldata = 0;
4163
4164 TObjArray* infos = (TObjArray*) gROOT->GetListOfStreamerInfo();
4165 if (fNumber < 0) {
4166 ++fgCount;
4167 fNumber = fgCount;
4168 }
4169 if (fNumber >= infos->GetSize()) {
4170 infos->AddAtAndExpand(this, fNumber);
4171 } else {
4172 if (!infos->At(fNumber)) {
4173 infos->AddAt(this, fNumber);
4174 }
4175 }
4176
4177 assert(fComp == 0 && fCompFull == 0 && fCompOpt == 0);
4178
4179
4180 Int_t ndata = fElements->GetEntriesFast();
4181
4182
4185
4188
4191
4192 if (fReadText) fReadText->fActions.clear();
4193 else fReadText = new TStreamerInfoActions::TActionSequence(this,ndata);
4194
4197
4200
4203
4204 if (fWriteText) fWriteText->fActions.clear();
4206
4207 if (!ndata) {
4208 // This may be the case for empty classes (e.g., TAtt3D).
4209 // We still need to properly set the size of emulated classes (i.e. add the virtual table)
4211 fSize = sizeof(TStreamerInfo*);
4212 }
4213 fComp = new TCompInfo[1];
4214 fCompFull = new TCompInfo*[1];
4215 fCompOpt = new TCompInfo*[1];
4216 fCompOpt[0] = fCompFull[0] = &(fComp[0]);
4217 fAlignment = 1;
4218 SetIsCompiled();
4219 return;
4220 }
4221
4222 // At most half of the elements can be used to hold optimized versions.
4223 // We use the bottom to hold the optimized-into elements and the non-optimized elements
4224 // and the top to hold the original copy of the optimized out elements.
4225 fNslots = ndata + ndata/2 + 1;
4226 Int_t optiOut = 0;
4227
4228 fComp = new TCompInfo[fNslots];
4229 fCompFull = new TCompInfo*[ndata];
4230 fCompOpt = new TCompInfo*[ndata];
4231
4232 TStreamerElement* element;
4233 TStreamerElement* previous = 0;
4234 Int_t keep = -1;
4235 Int_t i;
4236
4237 if (!CanOptimize()) {
4239 }
4240
4241 Bool_t isOptimized = kFALSE;
4242 Bool_t previousOptimized = kFALSE;
4243
4244 for (i = 0; i < ndata; ++i) {
4245 element = (TStreamerElement*) fElements->At(i);
4246 if (!element) {
4247 break;
4248 }
4249
4250 Int_t asize = element->GetSize();
4251 if (element->GetArrayLength()) {
4252 asize /= element->GetArrayLength();
4253 }
4254 fComp[fNdata].fType = element->GetType();
4255 fComp[fNdata].fNewType = element->GetNewType();
4256 fComp[fNdata].fOffset = element->GetOffset();
4257 fComp[fNdata].fLength = element->GetArrayLength();
4258 fComp[fNdata].fElem = element;
4259 fComp[fNdata].fMethod = element->GetMethod();
4260 fComp[fNdata].fClass = element->GetClassPointer();
4261 fComp[fNdata].fNewClass = element->GetNewClass();
4263 fComp[fNdata].fStreamer = element->GetStreamer();
4264
4265 // try to group consecutive members of the same type
4267 && (keep >= 0)
4268 && (element->GetType() > 0)
4269 && (element->GetType() < 10)
4271 && (fComp[keep].fMethod == 0)
4272 && (element->GetArrayDim() == 0)
4273 && (fComp[keep].fType < kObject)
4274 && (fComp[keep].fType != kCharStar) /* do not optimize char* */
4275 && (element->GetType() == (fComp[keep].fType%kRegrouped))
4276 && ((element->GetOffset()-fComp[keep].fOffset) == (fComp[keep].fLength)*asize)
4277 && ((fOldVersion<6) || !previous || /* In version of TStreamerInfo less than 6, the Double32_t were merged even if their annotation (aka factor) were different */
4278 ((element->GetFactor() == previous->GetFactor())
4279 && (element->GetXmin() == previous->GetXmin())
4280 && (element->GetXmax() == previous->GetXmax())
4281 )
4282 )
4285 // kWholeObject and kDoNotDelete do not apply to numerical elements.
4286 )
4287 {
4288 if (!previousOptimized) {
4289 // The element was not yet optimized we first need to copy it into
4290 // the set of original copies.
4291 fComp[fNslots - (++optiOut) ] = fComp[keep]; // Copy the optimized out elements.
4292 fCompFull[fNfulldata-1] = &(fComp[fNslots - optiOut]); // Reset the pointer in the full list.
4293 }
4294 fComp[fNslots - (++optiOut) ] = fComp[fNdata]; // Copy the optimized out elements.
4295 fCompFull[fNfulldata] = &(fComp[fNslots - optiOut]);
4296
4297 R__ASSERT( keep < (fNslots - optiOut) );
4298
4299 if (fComp[keep].fLength == 0) {
4300 fComp[keep].fLength++;
4301 }
4302 fComp[keep].fLength++;
4303 fComp[keep].fType = element->GetType() + kRegrouped;
4304 isOptimized = kTRUE;
4305 previousOptimized = kTRUE;
4306 } else if (element->GetType() < 0) {
4307
4308 // -- Deal with an ignored TObject base class.
4309 // Note: The only allowed negative value here is -1,
4310 // and signifies that Build() has found a TObject
4311 // base class and TClass::IgnoreTObjectStreamer() was
4312 // called. In this case the compiled version of the
4313 // elements omits the TObject base class element,
4314 // which has to be compensated for by TTree::Bronch()
4315 // when it is making branches for a split object.
4316 fComp[fNslots - (++optiOut) ] = fComp[fNdata]; // Copy the 'ignored' element.
4317 fCompFull[fNfulldata] = &(fComp[fNslots - optiOut]);
4318 keep = -1;
4319 previousOptimized = kFALSE;
4320
4321 } else {
4322 if (fComp[fNdata].fNewType != fComp[fNdata].fType) {
4323 if (fComp[fNdata].fNewType > 0) {
4324 if ( (fComp[fNdata].fNewType == kObjectp || fComp[fNdata].fNewType == kAnyp
4325 || fComp[fNdata].fNewType == kObject || fComp[fNdata].fNewType == kAny
4326 || fComp[fNdata].fNewType == kTObject || fComp[fNdata].fNewType == kTNamed || fComp[fNdata].fNewType == kTString)
4330 ) {
4332 } else if (fComp[fNdata].fType != kCounter) {
4333 fComp[fNdata].fType += kConv;
4334 }
4335 } else {
4336 if (fComp[fNdata].fType == kCounter) {
4337 Warning("Compile", "Counter %s should not be skipped from class %s", element->GetName(), GetName());
4338 }
4339 fComp[fNdata].fType += kSkip;
4340 }
4341 }
4342 fCompOpt[fNdata] = &(fComp[fNdata]);
4344
4345 R__ASSERT( fNdata < (fNslots - optiOut) );
4346
4347 keep = fNdata;
4348 if (fComp[keep].fLength == 0) {
4349 fComp[keep].fLength = 1;
4350 }
4351 fNdata++;
4352 previousOptimized = kFALSE;
4353 }
4354 // The test 'fMethod[keep] == 0' fails to detect a variable size array
4355 // if the counter happens to have an offset of zero, so let's explicitly
4356 // prevent for here.
4357 if (element->HasCounter()) keep = -1;
4358 ++fNfulldata;
4359 previous = element;
4360 }
4361
4362 for (i = 0; i < fNdata; ++i) {
4363 if (!fCompOpt[i]->fElem || fCompOpt[i]->fElem->GetType()< 0) {
4364 continue;
4365 }
4368 }
4369 for (i = 0; i < fNfulldata; ++i) {
4370 if (!fCompFull[i]->fElem || fCompFull[i]->fElem->GetType()< 0) {
4371 continue;
4372 }
4377
4380 }
4381 ComputeSize();
4382
4383 fOptimized = isOptimized;
4384 SetIsCompiled();
4385
4386 if (gDebug > 0) {
4387 ls();
4388 }
4389}
4390
4391template <typename From>
4393{
4394 switch (newtype) {
4411 }
4412}
4413
4414template <typename Onfile>
4416{
4417 // When writing 'newtype' is the origin of the information (i.e. the in memory representation)
4418 // and the template parameter `To` is the representation on disk
4419 switch (newtype) {
4436 }
4437}
4438
4439////////////////////////////////////////////////////////////////////////////////
4440/// Add a read action for the given element.
4441
4443{
4444 TStreamerElement *element = compinfo->fElem;
4445
4446 if (element->TestBit(TStreamerElement::kWrite)) return;
4447
4448 switch (compinfo->fType) {
4449 // read basic types
4450 case TStreamerInfo::kBool: readSequence->AddAction( ReadBasicType<Bool_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4451 case TStreamerInfo::kChar: readSequence->AddAction( ReadBasicType<Char_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4452 case TStreamerInfo::kShort: readSequence->AddAction( ReadBasicType<Short_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4453 case TStreamerInfo::kInt: readSequence->AddAction( ReadBasicType<Int_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4454 case TStreamerInfo::kLong: readSequence->AddAction( ReadBasicType<Long_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4455 case TStreamerInfo::kLong64: readSequence->AddAction( ReadBasicType<Long64_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4456 case TStreamerInfo::kFloat: readSequence->AddAction( ReadBasicType<Float_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4457 case TStreamerInfo::kDouble: readSequence->AddAction( ReadBasicType<Double_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4458 case TStreamerInfo::kUChar: readSequence->AddAction( ReadBasicType<UChar_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4459 case TStreamerInfo::kUShort: readSequence->AddAction( ReadBasicType<UShort_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4460 case TStreamerInfo::kUInt: readSequence->AddAction( ReadBasicType<UInt_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4461 case TStreamerInfo::kULong: readSequence->AddAction( ReadBasicType<ULong_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4462 case TStreamerInfo::kULong64: readSequence->AddAction( ReadBasicType<ULong64_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4463 case TStreamerInfo::kBits: readSequence->AddAction( ReadBasicType<BitsMarker>, new TBitsConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4465 if (element->GetFactor() != 0) {
4466 readSequence->AddAction( ReadBasicType_WithFactor<float>, new TConfWithFactor(this,i,compinfo,compinfo->fOffset,element->GetFactor(),element->GetXmin()) );
4467 } else {
4468 Int_t nbits = (Int_t)element->GetXmin();
4469 if (!nbits) nbits = 12;
4470 readSequence->AddAction( ReadBasicType_NoFactor<float>, new TConfNoFactor(this,i,compinfo,compinfo->fOffset,nbits) );
4471 }
4472 break;
4473 }
4475 if (element->GetFactor() != 0) {
4476 readSequence->AddAction( ReadBasicType_WithFactor<double>, new TConfWithFactor(this,i,compinfo,compinfo->fOffset,element->GetFactor(),element->GetXmin()) );
4477 } else {
4478 Int_t nbits = (Int_t)element->GetXmin();
4479 if (!nbits) {
4480 readSequence->AddAction( ConvertBasicType<float,double>::Action, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4481 } else {
4482 readSequence->AddAction( ReadBasicType_NoFactor<double>, new TConfNoFactor(this,i,compinfo,compinfo->fOffset,nbits) );
4483 }
4484 }
4485 break;
4486 }
4487 case TStreamerInfo::kTNamed: readSequence->AddAction( ReadTNamed, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4488 // Idea: We should calculate the CanIgnoreTObjectStreamer here and avoid calling the
4489 // Streamer alltogether.
4490 case TStreamerInfo::kTObject: readSequence->AddAction( ReadTObject, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4491 case TStreamerInfo::kTString: readSequence->AddAction( ReadTString, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4492 case TStreamerInfo::kSTL: {
4493 TClass *newClass = element->GetNewClass();
4494 TClass *oldClass = element->GetClassPointer();
4495 Bool_t isSTLbase = element->IsBase() && element->IsA()!=TStreamerBase::Class();
4496
4497 if (element->GetArrayLength() <= 1) {
4498 if (fOldVersion<3){ // case of old TStreamerInfo
4499 if (newClass && newClass != oldClass) {
4500 if (element->GetStreamer()) {
4501 readSequence->AddAction(ReadSTL<ReadSTLMemberWiseChangedClass,ReadSTLObjectWiseStreamerV2>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,newClass,element->GetStreamer(),element->GetTypeName(),isSTLbase));
4502 } else {
4503 readSequence->AddAction(ReadSTL<ReadSTLMemberWiseChangedClass,ReadSTLObjectWiseFastArrayV2>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,newClass,element->GetTypeName(),isSTLbase));
4504 }
4505 } else {
4506 if (element->GetStreamer()) {
4507 readSequence->AddAction(ReadSTL<ReadSTLMemberWiseSameClass,ReadSTLObjectWiseStreamerV2>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,element->GetStreamer(),element->GetTypeName(),isSTLbase));
4508 } else {
4509 readSequence->AddAction(ReadSTL<ReadSTLMemberWiseSameClass,ReadSTLObjectWiseFastArrayV2>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,element->GetTypeName(),isSTLbase));
4510 }
4511 }
4512 } else {
4513 if (newClass && newClass != oldClass) {
4514 if (element->GetStreamer()) {
4515 readSequence->AddAction(ReadSTL<ReadSTLMemberWiseChangedClass,ReadSTLObjectWiseStreamer>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,newClass,element->GetStreamer(),element->GetTypeName(),isSTLbase));
4516 } else if (oldClass) {
4517 if (oldClass->GetCollectionProxy() == 0 || oldClass->GetCollectionProxy()->GetValueClass() || oldClass->GetCollectionProxy()->HasPointers() ) {
4518 readSequence->AddAction(ReadSTL<ReadSTLMemberWiseChangedClass,ReadSTLObjectWiseFastArray>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,newClass,element->GetTypeName(),isSTLbase));
4519 } else {
4520 switch (SelectLooper(*newClass->GetCollectionProxy())) {
4521 case kVectorLooper:
4522 readSequence->AddAction(GetConvertCollectionReadAction<VectorLooper>(oldClass->GetCollectionProxy()->GetType(), newClass->GetCollectionProxy()->GetType(), new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,newClass,element->GetTypeName(),isSTLbase)));
4523 break;
4524 case kAssociativeLooper:
4525 readSequence->AddAction(GetConvertCollectionReadAction<AssociativeLooper>(oldClass->GetCollectionProxy()->GetType(), newClass->GetCollectionProxy()->GetType(), new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,newClass,element->GetTypeName(),isSTLbase)));
4526 break;
4527 case kVectorPtrLooper:
4528 case kGenericLooper:
4529 default:
4530 // For now TBufferXML would force use to allocate the data buffer each time and copy into the real thing.
4531 readSequence->AddAction(GetConvertCollectionReadAction<GenericLooper>(oldClass->GetCollectionProxy()->GetType(), newClass->GetCollectionProxy()->GetType(), new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,newClass,element->GetTypeName(),isSTLbase)));
4532 break;
4533 }
4534 }
4535 }
4536 } else {
4537 if (element->GetStreamer()) {
4538 readSequence->AddAction(ReadSTL<ReadSTLMemberWiseSameClass,ReadSTLObjectWiseStreamer>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,element->GetStreamer(),element->GetTypeName(),isSTLbase));
4539 } else if (oldClass) {
4540 if (oldClass->GetCollectionProxy() == 0 || oldClass->GetCollectionProxy()->GetValueClass() || oldClass->GetCollectionProxy()->HasPointers() ) {
4541 readSequence->AddAction(ReadSTL<ReadSTLMemberWiseSameClass,ReadSTLObjectWiseFastArray>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,element->GetTypeName(),isSTLbase));
4542 } else {
4543 switch (SelectLooper(*oldClass->GetCollectionProxy())) {
4544 case kVectorLooper:
4545 readSequence->AddAction(GetNumericCollectionReadAction<VectorLooper>(oldClass->GetCollectionProxy()->GetType(), new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,element->GetTypeName(),isSTLbase)));
4546 break;
4547 case kAssociativeLooper:
4548 readSequence->AddAction(GetNumericCollectionReadAction<AssociativeLooper>(oldClass->GetCollectionProxy()->GetType(), new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,element->GetTypeName(),isSTLbase)));
4549 break;
4550 case kVectorPtrLooper:
4551 case kGenericLooper:
4552 default:
4553 // For now TBufferXML would force use to allocate the data buffer each time and copy into the real thing.
4554 readSequence->AddAction(GetNumericCollectionReadAction<GenericLooper>(oldClass->GetCollectionProxy()->GetType(), new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,1,oldClass,element->GetTypeName(),isSTLbase)));
4555 break;
4556 }
4557 }
4558 }
4559 }
4560 }
4561 } else {
4562 if (fOldVersion<3){ // case of old TStreamerInfo
4563 if (newClass && newClass != oldClass) {
4564 if (element->GetStreamer()) {
4565 readSequence->AddAction(ReadSTL<ReadArraySTLMemberWiseChangedClass,ReadSTLObjectWiseStreamerV2>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,element->GetArrayLength(),oldClass,newClass,element->GetStreamer(),element->GetTypeName(),isSTLbase));
4566 } else {
4567 readSequence->AddAction(ReadSTL<ReadArraySTLMemberWiseChangedClass,ReadSTLObjectWiseFastArrayV2>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,element->GetArrayLength(),oldClass,newClass,element->GetTypeName(),isSTLbase));
4568 }
4569 } else {
4570 if (element->GetStreamer()) {
4571 readSequence->AddAction(ReadSTL<ReadArraySTLMemberWiseSameClass,ReadSTLObjectWiseStreamerV2>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,element->GetArrayLength(),oldClass,element->GetStreamer(),element->GetTypeName(),isSTLbase));
4572 } else {
4573 readSequence->AddAction(ReadSTL<ReadArraySTLMemberWiseSameClass,ReadSTLObjectWiseFastArrayV2>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,element->GetArrayLength(),oldClass,element->GetTypeName(),isSTLbase));
4574 }
4575 }
4576 } else {
4577 if (newClass && newClass != oldClass) {
4578 if (element->GetStreamer()) {
4579 readSequence->AddAction(ReadSTL<ReadArraySTLMemberWiseChangedClass,ReadSTLObjectWiseStreamer>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,element->GetArrayLength(),oldClass,newClass,element->GetStreamer(),element->GetTypeName(),isSTLbase));
4580 } else {
4581 readSequence->AddAction(ReadSTL<ReadArraySTLMemberWiseChangedClass,ReadSTLObjectWiseFastArray>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,element->GetArrayLength(),oldClass,newClass,element->GetTypeName(),isSTLbase));
4582 }
4583 } else {
4584 if (element->GetStreamer()) {
4585 readSequence->AddAction(ReadSTL<ReadArraySTLMemberWiseSameClass,ReadSTLObjectWiseStreamer>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,element->GetArrayLength(),oldClass,element->GetStreamer(),element->GetTypeName(),isSTLbase));
4586 } else {
4587 readSequence->AddAction(ReadSTL<ReadArraySTLMemberWiseSameClass,ReadSTLObjectWiseFastArray>, new TConfigSTL(/*read = */ true, this,i,compinfo,compinfo->fOffset,element->GetArrayLength(),oldClass,element->GetTypeName(),isSTLbase));
4588 }
4589 }
4590 }
4591 }
4592 break;
4593 }
4594
4596 AddReadConvertAction<Bool_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4597 break;
4599 AddReadConvertAction<Char_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4600 break;
4602 AddReadConvertAction<Short_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4603 break;
4605 AddReadConvertAction<Int_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4606 break;
4608 AddReadConvertAction<Long_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4609 break;
4611 AddReadConvertAction<Long64_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4612 break;
4614 AddReadConvertAction<Float_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4615 break;
4617 AddReadConvertAction<Double_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4618 break;
4620 AddReadConvertAction<UChar_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4621 break;
4623 AddReadConvertAction<UShort_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4624 break;
4626 AddReadConvertAction<UInt_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4627 break;
4629 AddReadConvertAction<ULong_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4630 break;
4632 AddReadConvertAction<ULong64_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4633 break;
4635 AddReadConvertAction<BitsMarker>(readSequence, compinfo->fNewType, new TBitsConfiguration(this,i,compinfo,compinfo->fOffset) );
4636 break;
4638 if (element->GetFactor() != 0) {
4639 AddReadConvertAction<WithFactorMarker<float> >(readSequence, compinfo->fNewType, new TConfWithFactor(this,i,compinfo,compinfo->fOffset,element->GetFactor(),element->GetXmin()) );
4640 } else {
4641 Int_t nbits = (Int_t)element->GetXmin();
4642 if (!nbits) nbits = 12;
4643 AddReadConvertAction<NoFactorMarker<float> >(readSequence, compinfo->fNewType, new TConfNoFactor(this,i,compinfo,compinfo->fOffset,nbits) );
4644 }
4645 break;
4646 }
4648 if (element->GetFactor() != 0) {
4649 AddReadConvertAction<WithFactorMarker<double> >(readSequence, compinfo->fNewType, new TConfWithFactor(this,i,compinfo,compinfo->fOffset,element->GetFactor(),element->GetXmin()) );
4650 } else {
4651 Int_t nbits = (Int_t)element->GetXmin();
4652 if (!nbits) {
4653 AddReadConvertAction<Float_t>(readSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4654 } else {
4655 AddReadConvertAction<NoFactorMarker<double> >(readSequence, compinfo->fNewType, new TConfNoFactor(this,i,compinfo,compinfo->fOffset,nbits) );
4656 }
4657 }
4658 break;
4659 }
4662 bool isPtrPtr = (strstr(compinfo->fElem->GetTypeName(), "**") != 0);
4663 readSequence->AddAction(ScalarLooper::ReadStreamerLoop<false>::Action,
4664 new TConfStreamerLoop(this, i, compinfo, compinfo->fOffset, isPtrPtr));
4665 break;
4666 }
4668 if (compinfo->fStreamer)
4669 readSequence->AddAction( ReadStreamerCase, new TGenericConfiguration(this,i,compinfo, compinfo->fOffset) );
4670 else {
4671 auto base = dynamic_cast<TStreamerBase*>(element);
4672 auto onfileBaseCl = base ? base->GetClassPointer() : nullptr;
4673 auto memoryBaseCl = base && base->GetNewBaseClass() ? base->GetNewBaseClass() : onfileBaseCl;
4674
4675 if(!base || !memoryBaseCl ||
4676 memoryBaseCl->GetStreamer() ||
4677 memoryBaseCl->GetStreamerFunc() || memoryBaseCl->GetConvStreamerFunc())
4678 {
4679 // Unusual Case.
4680 readSequence->AddAction( GenericReadAction, new TGenericConfiguration(this,i,compinfo) );
4681 }
4682 else
4683 readSequence->AddAction( ReadViaClassBuffer,
4684 new TConfObject(this, i, compinfo, compinfo->fOffset, onfileBaseCl, memoryBaseCl) );
4685 }
4686 break;
4688 if (fOldVersion >= 3)
4689 readSequence->AddAction( ReadStreamerCase, new TGenericConfiguration(this,i,compinfo, compinfo->fOffset) );
4690 else
4691 // Use the slower path for legacy files
4692 readSequence->AddAction( GenericReadAction, new TGenericConfiguration(this,i,compinfo) );
4693 break;
4695 if (compinfo->fStreamer)
4696 readSequence->AddAction( ReadViaExtStreamer, new TGenericConfiguration(this, i, compinfo, compinfo->fOffset) );
4697 else {
4698 if (compinfo->fNewClass && compinfo->fNewClass->HasDirectStreamerInfoUse())
4699 readSequence->AddAction( ReadViaClassBuffer,
4700 new TConfObject(this, i, compinfo, compinfo->fOffset, compinfo->fClass, compinfo->fNewClass) );
4701 else if (compinfo->fClass && compinfo->fClass->HasDirectStreamerInfoUse())
4702 readSequence->AddAction( ReadViaClassBuffer,
4703 new TConfObject(this, i, compinfo, compinfo->fOffset, compinfo->fClass, nullptr) );
4704 else // Use the slower path for unusual cases
4705 readSequence->AddAction( GenericReadAction, new TGenericConfiguration(this, i, compinfo) );
4706 }
4707 break;
4708 default:
4709 readSequence->AddAction( GenericReadAction, new TGenericConfiguration(this,i,compinfo) );
4710 break;
4711 }
4712 if (element->TestBit(TStreamerElement::kCache)) {
4713 TConfiguredAction action( readSequence->fActions.back() ); // Action is moved, we must pop it next.
4714 readSequence->fActions.pop_back();
4715 readSequence->AddAction( UseCache, new TConfigurationUseCache(this,action,element->TestBit(TStreamerElement::kRepeat)) );
4716 }
4717}
4718
4719////////////////////////////////////////////////////////////////////////////////
4720/// Add a read text action for the given element.
4721
4723{
4724 TStreamerElement *element = compinfo->fElem;
4725
4726 if (element->TestBit(TStreamerElement::kWrite))
4727 return;
4728
4729 Bool_t generic = kFALSE, isBase = kFALSE;
4730
4731 switch (compinfo->fType) {
4733 if (element->IsBase())
4734 isBase = kTRUE;
4735 // readSequence->AddAction( ReadTextTObjectBase, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4736 else
4737 readSequence->AddAction(ReadTextTObject, new TConfiguration(this, i, compinfo, compinfo->fOffset));
4738 break;
4739
4741 if (element->IsBase())
4742 isBase = kTRUE;
4743 // generic = kTRUE; // for the base class one cannot call TClass::Streamer() as performed for the normal object
4744 else
4745 readSequence->AddAction(ReadTextTNamed, new TConfiguration(this, i, compinfo, compinfo->fOffset));
4746 break;
4747
4748 case TStreamerInfo::kObject: // Class derived from TObject
4749 case TStreamerInfo::kAny: // Class NOT derived from TObject
4752 readSequence->AddAction(ReadTextObject, new TConfiguration(this, i, compinfo, compinfo->fOffset));
4753 break;
4754
4755 case TStreamerInfo::kSTLp: // Pointer to container with no virtual table (stl) and no comment
4757 TStreamerInfo::kOffsetL: // array of pointers to container with no virtual table (stl) and no comment
4758 readSequence->AddAction(TextReadSTLp, new TConfiguration(this, i, compinfo, compinfo->fOffset));
4759 break;
4760
4763 bool isPtrPtr = (strstr(compinfo->fElem->GetTypeName(), "**") != 0);
4764 readSequence->AddAction(ScalarLooper::ReadStreamerLoop<true>::Action,
4765 new TConfStreamerLoop(this, i, compinfo, compinfo->fOffset, isPtrPtr));
4766 break;
4767 }
4768 case TStreamerInfo::kBase: isBase = kTRUE; break;
4769
4771 readSequence->AddAction(ReadStreamerCase, new TGenericConfiguration(this, i, compinfo));
4772 break;
4773
4774 default: generic = kTRUE; break;
4775 }
4776
4777 if (isBase) {
4778 if (compinfo->fStreamer) {
4779 readSequence->AddAction(ReadStreamerCase, new TGenericConfiguration(this, i, compinfo));
4780 } else {
4781 readSequence->AddAction(ReadTextBaseClass, new TGenericConfiguration(this, i, compinfo));
4782 }
4783 } else if (generic)
4784 readSequence->AddAction(GenericReadAction, new TGenericConfiguration(this, i, compinfo));
4785}
4786
4787////////////////////////////////////////////////////////////////////////////////
4788/// Add a read action for the given element.
4789/// This is for streaming via a TClonesArray (or a vector of pointers of this type).
4790
4792{
4793 TStreamerElement *element = compinfo->fElem;
4794
4795 if (element->TestBit(TStreamerElement::kWrite)) return;
4796
4797 if (element->TestBit(TStreamerElement::kCache)) {
4798 TConfiguredAction action( GetCollectionReadAction<VectorLooper>(this,nullptr,element,compinfo->fType,i,compinfo,compinfo->fOffset) );
4799 readSequence->AddAction( UseCacheVectorPtrLoop, new TConfigurationUseCache(this,action,element->TestBit(TStreamerElement::kRepeat)) );
4800 } else {
4801 readSequence->AddAction( GetCollectionReadAction<VectorPtrLooper>(this,nullptr,element,compinfo->fType,i,compinfo,compinfo->fOffset) );
4802 }
4803}
4804
4805////////////////////////////////////////////////////////////////////////////////
4806
4808{
4809 TStreamerElement *element = compinfo->fElem;
4811 // Skip element cached for reading purposes.
4812 return;
4813 }
4814 if (element->GetType() >= kArtificial && !element->TestBit(TStreamerElement::kWrite)) {
4815 // Skip artificial element used for reading purposes.
4816 return;
4817 }
4818 switch (compinfo->fType) {
4819 // write basic types
4820 case TStreamerInfo::kBool: writeSequence->AddAction( WriteBasicType<Bool_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4821 case TStreamerInfo::kChar: writeSequence->AddAction( WriteBasicType<Char_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4822 case TStreamerInfo::kShort: writeSequence->AddAction( WriteBasicType<Short_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4823 case TStreamerInfo::kInt: writeSequence->AddAction( WriteBasicType<Int_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4824 case TStreamerInfo::kLong: writeSequence->AddAction( WriteBasicType<Long_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4825 case TStreamerInfo::kLong64: writeSequence->AddAction( WriteBasicType<Long64_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4826 case TStreamerInfo::kFloat: writeSequence->AddAction( WriteBasicType<Float_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4827 case TStreamerInfo::kDouble: writeSequence->AddAction( WriteBasicType<Double_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4828 case TStreamerInfo::kUChar: writeSequence->AddAction( WriteBasicType<UChar_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4829 case TStreamerInfo::kUShort: writeSequence->AddAction( WriteBasicType<UShort_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4830 case TStreamerInfo::kUInt: writeSequence->AddAction( WriteBasicType<UInt_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4831 case TStreamerInfo::kULong: writeSequence->AddAction( WriteBasicType<ULong_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4832 case TStreamerInfo::kULong64: writeSequence->AddAction( WriteBasicType<ULong64_t>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
4833
4835 AddWriteConvertAction<Char_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4836 break;
4838 AddWriteConvertAction<Short_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4839 break;
4841 AddWriteConvertAction<Int_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4842 break;
4844 AddWriteConvertAction<Long_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4845 break;
4847 AddWriteConvertAction<Long64_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4848 break;
4850 AddWriteConvertAction<UChar_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4851 break;
4853 AddWriteConvertAction<UShort_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4854 break;
4856 AddWriteConvertAction<UInt_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4857 break;
4859 AddWriteConvertAction<ULong_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4860 break;
4862 AddWriteConvertAction<ULong64_t>(writeSequence, compinfo->fNewType, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
4863 break;
4864
4865 case kSTL:
4866 {
4867 TClass *newClass = element->GetNewClass();
4868 TClass *onfileClass = element->GetClassPointer();
4869 Bool_t isSTLbase = element->IsBase() && element->IsA()!=TStreamerBase::Class();
4870
4871 if (element->GetArrayLength() <= 1) {
4872 if (newClass && newClass != onfileClass) {
4873 if (element->GetStreamer()) {
4874 writeSequence->AddAction(WriteSTL<WriteSTLMemberWise /* should be ChangedClass */, WriteSTLObjectWiseStreamer>,
4875 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass,
4876 newClass, element->GetStreamer(), element->GetTypeName(),
4877 isSTLbase));
4878 } else if (onfileClass) {
4879 if (onfileClass->GetCollectionProxy() == 0 || onfileClass->GetCollectionProxy()->GetValueClass() ||
4880 onfileClass->GetCollectionProxy()->HasPointers()) {
4881 writeSequence->AddAction(
4882 WriteSTL<WriteSTLObjectWiseStreamer /* should be ChangedClass */, WriteSTLObjectWiseFastArray>,
4883 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass, newClass,
4884 element->GetTypeName(), isSTLbase));
4885 } else {
4886 switch (SelectLooper(*newClass->GetCollectionProxy())) {
4887 case kVectorLooper:
4888 writeSequence->AddAction(GetConvertCollectionWriteAction<VectorLooper>(
4889 onfileClass->GetCollectionProxy()->GetType(), newClass->GetCollectionProxy()->GetType(),
4890 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass, newClass,
4891 element->GetTypeName(), isSTLbase)));
4892 break;
4893 case kAssociativeLooper:
4894 writeSequence->AddAction(GetConvertCollectionWriteAction<AssociativeLooper>(
4895 onfileClass->GetCollectionProxy()->GetType(), newClass->GetCollectionProxy()->GetType(),
4896 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass, newClass,
4897 element->GetTypeName(), isSTLbase)));
4898 break;
4899 case kVectorPtrLooper:
4900 case kGenericLooper:
4901 default:
4902 // For now TBufferXML would force use to allocate the data buffer each time and copy into the
4903 // real thing.
4904 writeSequence->AddAction(GetConvertCollectionWriteAction<GenericLooper>(
4905 onfileClass->GetCollectionProxy()->GetType(), newClass->GetCollectionProxy()->GetType(),
4906 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass, newClass,
4907 element->GetTypeName(), isSTLbase)));
4908 break;
4909 }
4910 }
4911 }
4912 } else {
4913 if (element->GetStreamer()) {
4914 writeSequence->AddAction(WriteSTL<WriteSTLMemberWise, WriteSTLObjectWiseStreamer>,
4915 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass,
4916 element->GetStreamer(), element->GetTypeName(),
4917 isSTLbase));
4918 } else if (onfileClass) {
4919 if (onfileClass->GetCollectionProxy() == 0 ||
4920 onfileClass->GetCollectionProxy()->GetValueClass() ||
4921 onfileClass->GetCollectionProxy()->HasPointers()) {
4922 writeSequence->AddAction(WriteSTL<WriteSTLMemberWise, WriteSTLObjectWiseFastArray>,
4923 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass,
4924 element->GetTypeName(), isSTLbase));
4925 } else {
4926 switch (SelectLooper(*onfileClass->GetCollectionProxy())) {
4927 case kVectorLooper:
4928 writeSequence->AddAction(GetNumericCollectionWriteAction<VectorLooper>(
4929 onfileClass->GetCollectionProxy()->GetType(),
4930 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass, element->GetTypeName(),
4931 isSTLbase)));
4932 break;
4933 case kAssociativeLooper:
4934 writeSequence->AddAction(GetNumericCollectionWriteAction<AssociativeLooper>(
4935 onfileClass->GetCollectionProxy()->GetType(),
4936 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass, element->GetTypeName(),
4937 isSTLbase)));
4938 break;
4939 case kVectorPtrLooper:
4940 case kGenericLooper:
4941 default:
4942 // For now TBufferXML would force use to allocate the data buffer each time and copy into the
4943 // real thing.
4944 writeSequence->AddAction(GetNumericCollectionWriteAction<GenericLooper>(
4945 onfileClass->GetCollectionProxy()->GetType(),
4946 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, 1, onfileClass, element->GetTypeName(),
4947 isSTLbase)));
4948 break;
4949 }
4950 }
4951 }
4952 }
4953 } else {
4954 if (newClass && newClass != onfileClass) {
4955 if (element->GetStreamer()) {
4956 writeSequence->AddAction(
4957 WriteSTL<WriteArraySTLMemberWise /* should be ChangedClass */, WriteSTLObjectWiseStreamer>,
4958 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, element->GetArrayLength(), onfileClass,
4959 newClass, element->GetStreamer(), element->GetTypeName(), isSTLbase));
4960 } else {
4961 writeSequence->AddAction(
4962 WriteSTL<WriteArraySTLMemberWise /* should be ChangedClass */, WriteSTLObjectWiseFastArray>,
4963 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset, element->GetArrayLength(), onfileClass,
4964 newClass, element->GetTypeName(), isSTLbase));
4965 }
4966 } else {
4967 if (element->GetStreamer()) {
4968 writeSequence->AddAction(WriteSTL<WriteArraySTLMemberWise, WriteSTLObjectWiseStreamer>,
4969 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset,
4970 element->GetArrayLength(), onfileClass,
4971 element->GetStreamer(), element->GetTypeName(), isSTLbase));
4972 } else {
4973 writeSequence->AddAction(WriteSTL<WriteArraySTLMemberWise, WriteSTLObjectWiseFastArray>,
4974 new TConfigSTL(/*read = */ false, this, i, compinfo, compinfo->fOffset,
4975 element->GetArrayLength(), onfileClass,
4976 element->GetTypeName(), isSTLbase));
4977 }
4978 }
4979 }
4980 break;
4981 }
4982
4983 case TStreamerInfo::kTNamed: writeSequence->AddAction( WriteTNamed, new TConfiguration(this, i, compinfo, compinfo->fOffset) ); break;
4984 // Idea: We should calculate the CanIgnoreTObjectStreamer here and avoid calling the
4985 // Streamer alltogether.
4986 case TStreamerInfo::kTObject: writeSequence->AddAction( WriteTObject, new TConfiguration(this, i, compinfo, compinfo->fOffset) ); break;
4987 case TStreamerInfo::kTString: writeSequence->AddAction( WriteTString, new TConfiguration(this, i, compinfo, compinfo->fOffset) ); break;
4988
4991 bool isPtrPtr = (strstr(compinfo->fElem->GetTypeName(), "**") != 0);
4992 writeSequence->AddAction(ScalarLooper::WriteStreamerLoop<false>::Action,
4993 new TConfStreamerLoop(this, i, compinfo, compinfo->fOffset, isPtrPtr));
4994 break;
4995 }
4997 if (compinfo->fStreamer)
4998 writeSequence->AddAction( WriteStreamerCase, new TGenericConfiguration(this,i,compinfo, compinfo->fOffset) );
4999 else {
5000 auto base = dynamic_cast<TStreamerBase*>(element);
5001 auto onfileBaseCl = base ? base->GetClassPointer() : nullptr;
5002 auto memoryBaseCl = base && base->GetNewBaseClass() ? base->GetNewBaseClass() : onfileBaseCl;
5003
5004 if(!base || !memoryBaseCl ||
5005 memoryBaseCl->GetStreamer() ||
5006 memoryBaseCl->GetStreamerFunc() || memoryBaseCl->GetConvStreamerFunc())
5007 {
5008 // Unusual Case.
5009 writeSequence->AddAction( GenericWriteAction, new TGenericConfiguration(this,i,compinfo) );
5010 }
5011 else {
5012 writeSequence->AddAction( WriteViaClassBuffer,
5013 new TConfObject(this, i, compinfo, compinfo->fOffset, onfileBaseCl, memoryBaseCl) );
5014 }
5015 }
5016 break;
5018 if (fOldVersion >= 3)
5019 writeSequence->AddAction( WriteStreamerCase, new TGenericConfiguration(this,i,compinfo, compinfo->fOffset) );
5020 else
5021 // Use the slower path for legacy files
5022 writeSequence->AddAction( GenericWriteAction, new TGenericConfiguration(this,i,compinfo) );
5023 break;
5025 if (compinfo->fStreamer)
5026 writeSequence->AddAction( WriteViaExtStreamer, new TGenericConfiguration(this, i, compinfo, compinfo->fOffset) );
5027 else {
5028 if (compinfo->fNewClass && compinfo->fNewClass->fStreamerImpl == &TClass::StreamerStreamerInfo)
5029 writeSequence->AddAction( WriteViaClassBuffer,
5030 new TConfObject(this, i, compinfo, compinfo->fOffset, compinfo->fClass, compinfo->fNewClass) );
5031 else if (compinfo->fClass && compinfo->fClass->fStreamerImpl == &TClass::StreamerStreamerInfo)
5032 writeSequence->AddAction( WriteViaClassBuffer,
5033 new TConfObject(this, i, compinfo, compinfo->fOffset, compinfo->fClass, nullptr) );
5034 else // Use the slower path for unusual cases
5035 writeSequence->AddAction( GenericWriteAction, new TGenericConfiguration(this, i, compinfo) );
5036 }
5037 break;
5038
5039 // case TStreamerInfo::kBits: writeSequence->AddAction( WriteBasicType<BitsMarker>, new TConfiguration(this,i,compinfo,compinfo->fOffset) ); break;
5040 /*case TStreamerInfo::kFloat16: {
5041 if (element->GetFactor() != 0) {
5042 writeSequence->AddAction( WriteBasicType_WithFactor<float>, new TConfWithFactor(this,i,compinfo,compinfo->fOffset,element->GetFactor(),element->GetXmin()) );
5043 } else {
5044 Int_t nbits = (Int_t)element->GetXmin();
5045 if (!nbits) nbits = 12;
5046 writeSequence->AddAction( WriteBasicType_NoFactor<float>, new TConfNoFactor(this,i,compinfo,compinfo->fOffset,nbits) );
5047 }
5048 break;
5049 } */
5050 /*case TStreamerInfo::kDouble32: {
5051 if (element->GetFactor() != 0) {
5052 writeSequence->AddAction( WriteBasicType_WithFactor<double>, new TConfWithFactor(this,i,compinfo,compinfo->fOffset,element->GetFactor(),element->GetXmin()) );
5053 } else {
5054 Int_t nbits = (Int_t)element->GetXmin();
5055 if (!nbits) {
5056 writeSequence->AddAction( ConvertBasicType<float,double>, new TConfiguration(this,i,compinfo,compinfo->fOffset) );
5057 } else {
5058 writeSequence->AddAction( WriteBasicType_NoFactor<double>, new TConfNoFactor(this,i,compinfo,compinfo->fOffset,nbits) );
5059 }
5060 }
5061 break;
5062 } */
5063 default:
5064 writeSequence->AddAction( GenericWriteAction, new TGenericConfiguration(this,i,compinfo) );
5065 break;
5066 }
5067}
5068
5069////////////////////////////////////////////////////////////////////////////////
5070
5072{
5073 TStreamerElement *element = compinfo->fElem;
5075 // Skip element cached for reading purposes.
5076 return;
5077 }
5078 if (element->GetType() >= kArtificial && !element->TestBit(TStreamerElement::kWrite)) {
5079 // Skip artificial element used for reading purposes.
5080 return;
5081 }
5082
5083 Bool_t generic = kFALSE, isBase = kFALSE;
5084
5085 switch (compinfo->fType) {
5086 // write basic types
5112 // Actually same action for this level
5113 AddWriteAction(writeSequence, i, compinfo);
5114 break;
5115
5117 if (element->IsBase())
5118 isBase = kTRUE;
5119 else
5120 writeSequence->AddAction(WriteTextTObject, new TConfiguration(this, i, compinfo, compinfo->fOffset));
5121 break;
5122
5124 if (element->IsBase())
5125 isBase = kTRUE;
5126 else
5127 writeSequence->AddAction(WriteTextTNamed, new TConfiguration(this, i, compinfo, compinfo->fOffset));
5128 break;
5129
5130 case TStreamerInfo::kSTLp: // Pointer to container with no virtual table (stl) and no comment
5132 TStreamerInfo::kOffsetL: // array of pointers to container with no virtual table (stl) and no comment
5133 writeSequence->AddAction(TextWriteSTLp, new TConfiguration(this, i, compinfo, compinfo->fOffset));
5134 break;
5135
5138 bool isPtrPtr = (strstr(compinfo->fElem->GetTypeName(), "**") != 0);
5139 writeSequence->AddAction(ScalarLooper::WriteStreamerLoop<true>::Action, new TConfStreamerLoop(this, i, compinfo, compinfo->fOffset, isPtrPtr));
5140 break;
5141 }
5142 case TStreamerInfo::kBase: isBase = kTRUE; break;
5143
5145 writeSequence->AddAction(WriteStreamerCase, new TGenericConfiguration(this, i, compinfo));
5146 break;
5147
5148 default: generic = kTRUE; break;
5149 }
5150
5151 if (isBase) {
5152 if (compinfo->fStreamer) {
5153 writeSequence->AddAction(WriteStreamerCase, new TGenericConfiguration(this, i, compinfo));
5154 } else {
5155 writeSequence->AddAction(WriteTextBaseClass, new TGenericConfiguration(this, i, compinfo));
5156 }
5157
5158 } else
5159
5160 // use generic write action when special handling is not provided
5161 if (generic)
5162 writeSequence->AddAction(GenericWriteAction, new TGenericConfiguration(this, i, compinfo));
5163}
5164
5165////////////////////////////////////////////////////////////////////////////////
5166/// This is for streaming via a TClonesArray (or a vector of pointers of this type).
5167
5169{
5170 TStreamerElement *element = compinfo->fElem;
5172 // Skip element cached for reading purposes.
5173 return;
5174 }
5175 if (element->GetType() >= kArtificial && !element->TestBit(TStreamerElement::kWrite)) {
5176 // Skip artificial element used for reading purposes.
5177 return;
5178 }
5179 writeSequence->AddAction( GetCollectionWriteAction<VectorPtrLooper>(this,nullptr,element,compinfo->fType,i,compinfo,compinfo->fOffset) );
5180}
5181
5182////////////////////////////////////////////////////////////////////////////////
5183/// Create the bundle of the actions necessary for the streaming memberwise of the content described by 'info' into the collection described by 'proxy'
5184
5186{
5187 if (info == 0) {
5189 }
5190
5191 std::unique_ptr<TLoopConfiguration> loopConfig;
5192 if (IsDefaultVector(proxy))
5193 {
5194 if (proxy.HasPointers()) {
5195 TStreamerInfo *sinfo = static_cast<TStreamerInfo*>(info);
5196 // Instead of the creating a new one let's copy the one from the StreamerInfo.
5197 return sinfo->GetReadMemberWiseActions(kTRUE)->CreateCopy();
5198 }
5199
5200 // We can speed up the iteration in case of vector. We also know that all emulated collection are stored internally as a vector.
5201 Long_t increment = proxy.GetIncrement();
5202 loopConfig = std::make_unique<TVectorLoopConfig>(&proxy, increment, /* read */ kTRUE);
5207 {
5208 Long_t increment = proxy.GetIncrement();
5209 loopConfig = std::make_unique<TVectorLoopConfig>(&proxy, increment, /* read */ kTRUE);
5210 // sequence->fLoopConfig = new TAssocLoopConfig(proxy);
5211 } else {
5212 loopConfig = std::make_unique<TGenericLoopConfig>(&proxy, /* read */ kTRUE);
5213 }
5214
5215 return CreateReadMemberWiseActions(*info, std::move(loopConfig));
5216}
5217
5218////////////////////////////////////////////////////////////////////////////////
5219/// Create the bundle of the actions necessary for the streaming memberwise of the content described by 'info' into the collection described by 'proxy'
5220
5222{
5223 UInt_t ndata = info.GetElements()->GetEntriesFast();
5225 sequence->fLoopConfig = std::move(inLoopConfig);
5226 TLoopConfiguration *loopConfig = sequence->fLoopConfig.get();
5227
5228 for (UInt_t i = 0; i < ndata; ++i) {
5229 TStreamerElement *element = (TStreamerElement*) info.GetElements()->At(i);
5230 if (!element) {
5231 break;
5232 }
5233 if (element->GetType() < 0) {
5234 // -- Skip an ignored TObject base class.
5235 // Note: The only allowed negative value here is -1, and signifies that Build() has found a TObject
5236 // base class and TClass::IgnoreTObjectStreamer() was called. In this case the compiled version of the
5237 // elements omits the TObject base class element, which has to be compensated for by TTree::Bronch()
5238 // when it is making branches for a split object.
5239 continue;
5240 }
5241 if (element->TestBit(TStreamerElement::kWrite)) {
5242 // Skip element that only for writing.
5243 continue;
5244 }
5245 TStreamerBase *baseEl = dynamic_cast<TStreamerBase*>(element);
5246 if (baseEl) {
5247 if (!baseEl->TestBit(TStreamerElement::kWarned) && baseEl->GetErrorMessage()[0]) {
5248 // There was a problem with the checksum, the user likely did not
5249 // increment the version number of the derived class when the
5250 // base class changed. Since we will be member wise streaming
5251 // this class, let's warn the user that something is wrong.
5252 ::Warning("CreateReadMemberWiseActions","%s",
5253 baseEl->GetErrorMessage());
5255 }
5256 }
5257
5258 TStreamerInfo *sinfo = static_cast<TStreamerInfo*>(&info);
5259 TStreamerInfo::TCompInfo_t *compinfo = sinfo->fCompFull[i];
5260
5261 Int_t oldType = element->GetType();
5262 Int_t newType = element->GetNewType();
5263
5264 Int_t offset = element->GetOffset();
5265 if (newType != oldType) {
5266 // This 'prevents' the switch from base class (kBase (0)) to
5267 // anything else.
5268 if (newType > 0) {
5269 if (oldType != TVirtualStreamerInfo::kCounter) {
5270 oldType += TVirtualStreamerInfo::kConv;
5271 }
5272 } else {
5273 oldType += TVirtualStreamerInfo::kSkip;
5274 }
5275 }
5276 switch (SelectLooper(loopConfig ? loopConfig->fProxy : nullptr)) {
5277 case kAssociativeLooper:
5278// } else if (proxy.GetCollectionType() == ROOT::kSTLset || proxy.GetCollectionType() == ROOT::kSTLmultiset
5279// || proxy.GetCollectionType() == ROOT::kSTLmap || proxy.GetCollectionType() == ROOT::kSTLmultimap) {
5280// sequence->AddAction( GenericAssocCollectionAction, new TConfigSTL(true, info,i,compinfo,offset,0,proxy.GetCollectionClass(),0,0) );
5281 case kVectorLooper:
5282 case kVectorPtrLooper:
5283 // We can speed up the iteration in case of vector. We also know that all emulated collection are stored internally as a vector.
5284 if (element->TestBit(TStreamerElement::kCache)) {
5285 TConfiguredAction action( GetCollectionReadAction<VectorLooper>(&info,loopConfig,element,oldType,i,compinfo,offset) );
5287 } else {
5288 sequence->AddAction( GetCollectionReadAction<VectorLooper>(&info,loopConfig,element,oldType,i,compinfo,offset));
5289 }
5290 break;
5291 case kGenericLooper:
5292 default:
5293 // The usual collection case.
5294 if (element->TestBit(TStreamerElement::kCache)) {
5295 TConfiguredAction action( GetCollectionReadAction<VectorLooper>(&info,loopConfig,element,oldType,i,compinfo,offset) );
5297 } else {
5298 sequence->AddAction( GetCollectionReadAction<GenericLooper>(&info,loopConfig,element,oldType,i,compinfo,offset) );
5299 }
5300 break;
5301 }
5302 }
5303 return sequence;
5304}
5305
5306////////////////////////////////////////////////////////////////////////////////
5307/// Create the bundle of the actions necessary for the streaming memberwise of the content described by 'info' into the collection described by 'proxy'
5308
5310{
5311 if (info == 0) {
5313 }
5314
5315 std::unique_ptr<TLoopConfiguration> loopConfig;
5316 if (IsDefaultVector(proxy))
5317 {
5318 if (proxy.HasPointers()) {
5319 TStreamerInfo *sinfo = static_cast<TStreamerInfo*>(info);
5320 // Instead of the creating a new one let's copy the one from the StreamerInfo.
5321 return sinfo->GetWriteMemberWiseActions(kTRUE)->CreateCopy();
5322 }
5323
5324 // We can speed up the iteration in case of vector. We also know that all emulated collection are stored internally as a vector.
5325 Long_t increment = proxy.GetIncrement();
5326 loopConfig = std::make_unique<TVectorLoopConfig>(&proxy, increment, /* read */ kFALSE);
5327 } else {
5328 loopConfig = std::make_unique<TGenericLoopConfig>(&proxy, /* read */ kFALSE);
5329 }
5330 return CreateWriteMemberWiseActions(*info, std::move(loopConfig));
5331}
5332
5333////////////////////////////////////////////////////////////////////////////////
5334/// Create the bundle of the actions necessary for the streaming memberwise of the content described by 'info' into the
5335/// collection described by 'proxy' \param loopConfig pointer ownership is taken from the caller and transferred to the
5336/// TActionSequence class (stored as public fLoopConfig internally, will be deleted in destructor) \return new
5337/// `sequence` pointer of type TActionSequence, the memory ownership is transferred to caller, must delete it later
5338
5340{
5341 UInt_t ndata = info.GetElements()->GetEntriesFast();
5343 sequence->fLoopConfig = std::move(inLoopConfig);
5344 TLoopConfiguration *loopConfig = sequence->fLoopConfig.get();
5345
5346 for (UInt_t i = 0; i < ndata; ++i) {
5347 TStreamerElement *element = (TStreamerElement*) info.GetElements()->At(i);
5348 if (!element) {
5349 break;
5350 }
5351 if (element->GetType() < 0) {
5352 // -- Skip an ignored TObject base class.
5353 // Note: The only allowed negative value here is -1, and signifies that Build() has found a TObject
5354 // base class and TClass::IgnoreTObjectStreamer() was called. In this case the compiled version of the
5355 // elements omits the TObject base class element, which has to be compensated for by TTree::Bronch()
5356 // when it is making branches for a split object.
5357 continue;
5358 }
5360 // Skip element cached for reading purposes.
5361 continue;
5362 }
5364 // Skip artificial element used for reading purposes.
5365 continue;
5366 }
5367 TStreamerInfo *sinfo = static_cast<TStreamerInfo*>(&info);
5368 TStreamerInfo::TCompInfo *compinfo = sinfo->fCompFull[i];
5369 Int_t onfileType = element->GetType();
5370 Int_t memoryType = element->GetNewType();
5371 if (memoryType != onfileType) {
5372 // This 'prevents' the switch from base class (kBase (0)) to
5373 // anything else.
5374 if (memoryType > 0) {
5375 if (onfileType != TVirtualStreamerInfo::kCounter) {
5376 onfileType += TVirtualStreamerInfo::kConv;
5377 }
5378 } else {
5379 // When reading we need to consume the data in the onfile buffer,
5380 // so we do create a 'Skip' action for the missing elements.
5381 // When writing we should probably write a default value, for
5382 // now let's just ignore the request.
5383 // We could issue an error here but we might too often issue a
5384 // 'false positive' if the user only reads.
5385 // FIXME: The 'right' solution is to add a new action that first print
5386 // once the following error message:
5387 //
5388 // info.Error("TActionSequence::CreateWriteMemberWiseActions",
5389 // "Ignoring request to write the missing data member %s in %s version %d checksum 0x%x",
5390 // element->GetName(), info.GetName(), info.GetClassVersion(), info.GetCheckSum());
5391 continue;
5392 //
5393 // Instead of skipping the field we could write a zero there with:
5394 // onfileType += TVirtualStreamerInfo::kSkip;
5395 }
5396 }
5397
5398 Int_t offset = element->GetOffset();
5399 switch (SelectLooper(loopConfig ? loopConfig->fProxy : nullptr)) {
5400 case kAssociativeLooper:
5401 sequence->AddAction( GetCollectionWriteAction<GenericLooper>(&info,loopConfig,element,onfileType,i,compinfo,offset) );
5402 break;
5403 case kVectorLooper:
5404 sequence->AddAction( GetCollectionWriteAction<VectorLooper>(&info,loopConfig,element,onfileType,i,compinfo,offset) );
5405 break;
5406 case kVectorPtrLooper:
5407 sequence->AddAction( GetCollectionWriteAction<VectorPtrLooper>(&info,loopConfig,element,onfileType,i,compinfo,offset) );
5408 break;
5409 case kGenericLooper:
5410 default:
5411 sequence->AddAction( GetCollectionWriteAction<GenericLooper>(&info,loopConfig,element,onfileType,i,compinfo,offset) );
5412 break;
5413 }
5414 }
5415 return sequence;
5416}
5417
5419{
5420 // Add the (potentially negative) delta to all the configuration's offset. This is used by
5421 // TBranchElement in the case of split sub-object.
5422
5423 TStreamerInfoActions::ActionContainer_t::iterator end = fActions.end();
5424 for(TStreamerInfoActions::ActionContainer_t::iterator iter = fActions.begin();
5425 iter != end;
5426 ++iter)
5427 {
5428 // (fElemId == -1) indications that the action is a Push or Pop DataCache.
5429 if (iter->fConfiguration->fElemId != (UInt_t)-1 &&
5430 !iter->fConfiguration->fInfo->GetElements()->At(iter->fConfiguration->fElemId)->TestBit(TStreamerElement::kCache))
5431 iter->fConfiguration->AddToOffset(delta);
5432 }
5433}
5434
5436{
5437 // Add the (potentially negative) delta to all the configuration's offset. This is used by
5438 // TBranchElement in the case of split sub-object.
5439
5440 TStreamerInfoActions::ActionContainer_t::iterator end = fActions.end();
5441 for(TStreamerInfoActions::ActionContainer_t::iterator iter = fActions.begin();
5442 iter != end;
5443 ++iter)
5444 {
5445 if (!iter->fConfiguration->fInfo->GetElements()->At(iter->fConfiguration->fElemId)->TestBit(TStreamerElement::kCache))
5446 iter->fConfiguration->SetMissing();
5447 }
5448}
5449
5451{
5452 // Create a copy of this sequence.
5453
5454 TStreamerInfoActions::TActionSequence *sequence = new TStreamerInfoActions::TActionSequence(fStreamerInfo, fActions.size(), IsForVectorPtrLooper());
5455
5456 sequence->fLoopConfig.reset(fLoopConfig ? fLoopConfig->Copy() : nullptr);
5457
5458 TStreamerInfoActions::ActionContainer_t::iterator end = fActions.end();
5459 for(TStreamerInfoActions::ActionContainer_t::iterator iter = fActions.begin();
5460 iter != end;
5461 ++iter)
5462 {
5463 TConfiguration *conf = iter->fConfiguration->Copy();
5464 sequence->AddAction( iter->fAction, conf );
5465 }
5466 return sequence;
5467}
5468
5470 const TStreamerInfoActions::TIDs &element_ids,
5471 Int_t offset,
5473{
5474 for(UInt_t id = 0; id < element_ids.size(); ++id) {
5475 if ( element_ids[id].fElemID < 0 ) {
5476 if (element_ids[id].fNestedIDs) {
5477 auto original = create(element_ids[id].fNestedIDs->fInfo,
5478 sequence->fLoopConfig ? sequence->fLoopConfig->GetCollectionProxy() : nullptr,
5479 nullptr);
5480 if (element_ids[id].fNestedIDs->fOnfileObject) {
5481 auto conf = new TConfigurationPushDataCache(element_ids[id].fNestedIDs->fInfo, element_ids[id].fNestedIDs->fOnfileObject, offset);
5482 if ( sequence->fLoopConfig )
5483 sequence->AddAction( PushDataCacheGenericCollection, conf );
5484 else if ( sequence->IsForVectorPtrLooper() )
5485 sequence->AddAction( PushDataCacheVectorPtr, conf );
5486 else
5487 sequence->AddAction( PushDataCache, conf );
5488 }
5489
5490 original->AddToSubSequence(sequence, element_ids[id].fNestedIDs->fIDs, element_ids[id].fNestedIDs->fOffset, create);
5491
5492 if (element_ids[id].fNestedIDs->fOnfileObject) {
5493 auto conf =
5494 new TConfigurationPushDataCache(element_ids[id].fNestedIDs->fInfo, nullptr, element_ids[id].fNestedIDs->fOffset);
5495 if ( sequence->fLoopConfig )
5496 sequence->AddAction( PopDataCacheGenericCollection, conf );
5497 else if ( sequence->IsForVectorPtrLooper() )
5498 sequence->AddAction( PopDataCacheVectorPtr, conf );
5499 else
5500 sequence->AddAction( PopDataCache, conf );
5501 }
5502 } else {
5503 TStreamerInfoActions::ActionContainer_t::iterator end = fActions.end();
5504 for(TStreamerInfoActions::ActionContainer_t::iterator iter = fActions.begin();
5505 iter != end;
5506 ++iter)
5507 {
5508 TConfiguration *conf = iter->fConfiguration->Copy();
5509 if (!iter->fConfiguration->fInfo->GetElements()->At(iter->fConfiguration->fElemId)->TestBit(TStreamerElement::kCache))
5510 conf->AddToOffset(offset);
5511 sequence->AddAction( iter->fAction, conf );
5512 }
5513 }
5514 } else {
5515 TStreamerInfoActions::ActionContainer_t::iterator end = fActions.end();
5516 for(TStreamerInfoActions::ActionContainer_t::iterator iter = fActions.begin();
5517 iter != end;
5518 ++iter) {
5519 if ( iter->fConfiguration->fElemId == (UInt_t)element_ids[id].fElemID ) {
5520 TConfiguration *conf = iter->fConfiguration->Copy();
5521 if (!iter->fConfiguration->fInfo->GetElements()->At(iter->fConfiguration->fElemId)->TestBit(TStreamerElement::kCache))
5522 conf->AddToOffset(offset);
5523 sequence->AddAction( iter->fAction, conf );
5524 }
5525 }
5526 }
5527 }
5528}
5529
5532{
5533 // Create a sequence containing the subset of the action corresponding to the SteamerElement whose ids is contained in the vector.
5534 // 'offset' is the location of this 'class' within the object (address) that will be passed to ReadBuffer when using this sequence.
5535
5536 TStreamerInfoActions::TActionSequence *sequence = new TStreamerInfoActions::TActionSequence(fStreamerInfo, element_ids.size(), IsForVectorPtrLooper());
5537
5538 sequence->fLoopConfig = std::unique_ptr<TLoopConfiguration>(fLoopConfig ? fLoopConfig->Copy() : 0);
5539
5540 AddToSubSequence(sequence, element_ids, offset, create);
5541
5542 return sequence;
5543}
5544
5546{
5547 // Create a sequence containing the subset of the action corresponding to the SteamerElement whose ids is contained in the vector.
5548 // 'offset' is the location of this 'class' within the object (address) that will be passed to ReadBuffer when using this sequence.
5549
5550 TStreamerInfoActions::TActionSequence *sequence = new TStreamerInfoActions::TActionSequence(fStreamerInfo, element_ids.size(), IsForVectorPtrLooper());
5551
5552 sequence->fLoopConfig.reset(fLoopConfig ? fLoopConfig->Copy() : 0);
5553
5554 for(UInt_t id = 0; id < element_ids.size(); ++id) {
5555 if ( element_ids[id] < 0 ) {
5556 TStreamerInfoActions::ActionContainer_t::iterator end = fActions.end();
5557 for(TStreamerInfoActions::ActionContainer_t::iterator iter = fActions.begin();
5558 iter != end;
5559 ++iter)
5560 {
5561 TConfiguration *conf = iter->fConfiguration->Copy();
5562 if (!iter->fConfiguration->fInfo->GetElements()->At(iter->fConfiguration->fElemId)->TestBit(TStreamerElement::kCache))
5563 conf->AddToOffset(offset);
5564 sequence->AddAction( iter->fAction, conf );
5565 }
5566 } else {
5567 TStreamerInfoActions::ActionContainer_t::iterator end = fActions.end();
5568 for(TStreamerInfoActions::ActionContainer_t::iterator iter = fActions.begin();
5569 iter != end;
5570 ++iter) {
5571 if ( iter->fConfiguration->fElemId == (UInt_t)element_ids[id] ) {
5572 TConfiguration *conf = iter->fConfiguration->Copy();
5573 if (!iter->fConfiguration->fInfo->GetElements()->At(iter->fConfiguration->fElemId)->TestBit(TStreamerElement::kCache))
5574 conf->AddToOffset(offset);
5575 sequence->AddAction( iter->fAction, conf );
5576 }
5577 }
5578 }
5579 }
5580 return sequence;
5581}
5582
5583#if !defined(R__WIN32)
5584
5585#include <dlfcn.h>
5586
5587#endif
5588
5589typedef void (*voidfunc)();
5590static const char *R__GetSymbolName(voidfunc func)
5591{
5592#if defined(R__WIN32) || defined(__CYGWIN__)
5593 return "not available on this platform";
5594#if 0
5595 MEMORY_BASIC_INFORMATION mbi;
5596 if (!VirtualQuery (func, &mbi, sizeof (mbi)))
5597 {
5598 return 0;
5599 }
5600
5601 HMODULE hMod = (HMODULE) mbi.AllocationBase;
5602 static char moduleName[MAX_PATH];
5603
5604 if (!GetModuleFileNameA (hMod, moduleName, sizeof (moduleName)))
5605 {
5606 return 0;
5607 }
5608 return moduleName;
5609#endif
5610#else
5611 Dl_info info;
5612 if (dladdr((void*)func,&info)==0) {
5613 // Not in a known share library, let's give up
5614 return "name not found";
5615 } else {
5616 //fprintf(stdout,"Found address in %s\n",info.dli_fname);
5617 return info.dli_sname;
5618 }
5619#endif
5620}
5621
5623{
5624 // Add the (potentially negative) delta to all the configuration's offset. This is used by
5625 // TTBranchElement in the case of split sub-object.
5626 // If opt contains 'func', also print the (mangled) name of the function that will be executed.
5627
5628 if (fLoopConfig) {
5629 fLoopConfig->Print();
5630 }
5631 TStreamerInfoActions::ActionContainer_t::const_iterator end = fActions.end();
5632 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = fActions.begin();
5633 iter != end;
5634 ++iter)
5635 {
5636 iter->fConfiguration->Print();
5637 if (strstr(opt,"func")) {
5638 printf("StreamerInfoAction func: %s\n",R__GetSymbolName((voidfunc)iter->fAction));
5639 }
5640 }
5641}
5642
5643
T ReadBuffer(TBufferFile *buf)
One of the template functions used to read objects from messages.
Definition MPSendRecv.h:158
#define b(i)
Definition RSha256.hxx:100
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:55
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
constexpr Int_t kMaxInt
Definition RtypesCore.h:120
short Version_t
Class version identifier (short)
Definition RtypesCore.h:80
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:139
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Definition TError.cxx:267
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
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 Float_t r
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 length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
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
float xmin
R__EXTERN TVirtualMutex * gInterpreterMutex
@ kIsReferenced
Definition TObject.h:378
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:792
#define gROOT
Definition TROOT.h:417
static TConfiguredAction GetNumericCollectionReadAction(Int_t type, TConfigSTL *conf)
static TConfiguredAction GetNumericCollectionWriteAction(Int_t type, TConfigSTL *conf)
void(* voidfunc)()
static void AddWriteConvertAction(TStreamerInfoActions::TActionSequence *sequence, Int_t newtype, TConfiguration *conf)
static TConfiguredAction GetCollectionWriteConvertAction(Int_t newtype, TConfiguration *conf)
static void AddReadConvertAction(TStreamerInfoActions::TActionSequence *sequence, Int_t newtype, TConfiguration *conf)
static TConfiguredAction GetCollectionReadConvertAction(Int_t newtype, TConfiguration *conf)
static TConfiguredAction GetCollectionReadAction(TVirtualStreamerInfo *info, TLoopConfiguration *loopConfig, TStreamerElement *element, Int_t type, UInt_t i, TStreamerInfo::TCompInfo_t *compinfo, Int_t offset)
static const Int_t kRegrouped
static const char * R__GetSymbolName(voidfunc func)
static TConfiguredAction GetCollectionWriteAction(TVirtualStreamerInfo *info, TLoopConfiguration *loopConfig, TStreamerElement *element, Int_t type, UInt_t i, TStreamerInfo::TCompInfo_t *compinfo, Int_t offset)
static TConfiguredAction GetConvertCollectionReadAction(Int_t oldtype, Int_t newtype, TConfiguration *conf)
static TConfiguredAction GetConvertCollectionWriteAction(Int_t onfileType, Int_t memoryType, TConfiguration *conf)
static TConfiguredAction GetConvertCollectionReadActionFrom(Int_t newtype, TConfiguration *conf)
static TConfiguredAction GetConvertCollectionWriteActionFrom(Int_t onfileType, TConfiguration *conf)
#define ReadBasicType(name)
#define WriteBasicType(name)
#define R__LOCKGUARD(mutex)
@ kStreamedMemberWise
Definition TBufferFile.h:70
Base class for text-based streamers like TBufferJSON or TBufferXML Special actions list will use meth...
Definition TBufferText.h:20
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual void ReadWithNbits(Float_t *ptr, Int_t nbits)=0
virtual void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue)=0
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)=0
virtual Version_t ReadVersionForMemberWise(const TClass *cl=nullptr)=0
virtual void WriteDouble32(Double_t *d, TStreamerElement *ele=nullptr)=0
virtual TProcessID * ReadProcessID(UShort_t pidf)=0
Return the current Process-ID.
Definition TBuffer.cxx:345
virtual UInt_t WriteVersionMemberWise(const TClass *cl, Bool_t useBcnt=kFALSE)=0
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
virtual void ReadInt(Int_t &i)=0
TObject * GetParent() const
Return pointer to parent of this buffer.
Definition TBuffer.cxx:261
virtual void WriteFloat16(Float_t *f, TStreamerElement *ele=nullptr)=0
virtual UShort_t GetPidOffset() const =0
@ kCannotHandleMemberWiseStreaming
Definition TBuffer.h:76
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object)=0
virtual void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits)=0
void SetBufferOffset(Int_t offset=0)
Definition TBuffer.h:93
virtual void WriteFastArrayFloat16(const Float_t *f, Long64_t n, TStreamerElement *ele=nullptr)=0
virtual void WriteFastArray(const Bool_t *b, Long64_t n)=0
virtual void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue)=0
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
virtual void WriteInt(Int_t i)=0
virtual void WriteFastArrayDouble32(const Double_t *d, Long64_t n, TStreamerElement *ele=nullptr)=0
virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Int_t Length() const
Definition TBuffer.h:100
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=nullptr)=0
TClassRef is used to implement a permanent reference to a TClass object.
Definition TClassRef.h:29
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=nullptr) const
Definition TClass.h:627
Bool_t CanSplit() const
Return true if the data member of this TClass can be saved separately.
Definition TClass.cxx:2331
void * NewArray(Long_t nElements, ENewType defConstructor=kClassNew) const
Return a pointer to a newly allocated array of objects of this class.
Definition TClass.cxx:5322
EState GetState() const
Definition TClass.h:504
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:5107
Bool_t HasCustomStreamerMember() const
The class has a Streamer method and it is implemented by the user or an older (not StreamerInfo based...
Definition TClass.h:524
Int_t Size() const
Return size of object of this class.
Definition TClass.cxx:5871
Bool_t HasDirectStreamerInfoUse() const
Definition TClass.h:422
static void StreamerStreamerInfo(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
Case of where we should directly use the StreamerInfo.
Definition TClass.cxx:7050
void DeleteArray(void *ary, Bool_t dtorOnly=kFALSE)
Explicitly call operator delete[] for an array.
Definition TClass.cxx:5658
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:4716
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Definition TClass.cxx:2923
std::atomic< StreamerImpl_t > fStreamerImpl
! Pointer to the function implementing streaming for this class
Definition TClass.h:296
@ kEmulated
Definition TClass.h:128
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
Int_t GetVersion() const
Definition TFile.h:335
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
static TClass * Class()
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
void AddAt(TObject *obj, Int_t idx) override
Add object at position ids.
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
TObject * At(Int_t idx) const override
Definition TObjArray.h:170
Mother of all ROOT objects.
Definition TObject.h:42
@ kIsOnHeap
object is on heap
Definition TObject.h:90
@ kNotDeleted
object has not been deleted
Definition TObject.h:91
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
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:479
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
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:886
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:897
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition TProcessID.h:74
void PutObjectWithID(TObject *obj, UInt_t uid=0)
stores the object at the uid th slot in the table of objects The object uniqued is set as well as its...
TVirtualStreamerInfo * GetBaseStreamerInfo() const
TClass * GetClassPointer() const override
Returns a pointer to the TClass of this element.
const char * GetErrorMessage() const
static TClass * Class()
Describe one element (data member) to be Streamed.
Int_t GetNewType() const
virtual Int_t GetSize() const
Returns size of this element in bytes.
Int_t GetType() const
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 ULongptr_t GetMethod() const
Int_t GetArrayDim() const
TMemberStreamer * GetStreamer() const
Return the local streamer object.
Double_t GetXmax() const
TClass * GetNewClass() const
Int_t GetArrayLength() const
Double_t GetFactor() const
const char * GetTypeName() const
TClass * IsA() const override
Double_t GetXmin() const
Int_t GetOffset() const
virtual Bool_t IsBase() const
Return kTRUE if the element represent a base class.
virtual Bool_t HasCounter() const
void GetSequenceType(TString &type) const
Fill type with the string representation of sequence information including 'cached',...
static TActionSequence * CreateReadMemberWiseActions(TVirtualStreamerInfo *info, TVirtualCollectionProxy &proxy)
Create the bundle of the actions necessary for the streaming memberwise of the content described by '...
std::unique_ptr< TLoopConfiguration > fLoopConfig
If this is a bundle of memberwise streaming action, this configures the looping.
void Print(Option_t *="") const override
This method must be overridden when a class wants to print itself.
static TActionSequence * CreateWriteMemberWiseActions(TVirtualStreamerInfo *info, TVirtualCollectionProxy &proxy)
Create the bundle of the actions necessary for the streaming memberwise of the content described by '...
SequencePtr(*)(TStreamerInfo *info, TVirtualCollectionProxy *collectionProxy, TClass *originalClass) SequenceGetter_t
void AddToSubSequence(TActionSequence *sequence, const TIDs &element_ids, Int_t offset, SequenceGetter_t create)
TActionSequence * CreateSubSequence(const std::vector< Int_t > &element_ids, size_t offset)
void AddAction(action_t action, TConfiguration *conf)
TLoopConfiguration * Copy() const override
TAssocLoopConfig(TVirtualCollectionProxy *proxy, Bool_t)
void * GetFirstAddress(void *start, const void *) const override
TConfNoFactor(TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, Int_t nbits)
TConfSTLNoFactor(TConfigSTL *orig, Int_t nbits)
TConfSTLWithFactor(TConfigSTL *orig, Double_t factor, Double_t xmin)
TConfWithFactor(TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, Double_t factor, Double_t xmin)
TConfigSTL(Bool_t read, TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, UInt_t length, TClass *oldClass, const char *type_name, Bool_t isbase)
TConfigSTL(Bool_t read, TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, UInt_t length, TClass *oldClass, TClass *newClass, const char *type_name, Bool_t isbase)
TConfigSTL(Bool_t read, TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, UInt_t length, TClass *oldClass, TMemberStreamer *streamer, const char *type_name, Bool_t isbase)
TVirtualCollectionProxy::CreateIterators_t fCreateIterators
TVirtualCollectionProxy::DeleteIterator_t fDeleteIterator
TVirtualCollectionProxy::DeleteTwoIterators_t fDeleteTwoIterators
TVirtualCollectionProxy::Next_t fNext
TConfigSTL(Bool_t read, TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, UInt_t length, TClass *oldClass, TClass *newClass, TMemberStreamer *streamer, const char *type_name, Bool_t isbase)
TVirtualCollectionProxy::CopyIterator_t fCopyIterator
TConfigurationPushDataCache(TVirtualStreamerInfo *info, TVirtualArray *onfileObject, Int_t offset)
void PrintDebug(TBuffer &buffer, void *object) const override
void PrintDebug(TBuffer &b, void *addr) const override
TConfigurationUseCache(TVirtualStreamerInfo *info, TConfiguredAction &action, Bool_t repeat)
Base class of the Configurations.
virtual void PrintDebug(TBuffer &buffer, void *object) const
TVirtualStreamerInfo * fInfo
TStreamerInfo form which the action is derived.
Int_t fOffset
Offset within the object.
TCompInfo_t * fCompInfo
Access to compiled information (for legacy code)
UInt_t fLength
Number of element in a fixed length array.
UInt_t fElemId
Identifier of the TStreamerElement.
void PrintDebug(TBuffer &buffer, void *object) const
TLoopConfiguration * Copy() const override
void * GetFirstAddress(void *start_collection, const void *end_collection) const override
TVirtualCollectionProxy::CopyIterator_t fCopyIterator
TVirtualCollectionProxy::DeleteIterator_t fDeleteIterator
TGenericLoopConfig(TVirtualCollectionProxy *proxy, Bool_t read)
Base class of the Configurations for the member wise looping routines.
virtual TLoopConfiguration * Copy() const =0
TLoopConfiguration * Copy() const override
void * GetFirstAddress(void *start, const void *) const override
TVectorLoopConfig(TVirtualCollectionProxy *proxy, Long_t increment, Bool_t)
TClass * fClass
Not Owned.
TMemberStreamer * fStreamer
Not Owned.
TStreamerElement * fElem
Not Owned.
TClass * fNewClass
Not Owned.
Describes a persistent version of a class.
Int_t fNVirtualInfoLoc
! Number of virtual info location to update.
Int_t ReadBufferSTL(TBuffer &b, TVirtualCollectionProxy *cont, Int_t nc, Int_t eoffset, Bool_t v7=kTRUE)
The STL vector/list is deserialized from the buffer b.
void AddWriteAction(TStreamerInfoActions::TActionSequence *writeSequence, Int_t index, TCompInfo *compinfo)
Int_t fNfulldata
!number of elements
TCompInfo * fComp
![fNslots with less than fElements->GetEntries()*1.5 used] Compiled info
TStreamerInfoActions::TActionSequence * GetWriteMemberWiseActions(Bool_t forCollection)
TStreamerInfoActions::TActionSequence * fWriteMemberWiseVecPtr
! List of write action resulting from the compilation for use in member wise streaming.
TStreamerInfoActions::TActionSequence * fReadText
! List of text read action resulting from the compilation, used for JSON.
void ls(Option_t *option="") const override
List the TStreamerElement list and also the precomputed tables if option contains the string "incOrig...
void AddReadTextAction(TStreamerInfoActions::TActionSequence *readSequence, Int_t index, TCompInfo *compinfo)
Add a read text action for the given element.
TCompInfo ** fCompFull
![fElements->GetEntries()]
TObjArray * fElements
Array of TStreamerElements.
void AddReadMemberWiseVecPtrAction(TStreamerInfoActions::TActionSequence *readSequence, Int_t index, TCompInfo *compinfo)
Add a read action for the given element.
TStreamerInfoActions::TActionSequence * fReadMemberWise
! List of read action resulting from the compilation for use in member wise streaming.
Int_t fNdata
!number of optimized elements
TStreamerInfoActions::TActionSequence * fReadMemberWiseVecPtr
! List of read action resulting from the compilation for use in member wise streaming.
TStreamerInfoActions::TActionSequence * fReadObjectWise
! List of read action resulting from the compilation.
TClass * fClass
!pointer to class
TCompInfo ** fCompOpt
![fNdata]
TClass * GetClass() const override
static std::atomic< Int_t > fgCount
Number of TStreamerInfo instances.
void AddWriteTextAction(TStreamerInfoActions::TActionSequence *writeSequence, Int_t index, TCompInfo *compinfo)
void ComputeSize()
Compute total size of all persistent elements of the class.
void AddReadAction(TStreamerInfoActions::TActionSequence *readSequence, Int_t index, TCompInfo *compinfo)
Add a read action for the given element.
void AddWriteMemberWiseVecPtrAction(TStreamerInfoActions::TActionSequence *writeSequence, Int_t index, TCompInfo *compinfo)
This is for streaming via a TClonesArray (or a vector of pointers of this type).
Int_t fNumber
!Unique identifier
TStreamerInfoActions::TActionSequence * fWriteObjectWise
! List of write action resulting from the compilation.
Int_t fSize
!size of the persistent class
void Compile() override
loop on the TStreamerElement list regroup members with same type Store predigested information into l...
Int_t ReadBufferSkip(TBuffer &b, const T &arrptr, const TCompInfo *compinfo, Int_t kase, TStreamerElement *aElement, Int_t narr, Int_t eoffset)
Skip an element.
TStreamerInfoActions::TActionSequence * fWriteMemberWise
! List of write action resulting from the compilation for use in member wise streaming.
Int_t fNslots
!total number of slots in fComp.
Version_t fOldVersion
! Version of the TStreamerInfo object read from the file
TStreamerInfoActions::TActionSequence * fWriteText
! List of text write action resulting for the compilation, used for JSON.
size_t fAlignment
!alignment of the memory representation of the class
TStreamerInfoActions::TActionSequence * GetReadMemberWiseActions(Bool_t forCollection)
Basic string class.
Definition TString.h:137
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1171
const char * Data() const
Definition TString.h:385
@ kTrailing
Definition TString.h:283
Wrapper around an object and giving indirect access to its content even if the object is not of a cla...
TClassRef fClass
RAII helper class that ensures that PushProxy() / PopProxy() are called when entering / leaving a C++...
Defines a common interface to inspect/change the contents of an object that represents a collection.
virtual Int_t GetProperties() const
Return miscallenous properties of the proxy (see TVirtualCollectionProxy::EProperty)
virtual ULong_t GetIncrement() const =0
Return the offset between two consecutive in-memory values (which depends on the sizeof() and alignme...
virtual TStreamerInfoActions::TActionSequence * GetReadMemberWiseActions(Int_t version)=0
void(* CreateIterators_t)(void *collection, void **begin_arena, void **end_arena, TVirtualCollectionProxy *proxy)
*begin_arena and *end_arena should contain the location of a memory arena of size fgIteratorArenaSize...
virtual EDataType GetType() const =0
If the value type is a fundamental data type, return its type (see enumeration EDataType).
@ kCustomAlloc
The collection has a custom allocator.
void *(* CopyIterator_t)(void *dest, const void *source)
Copy the iterator source into dest.
virtual TStreamerInfoActions::TActionSequence * GetWriteMemberWiseActions()=0
void *(* Next_t)(void *iter, const void *end)
iter and end should be pointers to an iterator to be incremented and an iterator that points to the e...
virtual TClass * GetValueClass() const =0
If the value type is a user-defined class, return a pointer to the TClass representing the value type...
virtual void Commit(void *)=0
Commits pending elements in a staging area (see Allocate() for more information).
virtual Int_t GetCollectionType() const =0
Return the type of the proxied collection (see enumeration TClassEdit::ESTLType)
virtual Next_t GetFunctionNext(Bool_t read=kTRUE)=0
Return a pointer to a function that can advance an iterator (see Next_t).
virtual DeleteTwoIterators_t GetFunctionDeleteTwoIterators(Bool_t read=kTRUE)=0
virtual UInt_t Size() const =0
Return the current number of elements in the container.
void(* DeleteTwoIterators_t)(void *begin, void *end)
void(* DeleteIterator_t)(void *iter)
If the size of the iterator is greater than fgIteratorArenaSize, call delete on the addresses; otherw...
static const Int_t fgIteratorArenaSize
The size of a small buffer that can be allocated on the stack to store iterator-specific information.
virtual CreateIterators_t GetFunctionCreateIterators(Bool_t read=kTRUE)=0
Return a pointer to a function that can create an iterator pair, where each iterator points to the be...
virtual void * Allocate(UInt_t n, Bool_t forceDelete)=0
Allocates space for storing at least n elements.
virtual TStreamerInfoActions::TActionSequence * GetConversionReadMemberWiseActions(TClass *oldClass, Int_t version)=0
virtual DeleteIterator_t GetFunctionDeleteIterator(Bool_t read=kTRUE)=0
Return a pointer to a function that can delete an iterator (pair) (see DeleteIterator_t).
virtual CopyIterator_t GetFunctionCopyIterator(Bool_t read=kTRUE)=0
Return a pointer to a function that can copy an iterator (see CopyIterator_t).
virtual Bool_t HasPointers() const =0
Return true if the content is of type 'pointer to'.
virtual TClass * GetCollectionClass() const
Return a pointer to the TClass representing the proxied container class.
static void * Next(void *iter, const void *end)
static void * CopyIterator(void *dest, const void *source)
Abstract Interface class describing Streamer information for one class.
static Bool_t GetStreamMemberWise()
Return whether the TStreamerInfos will save the collections in "member-wise" order whenever possible.
@ kUChar
Equal to TDataType's kchar.
TClass * IsA() const override
static Bool_t CanOptimize()
static function returning true if optimization can be on
virtual TObjArray * GetElements() const =0
virtual Version_t GetOldVersion() const =0
virtual Int_t GetClassVersion() const =0
Bool_t fOptimized
! true if the StreamerInfo has been optimized
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
@ kSTLbitset
Definition ESTLType.h:37
@ kSTLmap
Definition ESTLType.h:33
@ kSTLunorderedmultiset
Definition ESTLType.h:43
@ kSTLset
Definition ESTLType.h:35
@ kSTLmultiset
Definition ESTLType.h:36
@ kSTLvector
Definition ESTLType.h:30
@ kSTLunorderedmultimap
Definition ESTLType.h:45
@ kSTLunorderedset
Definition ESTLType.h:42
@ kSTLunorderedmap
Definition ESTLType.h:44
@ kSTLmultimap
Definition ESTLType.h:34
void ReadSTLObjectWiseStreamer(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t, UInt_t)
Int_t WriteTString(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t PushDataCacheVectorPtr(TBuffer &b, void *, const void *, const TConfiguration *conf)
Int_t PopDataCache(TBuffer &b, void *, const TConfiguration *)
void ReadSTLMemberWiseChangedClass(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers)
Int_t TextReadSTLp(TBuffer &buf, void *addr, const TConfiguration *config)
void ReadSTLObjectWiseFastArrayV2(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers, UInt_t start)
Int_t ReadBasicType< BitsMarker >(TBuffer &buf, void *addr, const TConfiguration *config)
static void WriteCompressed(TBuffer &buf, float *addr, const TStreamerElement *elem)
Int_t WriteTextBaseClass(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t GenericWriteAction(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t WriteTObject(TBuffer &buf, void *addr, const TConfiguration *config)
void ReadArraySTLMemberWiseChangedClass(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers)
std::vector< TIDNode > TIDs
Int_t PopDataCacheVectorPtr(TBuffer &b, void *, const void *, const TConfiguration *)
Int_t GenericReadAction(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t WriteTextTObject(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t WriteTNamed(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t ReadBasicType_WithFactor(TBuffer &buf, void *addr, const TConfiguration *config)
void WriteSTLObjectWiseFastArray(TBuffer &buf, void *addr, const TConfiguration *conf)
Int_t ReadTextBaseClass(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t UseCacheVectorPtrLoop(TBuffer &b, void *start, const void *end, const TConfiguration *conf)
void WriteSTLObjectWiseStreamer(TBuffer &buf, void *addr, const TConfiguration *conf)
Int_t WriteSTL(TBuffer &buf, void *addr, const TConfiguration *conf)
Int_t ReadSTL(TBuffer &buf, void *addr, const TConfiguration *conf)
Int_t ReadTextTObject(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t PushDataCache(TBuffer &b, void *, const TConfiguration *conf)
Int_t UseCache(TBuffer &b, void *addr, const TConfiguration *conf)
Int_t WriteViaClassBuffer(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t WriteLoopInvalid(TBuffer &, void *, const void *, const TConfiguration *config)
void ReadSTLMemberWiseSameClass(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers)
Int_t WriteTextTNamed(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t ReadTextObject(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t TextWriteSTLp(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t UseCacheVectorLoop(TBuffer &b, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *conf)
Int_t ReadViaExtStreamer(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t ReadTextTNamed(TBuffer &buf, void *addr, const TConfiguration *config)
void WriteArraySTLMemberWise(TBuffer &buf, void *addr, const TConfiguration *conf)
Int_t WriteStreamerCase(TBuffer &buf, void *addr, const TConfiguration *config)
void ReadSTLObjectWiseFastArray(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t, UInt_t)
Int_t ReadTNamed(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t ReadBasicType_NoFactor(TBuffer &buf, void *addr, const TConfiguration *config)
bool IsDefaultVector(TVirtualCollectionProxy &proxy)
Int_t ReadLoopInvalid(TBuffer &, void *, const void *, const TConfiguration *config)
Int_t ReadTObject(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t WriteViaExtStreamer(TBuffer &buf, void *addr, const TConfiguration *config)
void ReadSTLObjectWiseStreamerV2(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers, UInt_t start)
void ReadArraySTLMemberWiseSameClass(TBuffer &buf, void *addr, const TConfiguration *conf, Version_t vers)
void HandleReferencedTObject(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t PopDataCacheGenericCollection(TBuffer &b, void *, const void *, const TLoopConfiguration *, const TConfiguration *)
Int_t ReadStreamerCase(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t PushDataCacheGenericCollection(TBuffer &b, void *, const void *, const TLoopConfiguration *loopconfig, const TConfiguration *conf)
Int_t ReadTextTObjectBase(TBuffer &buf, void *addr, const TConfiguration *config)
ESelectLooper SelectLooper(TVirtualCollectionProxy &proxy)
Int_t ReadTString(TBuffer &buf, void *addr, const TConfiguration *config)
Int_t UseCacheGenericCollection(TBuffer &b, void *, const void *, const TLoopConfiguration *loopconfig, const TConfiguration *conf)
void WriteSTLMemberWise(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t WriteBasicZero(TBuffer &buf, void *, const TConfiguration *)
Int_t ReadViaClassBuffer(TBuffer &buf, void *addr, const TConfiguration *config)
TVirtualCollectionProxy::Next_t Next_t
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
static void Action(TBuffer &buf, void *addr, Int_t nvalues)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
static void LoopOverCollection(TBuffer &buf, void *iter, const void *end, Next_t next, Int_t, const TStreamerElement *elem)
static void SimpleWriteFloat16(TBuffer &buf, void *addr, const TStreamerElement *elem)
static Int_t WriteCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
static void SimpleRead(TBuffer &buf, void *addr, Int_t nvalues)
static void ArrayWrite(TBuffer &buf, void *addr, Int_t nvalues, const TStreamerElement *)
static Int_t WriteCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t ReadCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
static void SimpleReadDouble32(TBuffer &buf, void *addr, Int_t nvalues)
static void SimpleWrite(TBuffer &buf, void *addr, const TStreamerElement *)
static void ConvertLoopOverCollection(TBuffer &buf, void *iter, const void *end, Next_t next, Int_t nvalues, const TStreamerElement *elem)
static void ArrayWriteCompressed(TBuffer &buf, double *addr, Int_t nvalues, const TStreamerElement *elem)
static void SimpleWriteDouble32(TBuffer &buf, void *addr, const TStreamerElement *elem)
static Int_t ReadCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
void(*)(TBuffer &, void *, const void *, Next_t, Int_t, const TStreamerElement *elem) LoopAction_t
static Int_t ReadCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
static void ArrayWriteCompressed(TBuffer &buf, float *addr, Int_t nvalues, const TStreamerElement *elem)
static void SimpleReadFloat16(TBuffer &buf, void *addr, Int_t nvalues)
static Int_t WriteNumericalCollection(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t WriteCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t ReadNumericalCollection(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t Action(TBuffer &buf, void *start, Ts... args, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *start, Ts... args, const TConfiguration *config)
static Int_t ReadStreamerLoopStatic(TBuffer &buf, void *addr, const TConfiguration *config)
static Int_t SubSequenceAction(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *, const TConfiguration *config)
static std::unique_ptr< TStreamerInfoActions::TActionSequence > CreateWriteActionSequence(TStreamerInfo &info, TLoopConfiguration *loopConfig)
static Int_t WriteStreamerLoopStatic(TBuffer &buf, void *addr, const TConfiguration *config)
static Int_t WriteStreamerLoopPoly(TBuffer &buf, void *addr, const TConfiguration *config)
static Int_t ReadStreamerLoopPoly(TBuffer &buf, void *addr, const TConfiguration *config)
static Int_t WriteStreamerCase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static std::unique_ptr< TStreamerInfoActions::TActionSequence > CreateReadActionSequence(TStreamerInfo &info, TLoopConfiguration *loopConfig)
static Int_t StreamerLoopExternal(TBuffer &buf, void *addr, const TConfiguration *actionConfig)
static Int_t ReadStreamerCase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
static void WriteConvertAction(void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config, To *items)
static void ConvertAction(From *items, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static void WriteConvertAction(void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *, To *items)
static void ConvertAction(From *items, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *)
static Int_t Action(TBuffer &, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t Action(TBuffer &, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t Action(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t ReadBasicType(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
CollectionLooper< GenericLooper >::ReadStreamerLoop< kIsText, const void *, const TLoopConfiguration * > ReadStreamerLoop
static Int_t ReadCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t WriteBase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t WriteNumericalCollection(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t ReadBase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t WriteBasicType(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t GenericRead(TBuffer &buf, void *, const void *, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t WriteCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t WriteCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t WriteCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
static void SimpleWriteFloat16(TBuffer &buf, void *addr)
static void SimpleReadFloat16(TBuffer &buf, void *addr)
Int_t(*)(TBuffer &, void *, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *) LoopAction_t
static Int_t LoopOverCollection(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t ReadNumericalCollection(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t GenericWrite(TBuffer &buf, void *, const void *, const TLoopConfiguration *loopconf, const TConfiguration *config)
static Int_t ReadCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
static void SimpleRead(TBuffer &buf, void *addr)
static void SimpleReadDouble32(TBuffer &buf, void *addr)
static void SimpleWriteDouble32(TBuffer &buf, void *addr)
static Int_t ReadCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
CollectionLooper< GenericLooper >::WriteStreamerLoop< kIsText, const void *, const TLoopConfiguration * > WriteStreamerLoop
Int_t(*)(TBuffer &, void *, const TConfiguration *) LoopAction_t
static Int_t LoopOverCollection(TBuffer &buf, void *start, const TConfiguration *config)
TBitsConfiguration(TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset=0)
void PrintDebug(TBuffer &, void *) const override
TConfObject(TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, TClass *onfileClass, TClass *inMemoryClass)
TConfStreamerLoop(TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, bool isPtrPtr)
TConfSubSequence(const TConfSubSequence &input)
TConfSubSequence(TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset, std::unique_ptr< TStreamerInfoActions::TActionSequence > actions)
std::unique_ptr< TStreamerInfoActions::TActionSequence > fActions
TGenericConfiguration(TVirtualStreamerInfo *info, UInt_t id, TCompInfo_t *compinfo, Int_t offset=0)
void PrintDebug(TBuffer &, void *) const override
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *conf)
CollectionLooper< VectorLooper >::ReadStreamerLoop< kIsText, const void *, const TLoopConfiguration * > ReadStreamerLoop
static Int_t WriteCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t WriteCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
Int_t(*)(TBuffer &, void *, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *) LoopAction_t
static Int_t WriteBasicType(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t WriteCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t GenericWrite(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t ReadCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
CollectionLooper< VectorLooper >::WriteStreamerLoop< kIsText, const void *, const TLoopConfiguration * > WriteStreamerLoop
static Int_t ConvertCollectionDouble32(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t ReadCollectionBasicType(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t ReadBasicType(TBuffer &buf, void *iter, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t WriteBase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t ReadBase(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t ReadCollectionFloat16(TBuffer &buf, void *addr, const TConfiguration *conf)
static Int_t GenericRead(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t LoopOverCollection(TBuffer &buf, void *start, const void *end, const TLoopConfiguration *loopconfig, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
Int_t(*)(TBuffer &, void *start, const void *end, const TConfiguration *) LoopAction_t
static Int_t ReadBase(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
static Int_t ReadBasicType(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static std::unique_ptr< TStreamerInfoActions::TActionSequence > CreateWriteActionSequence(TStreamerInfo &info, TLoopConfiguration *)
static Int_t LoopOverCollection(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
static Int_t GenericRead(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t WriteBasicType(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t GenericWrite(TBuffer &buf, void *iter, const void *end, const TConfiguration *config)
static Int_t WriteBase(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
CollectionLooper< VectorPtrLooper >::ReadStreamerLoop< kIsText, const void * > ReadStreamerLoop
static std::unique_ptr< TStreamerInfoActions::TActionSequence > CreateReadActionSequence(TStreamerInfo &info, TLoopConfiguration *)
CollectionLooper< VectorPtrLooper >::WriteStreamerLoop< kIsText, const void * > WriteStreamerLoop
static Int_t SubSequenceAction(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
static Int_t WriteStreamerCase(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
static Int_t ReadStreamerCase(TBuffer &buf, void *start, const void *end, const TConfiguration *config)
static Int_t Action(TBuffer &buf, void *addr, const TConfiguration *config)