26 #include "TClassEdit.h" 145 template <
typename From,
typename To>
148 From *
r = getaddress<From>( *read );
149 To *w = getaddress<To>( *write );
150 for(
int i = 0; i < nElements; ++i) {
156 template <
typename From>
161 ConvertArray<From,bool>(
read,
write,nElements);
164 ConvertArray<From,Char_t>(
read,
write,nElements);
167 ConvertArray<From,Short_t>(
read,
write,nElements);
170 ConvertArray<From,Int_t>(
read,
write,nElements);
173 ConvertArray<From,Long64_t>(
read,
write,nElements);
176 ConvertArray<From,Long64_t>(
read,
write,nElements);
179 ConvertArray<From,Float_t>(
read,
write,nElements);
182 ConvertArray<From,Float16_t>(
read,
write,nElements);
185 ConvertArray<From,Double_t>(
read,
write,nElements);
188 ConvertArray<From,UChar_t>(
read,
write,nElements);
191 ConvertArray<From,UShort_t>(
read,
write,nElements);
194 ConvertArray<From,UInt_t>(
read,
write,nElements);
197 ConvertArray<From,ULong_t>(
read,
write,nElements);
200 ConvertArray<From,ULong64_t>(
read,
write,nElements);
203 ConvertArray<From,Double32_t>(
read,
write,nElements);
208 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n", writeType);
223 case ROOT::kSTLvector:
236 itmstore = (
StreamHelper*)(len <
sizeof(buffer) ? buffer : memory =::operator
new(len));
300 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n", readkind);
305 DispatchConvertArray<bool>(
fVal->
fKind, itmread, itmstore, nElements);
308 DispatchConvertArray<Char_t>(
fVal->
fKind, itmread, itmstore, nElements);
311 DispatchConvertArray<Short_t>(
fVal->
fKind, itmread, itmstore, nElements);
314 DispatchConvertArray<Int_t>(
fVal->
fKind, itmread, itmstore, nElements);
317 DispatchConvertArray<Long_t>(
fVal->
fKind, itmread, itmstore, nElements);
320 DispatchConvertArray<Long64_t>(
fVal->
fKind, itmread, itmstore, nElements);
323 DispatchConvertArray<Float_t>(
fVal->
fKind, itmread, itmstore, nElements);
326 DispatchConvertArray<Float16_t>(
fVal->
fKind, itmread, itmstore, nElements);
329 DispatchConvertArray<Double_t>(
fVal->
fKind, itmread, itmstore, nElements);
332 DispatchConvertArray<UChar_t>(
fVal->
fKind, itmread, itmstore, nElements);
335 DispatchConvertArray<UShort_t>(
fVal->
fKind, itmread, itmstore, nElements);
338 DispatchConvertArray<UInt_t>(
fVal->
fKind, itmread, itmstore, nElements);
341 DispatchConvertArray<ULong_t>(
fVal->
fKind, itmread, itmstore, nElements);
344 DispatchConvertArray<ULong64_t>(
fVal->
fKind, itmread, itmstore, nElements);
347 DispatchConvertArray<Double_t>(
fVal->
fKind, itmread, itmstore, nElements);
352 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n", readkind);
354 ::operator
delete((
void*)itmconv);
359 ::operator
delete(memory);
378 case ROOT::kSTLvector:
379 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)(((char*)itm) + fValDiff*idx); { x ;} ++idx;} break;} 393 DOLOOP(i->read_std_string(b));
397 DOLOOP(i->read_std_string_pointer(b));
399 DOLOOP(i->read_tstring_pointer(vsn3, b));
407 case ROOT::kSTLforwardlist:
408 case ROOT::kSTLdeque:
409 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)TGenCollectionProxy::At(idx); { x ;} ++idx;} break;} 417 DOLOOP(i->read_std_string(b));
421 DOLOOP(i->read_std_string_pointer(b));
423 DOLOOP(i->read_tstring_pointer(vsn3, b));
430 case ROOT::kSTLmultiset:
432 case ROOT::kSTLunorderedset:
433 case ROOT::kSTLunorderedmultiset:
434 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)(((char*)itm) + fValDiff*idx); { x ;} ++idx;}} 444 DOLOOP(i->read_std_string(b))
453 DOLOOP(i->read_std_string_pointer(b))
457 DOLOOP(i->read_tstring_pointer(vsn3, b));
467 ::operator
delete(memory);
486 std::vector<std::string> inside;
487 TClassEdit::GetSplit(pinfo->
GetName(), inside, nested);
495 case ROOT::kSTLvector:
496 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)(((char*)itm) + fValDiff*idx); { x ;} ++idx;} break;} 519 case ROOT::kSTLforwardlist:
520 case ROOT::kSTLdeque:
521 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)TGenCollectionProxy::At(idx); { x ;} ++idx;} break;} 532 char **where = (
char**)(
void*) & i;
541 case ROOT::kSTLmultiset:
543 case ROOT::kSTLunorderedset:
544 case ROOT::kSTLunorderedmultiset:
545 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)(((char*)itm) + fValDiff*idx); { x ;} ++idx;}} 551 char **where = (
char**)(
void*) & i;
564 ::operator
delete(memory);
578 switch (
int(v->
fKind)) {
629 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n", v->
fKind);
650 template <
typename To>
721 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n", readtype);
733 char buffer[8096], *addr, *temp;
738 fEnv->
fStart = (len <
sizeof(buffer) ? buffer : memory =::
operator new(len));
742 int onFileValueKind[2];
749 for (
int loop, idx = 0; idx < nElements; ++idx) {
752 for (loop = 0; loop < 2; loop++) {
758 int readtype = (int)(onFileValueKind[loop]);
759 switch (
int(v->
fKind)) {
761 i->
boolean = readOneValue<bool>(
b,readtype);
764 i->
s_char = readOneValue<Char_t>(
b,readtype);
767 i->
s_short = readOneValue<Short_t>(
b,readtype);
770 i->
s_int = readOneValue<Int_t>(
b,readtype);
773 i->
s_long = readOneValue<Long_t>(
b,readtype);
776 i->
s_longlong = readOneValue<Long64_t>(
b,readtype);
779 i->
flt = readOneValue<Float_t>(
b,readtype);
782 i->
flt = readOneValue<Float16_t>(
b,readtype);
785 i->
dbl = readOneValue<Double_t>(
b,readtype);
788 i->
u_char = readOneValue<UChar_t>(
b,readtype);
791 i->
u_short = readOneValue<UShort_t>(
b,readtype);
794 i->
u_int = readOneValue<UInt_t>(
b,readtype);
797 i->
u_long = readOneValue<ULong_t>(
b,readtype);
800 i->
u_longlong = readOneValue<ULong64_t>(
b,readtype);
803 i->
dbl = readOneValue<Double32_t>(
b,readtype);
808 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n", v->
fKind);
811 switch (
int(v->
fKind)) {
862 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n", v->
fKind);
889 ::operator
delete(memory);
901 case ROOT::kSTLvector:
960 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n",
fVal->
fKind);
963 ::operator
delete(memory);
973 case ROOT::kSTLvector:
974 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)(((char*)itm) + fValDiff*idx); { x ;} ++idx;} break;} 987 DOLOOP(i->write_std_string_pointer(b));
990 DOLOOP(i->write_tstring_pointer(b));
999 case ROOT::kSTLforwardlist:
1000 case ROOT::kSTLdeque:
1001 case ROOT::kSTLmultiset:
1003 case ROOT::kSTLunorderedset:
1004 case ROOT::kSTLunorderedmultiset:
1005 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)TGenCollectionProxy::At(idx); { x ;} ++idx;} break;} 1014 DOLOOP(i->write_std_string_pointer(b));
1016 DOLOOP(i->write_tstring_pointer(b));
1031 for (
int loop, idx = 0; idx < nElements; ++idx) {
1034 for (loop = 0; loop < 2; ++loop) {
1039 switch (
int(v->
fKind)) {
1088 Error(
"TGenCollectionStreamer",
"fType %d is not supported yet!\n", v->
fKind);
1113 template <
typename From,
typename To>
1116 From *temp =
new From[nElements];
1118 std::vector<To> *
const vec = (std::vector<To>*)(obj);
1119 for(
Int_t ind = 0; ind < nElements; ++ind) {
1120 (*vec)[ind] = (To)temp[ind];
1125 template <
typename To>
1130 std::vector<To> *
const vec = (std::vector<To>*)(obj);
1131 for(
Int_t ind = 0; ind < nElements; ++ind) {
1132 (*vec)[ind] = (To)temp[ind];
1137 template <
typename To>
1142 std::vector<To> *
const vec = (std::vector<To>*)(obj);
1143 for(
Int_t ind = 0; ind < nElements; ++ind) {
1144 (*vec)[ind] = (To)temp[ind];
1149 template <
typename To>
1172 template <
typename basictype>
1180 DispatchConvertBufferVectorPrimitives<basictype>(
b,obj,nElements,onFileClass->
GetCollectionProxy());
1195 DispatchConvertBufferVectorPrimitives<Float16_t>(
b,obj,nElements,onFileClass->
GetCollectionProxy());
1210 DispatchConvertBufferVectorPrimitives<Double32_t>(
b,obj,nElements,onFileClass->
GetCollectionProxy());
1244 Fatal(
"TGenCollectionStreamer::ReadBufferDefault",
"No CreateIterators function for %s",
fName.c_str());
1254 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<Char_t>;
1257 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<Short_t>;
1260 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<Int_t>;
1263 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<Long_t>;
1266 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<Long64_t>;
1269 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<Float_t>;
1275 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<Double_t>;
1278 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<UChar_t>;
1281 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<UShort_t>;
1284 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<UInt_t>;
1287 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<ULong_t>;
1290 fReadBufferFunc = &TGenCollectionStreamer::ReadBufferVectorPrimitives<ULong64_t>;
1312 if (nElements == 0) {
1316 }
else if (nElements > 0) {
1318 case ROOT::kSTLbitset:
1328 case ROOT::kSTLvector:
1347 case ROOT::kSTLlist:
1348 case ROOT::kSTLforwardlist:
1349 case ROOT::kSTLdeque:
1350 case ROOT::kSTLmultiset:
1352 case ROOT::kSTLunorderedset:
1353 case ROOT::kSTLunorderedmultiset:
1372 case ROOT::kSTLmultimap:
1373 case ROOT::kSTLunorderedmap:
1374 case ROOT::kSTLunorderedmultimap:
1382 ReadMap(nElements, b, onFileClass);
1397 if (nElements > 0) {
1399 case ROOT::kSTLbitset:
1402 case ROOT::kSTLvector:
1403 case ROOT::kSTLlist:
1404 case ROOT::kSTLdeque:
1405 case ROOT::kSTLmultiset:
1407 case ROOT::kSTLunorderedset:
1408 case ROOT::kSTLunorderedmultiset:
1420 case ROOT::kSTLmultimap:
1421 case ROOT::kSTLunorderedmap:
1422 case ROOT::kSTLunorderedmultimap:
1430 if (nElements > 0) {
1432 case ROOT::kSTLbitset:
1435 case ROOT::kSTLvector:
1436 case ROOT::kSTLlist:
1437 case ROOT::kSTLforwardlist:
1438 case ROOT::kSTLdeque:
1439 case ROOT::kSTLmultiset:
1441 case ROOT::kSTLunorderedset:
1442 case ROOT::kSTLunorderedmultiset:
1454 case ROOT::kSTLmultimap:
1455 case ROOT::kSTLunorderedmap:
1456 case ROOT::kSTLunorderedmultimap:
1473 if (nElements > 0) {
1476 case ROOT::kSTLmultimap:
1477 case ROOT::kSTLunorderedmap:
1478 case ROOT::kSTLunorderedmultimap:
1481 case ROOT::kSTLvector:
1482 case ROOT::kSTLlist:
1483 case ROOT::kSTLforwardlist:
1484 case ROOT::kSTLdeque:
1485 case ROOT::kSTLmultiset:
1487 case ROOT::kSTLunorderedset:
1488 case ROOT::kSTLunorderedmultiset:{
Describe Streamer information for one class version.
Method fSize
Container accessors: size of container.
virtual const char * GetName() const
Returns name of object.
UShort_t * getaddress< UShort_t >(TGenCollectionProxy::StreamHelper &itm)
double read(const std::string &file_name)
reading
virtual void ReadBuffer(TBuffer &b, void *obj, const TClass *onfileClass)
virtual void WriteFastArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0)=0
void ReadBufferVectorPrimitivesDouble32(TBuffer &b, void *obj, const TClass *onFileClass)
void CreateIterators(void *collection)
ULong_t * getaddress< ULong_t >(TGenCollectionProxy::StreamHelper &itm)
void WriteMap(int nElements, TBuffer &b)
double write(int n, const std::string &file_name, const std::string &vector_type, int compress=0)
writing
void Fatal(const char *location, const char *msgfmt,...)
virtual TVirtualCollectionProxy * Generate() const
Virtual copy constructor.
Equal to TDataType's kchar.
Collectfunc_t fCollect
Method to collect objects from container.
std::string fName
Name of the class being proxied.
virtual TClass * GetValueClass() const =0
virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass)=0
Char_t * getaddress< Char_t >(TGenCollectionProxy::StreamHelper &itm)
void write_tstring_pointer(TBuffer &b)
static T * getaddress(TGenCollectionProxy::StreamHelper &itm)
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist...
Method fFirst
Container accessors: generic iteration: first.
Buffer base class used for serializing objects.
void ReadBufferGeneric(TBuffer &b, void *obj, const TClass *onFileClass)
virtual EDataType GetType() const
If the content is a simple numerical value, return its type (see TDataType)
TClass * fOnFileClass
On file class.
Feedfunc_t fFeed
Container accessors: block feed.
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
TGenCollectionStreamer(const TGenCollectionStreamer ©)
TObject * At(Int_t idx) const
void ReadPrimitives(int nElements, TBuffer &b, const TClass *onfileClass)
UInt_t fCase
type of data of Value_type
void DispatchConvertArray(int writeType, TGenCollectionProxy::StreamHelper *read, TGenCollectionProxy::StreamHelper *write, int nElements)
virtual EDataType GetType() const =0
Sizing_t fResize
Container accessors: resize container.
void ReadPairFromMap(int nElements, TBuffer &b)
virtual TVirtualStreamerInfo * GetInfo()=0
void * invoke(void *obj) const
V GetOffset(E val1, E val2, V iso)
Long64_t * getaddress< Long64_t >(TGenCollectionProxy::StreamHelper &itm)
virtual void StreamerAsMap(TBuffer &refBuffer)
void ConvertBufferVectorPrimitives(TBuffer &b, void *obj, Int_t nElements)
void read_std_string(TBuffer &b)
To readOneValue(TBuffer &b, int readtype)
virtual CreateIterators_t GetFunctionCreateIterators(Bool_t read=kTRUE)
See typedef void (*CreateIterators_t)(void *collection, void *&begin_arena, void *&end_arena); begin_...
void WritePrimitives(int nElements, TBuffer &b)
Short_t * getaddress< Short_t >(TGenCollectionProxy::StreamHelper &itm)
void WriteObjects(int nElements, TBuffer &b)
Method fClear
Method cache for container accessors: clear container.
ArrIterfunc_t fConstruct
Container accessors: block construct.
void Error(const char *location, const char *msgfmt,...)
EDataType fKind
kind of ROOT-fundamental type
void ReadBufferDefault(TBuffer &b, void *obj, const TClass *onFileClass)
UChar_t * getaddress< UChar_t >(TGenCollectionProxy::StreamHelper &itm)
int fValOffset
Offset from key to value (in maps)
TGenCollectionProxy * Initialize(Bool_t silent) const
Proxy initializer.
ReadBuffer_t fReadBufferFunc
void read_std_string_pointer(TBuffer &b)
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0)=0
int fSTL_type
STL container type.
Long_t * getaddress< Long_t >(TGenCollectionProxy::StreamHelper &itm)
virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object)=0
virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=0)=0
void ReadBufferVectorPrimitivesFloat16(TBuffer &b, void *obj, const TClass *onFileClass)
CreateIterators_t fFunctionCreateIterators
The ROOT global object gROOT contains a list of all defined classes.
void ReadMap(int nElements, TBuffer &b, const TClass *onfileClass)
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
void ConvertBufferVectorPrimitivesDouble32(TBuffer &b, void *obj, Int_t nElements)
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
int fValDiff
Offset between two consecutive value_types (memory layout).
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=0)=0
virtual ULong_t GetIncrement() const =0
ULong64_t * getaddress< ULong64_t >(TGenCollectionProxy::StreamHelper &itm)
void ReadBufferVectorPrimitives(TBuffer &b, void *obj, const TClass *onFileClass)
Float_t * getaddress< Float_t >(TGenCollectionProxy::StreamHelper &itm)
virtual TObjArray * GetElements() const =0
virtual TGenCollectionProxy * InitializeEx(Bool_t silent)
Proxy initializer.
unsigned long long ULong64_t
UInt_t * getaddress< UInt_t >(TGenCollectionProxy::StreamHelper &itm)
void write_std_string_pointer(TBuffer &b)
virtual void * ReadObjectAny(const TClass *cast)=0
virtual Version_t GetOldVersion() const =0
std::atomic< Value * > fValue
Descriptor of the container value type.
TClassRef fType
TClass reference of Value_type in collection.
virtual void Clear(const char *opt="")
Clear the emulated collection.
TObjArray * GetElements() const
virtual void * At(UInt_t idx)
Return the address of the value at index 'idx'.
Value * fKey
Descriptor of the key_type.
void ConvertBufferVectorPrimitivesFloat16(TBuffer &b, void *obj, Int_t nElements)
virtual void Streamer(TBuffer &refBuffer)
Streamer Function.
Helper class to facilitate I/O.
Proxy around an arbitrary container, which implements basic functionality and iteration.
EnvironBase_t * fEnv
Address of the currently proxied object.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Sizing_t fDestruct
Container accessors: block destruct.
virtual ~TGenCollectionStreamer()
bool * getaddress< bool >(TGenCollectionProxy::StreamHelper &itm)
Int_t * getaddress< Int_t >(TGenCollectionProxy::StreamHelper &itm)
Double_t * getaddress< Double_t >(TGenCollectionProxy::StreamHelper &itm)
TStreamerInfoActions::TActionSequence * GetReadObjectWiseActions()
void ReadObjects(int nElements, TBuffer &b, const TClass *onfileClass)
Abstract Interface class describing Streamer information for one class.
const std::type_info & Info_t
void ReadMapHelper(StreamHelper *i, Value *v, Bool_t vsn3, TBuffer &b)
void DispatchConvertBufferVectorPrimitives(TBuffer &b, void *obj, Int_t nElements, const TVirtualCollectionProxy *onfileProxy)
void ConvertArray(TGenCollectionProxy::StreamHelper *read, TGenCollectionProxy::StreamHelper *write, int nElements)
virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)=0
Small helper to describe the Value_type or the key_type of an STL container.
void read_tstring_pointer(Bool_t vsn3, TBuffer &b)
Value * fVal
Descriptor of the Value_type.
EReadWrite
EReadWrite Enumerator Enum Constant Description kBase Base class element kOffsetL Fixed size array k...