Logo ROOT   6.10/09
Reference Guide
TBuffer.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Rene Brun, Philippe Canal, Fons Rademakers 04/05/96
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 #ifndef ROOT_TBuffer
13 #define ROOT_TBuffer
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TBuffer //
19 // //
20 // Buffer base class used for serializing objects. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TObject.h"
25 
26 #include <vector>
27 
29 class TStreamerElement;
30 class TClass;
31 class TString;
32 class TProcessID;
33 class TClonesArray;
34 class TRefTable;
35 class TVirtualArray;
37  class TActionSequence;
38 }
39 
40 class TBuffer : public TObject {
41 
42 protected:
43  typedef std::vector<TVirtualArray*> CacheList_t;
44 
45  Bool_t fMode; //Read or write mode
46  Int_t fVersion; //Buffer format version
47  Int_t fBufSize; //Size of buffer
48  char *fBuffer; //Buffer used to store objects
49  char *fBufCur; //Current position in buffer
50  char *fBufMax; //End of buffer
51  TObject *fParent; //Pointer to parent object owning this buffer
52  ReAllocCharFun_t fReAllocFunc; //! Realloc function to be used when extending the buffer.
53  CacheList_t fCacheStack; //Stack of pointers to the cache where to temporarily store the value of 'missing' data members
54 
55  // Default ctor
56  TBuffer() : TObject(), fMode(0), fVersion(0), fBufSize(0), fBuffer(0),
57  fBufCur(0), fBufMax(0), fParent(0), fReAllocFunc(0), fCacheStack(0,(TVirtualArray*)0) {}
58 
59  // TBuffer objects cannot be copied or assigned
60  TBuffer(const TBuffer &); // not implemented
61  void operator=(const TBuffer &); // not implemented
62 
63  Int_t Read(const char *name) { return TObject::Read(name); }
64  Int_t Write(const char *name, Int_t opt, Int_t bufs)
65  { return TObject::Write(name, opt, bufs); }
66  Int_t Write(const char *name, Int_t opt, Int_t bufs) const
67  { return TObject::Write(name, opt, bufs); }
68 
69 public:
70  enum EMode { kRead = 0, kWrite = 1 };
71  enum { kIsOwner = BIT(16) }; //if set TBuffer owns fBuffer
72  enum { kCannotHandleMemberWiseStreaming = BIT(17)}; //if set TClonesArray should not use member wise streaming
73  enum { kInitialSize = 1024, kMinimalSize = 128 };
74 
75  TBuffer(EMode mode);
76  TBuffer(EMode mode, Int_t bufsiz);
77  TBuffer(EMode mode, Int_t bufsiz, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = 0);
78  virtual ~TBuffer();
79 
80  Int_t GetBufferVersion() const { return fVersion; }
81  Bool_t IsReading() const { return (fMode & kWrite) == 0; }
82  Bool_t IsWriting() const { return (fMode & kWrite) != 0; }
83  void SetReadMode();
84  void SetWriteMode();
85  void SetBuffer(void *buf, UInt_t bufsiz = 0, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = 0);
86  ReAllocCharFun_t GetReAllocFunc() const;
87  void SetReAllocFunc(ReAllocCharFun_t reallocfunc = 0);
88  void SetBufferOffset(Int_t offset = 0) { fBufCur = fBuffer+offset; }
89  void SetParent(TObject *parent);
90  TObject *GetParent() const;
91  char *Buffer() const { return fBuffer; }
92  Int_t BufferSize() const { return fBufSize; }
93  void DetachBuffer() { fBuffer = 0; }
94  Int_t Length() const { return (Int_t)(fBufCur - fBuffer); }
95  void Expand(Int_t newsize, Bool_t copy = kTRUE); // expand buffer to newsize
96  void AutoExpand(Int_t size_needed); // expand buffer to newsize
97 
98  virtual Bool_t CheckObject(const TObject *obj) = 0;
99  virtual Bool_t CheckObject(const void *obj, const TClass *ptrClass) = 0;
100 
101  virtual Int_t ReadBuf(void *buf, Int_t max) = 0;
102  virtual void WriteBuf(const void *buf, Int_t max) = 0;
103 
104  virtual char *ReadString(char *s, Int_t max) = 0;
105  virtual void WriteString(const char *s) = 0;
106 
107  virtual Int_t GetVersionOwner() const = 0;
108  virtual Int_t GetMapCount() const = 0;
109  virtual void GetMappedObject(UInt_t tag, void* &ptr, TClass* &ClassPtr) const = 0;
110  virtual void MapObject(const TObject *obj, UInt_t offset = 1) = 0;
111  virtual void MapObject(const void *obj, const TClass *cl, UInt_t offset = 1) = 0;
112  virtual void Reset() = 0;
113  virtual void InitMap() = 0;
114  virtual void ResetMap() = 0;
115  virtual void SetReadParam(Int_t mapsize) = 0;
116  virtual void SetWriteParam(Int_t mapsize) = 0;
117 
118  virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss) = 0;
119  virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname) = 0;
120  virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion = kFALSE)= 0;
121 
122  virtual void SkipVersion(const TClass *cl = 0) = 0;
123  virtual Version_t ReadVersion(UInt_t *start = 0, UInt_t *bcnt = 0, const TClass *cl = 0) = 0;
124  virtual Version_t ReadVersionNoCheckSum(UInt_t *start = 0, UInt_t *bcnt = 0) = 0;
125  virtual Version_t ReadVersionForMemberWise(const TClass *cl = 0) = 0;
126  virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt = kFALSE) = 0;
127  virtual UInt_t WriteVersionMemberWise(const TClass *cl, Bool_t useBcnt = kFALSE) = 0;
128 
129  virtual void *ReadObjectAny(const TClass* cast) = 0;
130  virtual void SkipObjectAny() = 0;
131 
132  virtual void TagStreamerInfo(TVirtualStreamerInfo* info) = 0;
133  virtual void IncrementLevel(TVirtualStreamerInfo* info) = 0;
134  virtual void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type) = 0;
135  virtual void DecrementLevel(TVirtualStreamerInfo*) = 0;
136 
137  virtual void ClassBegin(const TClass*, Version_t = -1) = 0;
138  virtual void ClassEnd(const TClass*) = 0;
139  virtual void ClassMember(const char*, const char* = 0, Int_t = -1, Int_t = -1) = 0;
140  virtual TVirtualStreamerInfo *GetInfo() = 0;
141 
142  virtual TVirtualArray *PeekDataCache() const;
143  virtual TVirtualArray *PopDataCache();
144  virtual void PushDataCache(TVirtualArray *);
145 
146  virtual TClass *ReadClass(const TClass *cl = 0, UInt_t *objTag = 0) = 0;
147  virtual void WriteClass(const TClass *cl) = 0;
148 
149  virtual TObject *ReadObject(const TClass *cl) = 0;
150  virtual void WriteObject(const TObject *obj) = 0;
151 
152  virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass) = 0;
153 
154  virtual UShort_t GetPidOffset() const = 0;
155  virtual void SetPidOffset(UShort_t offset) = 0;
156  virtual Int_t GetBufferDisplacement() const = 0;
157  virtual void SetBufferDisplacement() = 0;
158  virtual void SetBufferDisplacement(Int_t skipped) = 0;
159 
160  // basic types and arrays of basic types
161  virtual void ReadFloat16 (Float_t *f, TStreamerElement *ele=0) = 0;
162  virtual void WriteFloat16(Float_t *f, TStreamerElement *ele=0) = 0;
163  virtual void ReadDouble32 (Double_t *d, TStreamerElement *ele=0) = 0;
164  virtual void WriteDouble32(Double_t *d, TStreamerElement *ele=0) = 0;
165  virtual void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue) = 0;
166  virtual void ReadWithNbits(Float_t *ptr, Int_t nbits) = 0;
167  virtual void ReadWithFactor(Double_t *ptr, Double_t factor, Double_t minvalue) = 0;
168  virtual void ReadWithNbits(Double_t *ptr, Int_t nbits) = 0;
169 
170  virtual Int_t ReadArray(Bool_t *&b) = 0;
171  virtual Int_t ReadArray(Char_t *&c) = 0;
172  virtual Int_t ReadArray(UChar_t *&c) = 0;
173  virtual Int_t ReadArray(Short_t *&h) = 0;
174  virtual Int_t ReadArray(UShort_t *&h) = 0;
175  virtual Int_t ReadArray(Int_t *&i) = 0;
176  virtual Int_t ReadArray(UInt_t *&i) = 0;
177  virtual Int_t ReadArray(Long_t *&l) = 0;
178  virtual Int_t ReadArray(ULong_t *&l) = 0;
179  virtual Int_t ReadArray(Long64_t *&l) = 0;
180  virtual Int_t ReadArray(ULong64_t *&l) = 0;
181  virtual Int_t ReadArray(Float_t *&f) = 0;
182  virtual Int_t ReadArray(Double_t *&d) = 0;
183  virtual Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=0) = 0;
184  virtual Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele=0) = 0;
185 
186  virtual Int_t ReadStaticArray(Bool_t *b) = 0;
187  virtual Int_t ReadStaticArray(Char_t *c) = 0;
188  virtual Int_t ReadStaticArray(UChar_t *c) = 0;
189  virtual Int_t ReadStaticArray(Short_t *h) = 0;
190  virtual Int_t ReadStaticArray(UShort_t *h) = 0;
191  virtual Int_t ReadStaticArray(Int_t *i) = 0;
192  virtual Int_t ReadStaticArray(UInt_t *i) = 0;
193  virtual Int_t ReadStaticArray(Long_t *l) = 0;
194  virtual Int_t ReadStaticArray(ULong_t *l) = 0;
195  virtual Int_t ReadStaticArray(Long64_t *l) = 0;
196  virtual Int_t ReadStaticArray(ULong64_t *l) = 0;
197  virtual Int_t ReadStaticArray(Float_t *f) = 0;
198  virtual Int_t ReadStaticArray(Double_t *d) = 0;
199  virtual Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele=0) = 0;
200  virtual Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele=0) = 0;
201 
202  virtual void ReadFastArray(Bool_t *b, Int_t n) = 0;
203  virtual void ReadFastArray(Char_t *c, Int_t n) = 0;
204  virtual void ReadFastArrayString(Char_t *c, Int_t n) = 0;
205  virtual void ReadFastArray(UChar_t *c, Int_t n) = 0;
206  virtual void ReadFastArray(Short_t *h, Int_t n) = 0;
207  virtual void ReadFastArray(UShort_t *h, Int_t n) = 0;
208  virtual void ReadFastArray(Int_t *i, Int_t n) = 0;
209  virtual void ReadFastArray(UInt_t *i, Int_t n) = 0;
210  virtual void ReadFastArray(Long_t *l, Int_t n) = 0;
211  virtual void ReadFastArray(ULong_t *l, Int_t n) = 0;
212  virtual void ReadFastArray(Long64_t *l, Int_t n) = 0;
213  virtual void ReadFastArray(ULong64_t *l, Int_t n) = 0;
214  virtual void ReadFastArray(Float_t *f, Int_t n) = 0;
215  virtual void ReadFastArray(Double_t *d, Int_t n) = 0;
216  virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=0) = 0;
217  virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0) = 0;
218  virtual void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue) = 0;
219  virtual void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits) = 0;
220  virtual void ReadFastArrayWithFactor(Double_t *ptr, Int_t n, Double_t factor, Double_t minvalue) = 0;
221  virtual void ReadFastArrayWithNbits(Double_t *ptr, Int_t n, Int_t nbits) = 0;
222  virtual void ReadFastArray(void *start , const TClass *cl, Int_t n=1, TMemberStreamer *s=0, const TClass *onFileClass=0) = 0;
223  virtual void ReadFastArray(void **startp, const TClass *cl, Int_t n=1, Bool_t isPreAlloc=kFALSE, TMemberStreamer *s=0, const TClass *onFileClass=0) = 0;
224 
225  virtual void WriteArray(const Bool_t *b, Int_t n) = 0;
226  virtual void WriteArray(const Char_t *c, Int_t n) = 0;
227  virtual void WriteArray(const UChar_t *c, Int_t n) = 0;
228  virtual void WriteArray(const Short_t *h, Int_t n) = 0;
229  virtual void WriteArray(const UShort_t *h, Int_t n) = 0;
230  virtual void WriteArray(const Int_t *i, Int_t n) = 0;
231  virtual void WriteArray(const UInt_t *i, Int_t n) = 0;
232  virtual void WriteArray(const Long_t *l, Int_t n) = 0;
233  virtual void WriteArray(const ULong_t *l, Int_t n) = 0;
234  virtual void WriteArray(const Long64_t *l, Int_t n) = 0;
235  virtual void WriteArray(const ULong64_t *l, Int_t n) = 0;
236  virtual void WriteArray(const Float_t *f, Int_t n) = 0;
237  virtual void WriteArray(const Double_t *d, Int_t n) = 0;
238  virtual void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0) = 0;
239  virtual void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0) = 0;
240 
241  virtual void WriteFastArray(const Bool_t *b, Int_t n) = 0;
242  virtual void WriteFastArray(const Char_t *c, Int_t n) = 0;
243  virtual void WriteFastArrayString(const Char_t *c, Int_t n) = 0;
244  virtual void WriteFastArray(const UChar_t *c, Int_t n) = 0;
245  virtual void WriteFastArray(const Short_t *h, Int_t n) = 0;
246  virtual void WriteFastArray(const UShort_t *h, Int_t n) = 0;
247  virtual void WriteFastArray(const Int_t *i, Int_t n) = 0;
248  virtual void WriteFastArray(const UInt_t *i, Int_t n) = 0;
249  virtual void WriteFastArray(const Long_t *l, Int_t n) = 0;
250  virtual void WriteFastArray(const ULong_t *l, Int_t n) = 0;
251  virtual void WriteFastArray(const Long64_t *l, Int_t n) = 0;
252  virtual void WriteFastArray(const ULong64_t *l, Int_t n) = 0;
253  virtual void WriteFastArray(const Float_t *f, Int_t n) = 0;
254  virtual void WriteFastArray(const Double_t *d, Int_t n) = 0;
255  virtual void WriteFastArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0) = 0;
256  virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0) = 0;
257  virtual void WriteFastArray(void *start, const TClass *cl, Int_t n=1, TMemberStreamer *s=0) = 0;
258  virtual Int_t WriteFastArray(void **startp, const TClass *cl, Int_t n=1, Bool_t isPreAlloc=kFALSE, TMemberStreamer *s=0) = 0;
259 
260  virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass* onFileClass = 0 ) = 0;
261  virtual void StreamObject(void *obj, const char *className, const TClass* onFileClass = 0 ) = 0;
262  virtual void StreamObject(void *obj, const TClass *cl, const TClass* onFileClass = 0 ) = 0;
263  virtual void StreamObject(TObject *obj) = 0;
264 
265  virtual void ReadBool(Bool_t &b) = 0;
266  virtual void ReadChar(Char_t &c) = 0;
267  virtual void ReadUChar(UChar_t &c) = 0;
268  virtual void ReadShort(Short_t &s) = 0;
269  virtual void ReadUShort(UShort_t &s) = 0;
270  virtual void ReadInt(Int_t &i) = 0;
271  virtual void ReadUInt(UInt_t &i) = 0;
272  virtual void ReadLong(Long_t &l) = 0;
273  virtual void ReadULong(ULong_t &l) = 0;
274  virtual void ReadLong64(Long64_t &l) = 0;
275  virtual void ReadULong64(ULong64_t &l) = 0;
276  virtual void ReadFloat(Float_t &f) = 0;
277  virtual void ReadDouble(Double_t &d) = 0;
278  virtual void ReadCharP(Char_t *c) = 0;
279  virtual void ReadTString(TString &s) = 0;
280  virtual void ReadStdString(std::string *s) = 0;
281  virtual void ReadCharStar(char* &s) = 0;
282 
283  virtual inline void ReadStdString(std::string &s) { ReadStdString(&s); }
284 
285  virtual void WriteBool(Bool_t b) = 0;
286  virtual void WriteChar(Char_t c) = 0;
287  virtual void WriteUChar(UChar_t c) = 0;
288  virtual void WriteShort(Short_t s) = 0;
289  virtual void WriteUShort(UShort_t s) = 0;
290  virtual void WriteInt(Int_t i) = 0;
291  virtual void WriteUInt(UInt_t i) = 0;
292  virtual void WriteLong(Long_t l) = 0;
293  virtual void WriteULong(ULong_t l) = 0;
294  virtual void WriteLong64(Long64_t l) = 0;
295  virtual void WriteULong64(ULong64_t l) = 0;
296  virtual void WriteFloat(Float_t f) = 0;
297  virtual void WriteDouble(Double_t d) = 0;
298  virtual void WriteCharP(const Char_t *c) = 0;
299  virtual void WriteTString(const TString &s) = 0;
300  virtual void WriteStdString(const std::string *s) = 0;
301  virtual void WriteCharStar(char *s) = 0;
302 
303  virtual inline void WriteStdString(std::string &s) { WriteStdString(&s); }
304 
305  // Special basic ROOT objects and collections
306  virtual TProcessID *GetLastProcessID(TRefTable *reftable) const = 0;
307  virtual UInt_t GetTRefExecId() = 0;
308  virtual TProcessID *ReadProcessID(UShort_t pidf) = 0;
309  virtual UShort_t WriteProcessID(TProcessID *pid) = 0;
310 
311  // Utilities for TStreamerInfo
312  virtual void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) = 0;
313  virtual void ForceWriteInfoClones(TClonesArray *a) = 0;
314  virtual Int_t ReadClones (TClonesArray *a, Int_t nobjects, Version_t objvers) = 0;
315  virtual Int_t WriteClones(TClonesArray *a, Int_t nobjects) = 0;
316 
317  // Utilities for TClass
318  virtual Int_t ReadClassEmulated(const TClass *cl, void *object, const TClass *onfile_class = 0) = 0;
319  virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class = 0) = 0;
320  virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, Int_t version, UInt_t start, UInt_t count, const TClass *onfile_class = 0) = 0;
321  virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer) = 0;
322 
323  // Utilites to streamer using sequences.
324  virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object) = 0;
325  virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection) = 0;
326  virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection) = 0;
327 
328  static TClass *GetClass(const std::type_info &typeinfo);
329  static TClass *GetClass(const char *className);
330 
331  ClassDef(TBuffer,0) //Buffer base class used for serializing objects
332 };
333 
334 //---------------------- TBuffer default external operators --------------------
335 
336 inline TBuffer &operator>>(TBuffer &buf, Bool_t &b) { buf.ReadBool(b); return buf; }
337 inline TBuffer &operator>>(TBuffer &buf, Char_t &c) { buf.ReadChar(c); return buf; }
338 inline TBuffer &operator>>(TBuffer &buf, UChar_t &c) { buf.ReadUChar(c); return buf; }
339 inline TBuffer &operator>>(TBuffer &buf, Short_t &s) { buf.ReadShort(s); return buf; }
340 inline TBuffer &operator>>(TBuffer &buf, UShort_t &s) { buf.ReadUShort(s); return buf; }
341 inline TBuffer &operator>>(TBuffer &buf, Int_t &i) { buf.ReadInt(i); return buf; }
342 inline TBuffer &operator>>(TBuffer &buf, UInt_t &i) { buf.ReadUInt(i); return buf; }
343 inline TBuffer &operator>>(TBuffer &buf, Long_t &l) { buf.ReadLong(l); return buf; }
344 inline TBuffer &operator>>(TBuffer &buf, ULong_t &l) { buf.ReadULong(l); return buf; }
345 inline TBuffer &operator>>(TBuffer &buf, Long64_t &l) { buf.ReadLong64(l); return buf; }
346 inline TBuffer &operator>>(TBuffer &buf, ULong64_t &l){ buf.ReadULong64(l);return buf; }
347 inline TBuffer &operator>>(TBuffer &buf, Float_t &f) { buf.ReadFloat(f); return buf; }
348 inline TBuffer &operator>>(TBuffer &buf, Double_t &d) { buf.ReadDouble(d); return buf; }
349 inline TBuffer &operator>>(TBuffer &buf, Char_t *c) { buf.ReadCharP(c); return buf; }
350 inline TBuffer &operator>>(TBuffer &buf, TString &s) { buf.ReadTString(s);return buf; }
351 
352 inline TBuffer &operator<<(TBuffer &buf, Bool_t b) { buf.WriteBool(b); return buf; }
353 inline TBuffer &operator<<(TBuffer &buf, Char_t c) { buf.WriteChar(c); return buf; }
354 inline TBuffer &operator<<(TBuffer &buf, UChar_t c) { buf.WriteUChar(c); return buf; }
355 inline TBuffer &operator<<(TBuffer &buf, Short_t s) { buf.WriteShort(s); return buf; }
356 inline TBuffer &operator<<(TBuffer &buf, UShort_t s) { buf.WriteUShort(s); return buf; }
357 inline TBuffer &operator<<(TBuffer &buf, Int_t i) { buf.WriteInt(i); return buf; }
358 inline TBuffer &operator<<(TBuffer &buf, UInt_t i) { buf.WriteUInt(i); return buf; }
359 inline TBuffer &operator<<(TBuffer &buf, Long_t l) { buf.WriteLong(l); return buf; }
360 inline TBuffer &operator<<(TBuffer &buf, ULong_t l) { buf.WriteULong(l); return buf; }
361 inline TBuffer &operator<<(TBuffer &buf, Long64_t l) { buf.WriteLong64(l); return buf; }
362 inline TBuffer &operator<<(TBuffer &buf, ULong64_t l){ buf.WriteULong64(l);return buf; }
363 inline TBuffer &operator<<(TBuffer &buf, Float_t f) { buf.WriteFloat(f); return buf; }
364 inline TBuffer &operator<<(TBuffer &buf, Double_t d) { buf.WriteDouble(d); return buf; }
365 inline TBuffer &operator<<(TBuffer &buf, const Char_t *c) { buf.WriteCharP(c); return buf; }
366 inline TBuffer &operator<<(TBuffer &buf, const TString &s) { buf.WriteTString(s);return buf; }
367 
368 #ifndef __CINT__
369 
370 #if defined(R__SOLARIS) && defined(R__GNU)
371 #include <typeinfo>
372 #endif
373 
374 template <class Tmpl> TBuffer &operator>>(TBuffer &buf, Tmpl *&obj)
375 {
376  // Read TObject derived classes from a TBuffer. Need to provide
377  // custom version for non-TObject derived classes.
378 
379  // This operator has to be a templated and/or automatically
380  // generated if we want to be able to check the type of the
381  // incoming object. I.e. a operator>>(TBuffer &buf, TObject *&)
382  // would not be sufficient to pass the information 'which class do we want'
383  // since the pointer could be zero (so typeid(*obj) is not usable).
384 
385  TClass *cl = TBuffer::GetClass(typeid(Tmpl));
386  obj = (Tmpl *) ( (void*) buf.ReadObjectAny(cl) );
387  return buf;
388 }
389 
390 template <class Tmpl> TBuffer &operator<<(TBuffer &buf, const Tmpl *obj)
391 {
392  TClass *cl = (obj) ? TBuffer::GetClass(typeid(*obj)) : 0;
393  buf.WriteObjectAny(obj, cl);
394  return buf;
395 }
396 #else
397 template <class Tmpl> TBuffer &operator>>(TBuffer &buf, Tmpl *&obj);
398 template <class Tmpl> TBuffer &operator<<(TBuffer &buf, Tmpl *&obj);
399 #endif
400 
401 #if defined(R__TEMPLATE_OVERLOAD_BUG)
402 template <>
403 #endif
404 inline TBuffer &operator<<(TBuffer &buf, const TObject *obj)
405  { buf.WriteObjectAny(obj, TObject::Class()); return buf; }
406 
407 #endif
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:778
void SetBufferOffset(Int_t offset=0)
Definition: TBuffer.h:88
Bool_t IsReading() const
Definition: TBuffer.h:81
Bool_t IsWriting() const
Definition: TBuffer.h:82
virtual void WriteBool(Bool_t b)=0
long long Long64_t
Definition: RtypesCore.h:69
char * fBuffer
Definition: TBuffer.h:48
short Version_t
Definition: RtypesCore.h:61
Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TBuffer.h:63
float Float_t
Definition: RtypesCore.h:53
virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass)=0
Bool_t fMode
Definition: TBuffer.h:45
unsigned short UShort_t
Definition: RtypesCore.h:36
#define BIT(n)
Definition: Rtypes.h:75
TH1 * h
Definition: legend2.C:5
ReAllocCharFun_t fReAllocFunc
Definition: TBuffer.h:52
char *(* ReAllocCharFun_t)(char *, size_t, size_t)
Definition: TStorage.h:30
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual void WriteDouble(Double_t d)=0
virtual void ReadShort(Short_t &s)=0
Basic string class.
Definition: TString.h:129
std::vector< TVirtualArray * > CacheList_t
Definition: TBuffer.h:43
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
virtual void WriteTString(const TString &s)=0
INLINE_TEMPLATE_ARGS Int_t ReadTString(TBuffer &buf, void *addr, const TConfiguration *config)
virtual void WriteLong64(Long64_t l)=0
virtual void ReadChar(Char_t &c)=0
virtual void ReadUChar(UChar_t &c)=0
virtual void ReadInt(Int_t &i)=0
Int_t Length() const
Definition: TBuffer.h:94
TClass * GetClass(T *)
Definition: TClass.h:545
#define ClassDef(name, id)
Definition: Rtypes.h:297
void Class()
Definition: Class.C:29
virtual void WriteUShort(UShort_t s)=0
char * Buffer() const
Definition: TBuffer.h:91
virtual void ReadDouble(Double_t &d)=0
static TClass * GetClass(const std::type_info &typeinfo)
Forward to TROOT::GetClass().
Definition: TBuffer.cxx:297
virtual void ReadLong(Long_t &l)=0
virtual void ReadUInt(UInt_t &i)=0
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition: TObject.cxx:555
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:69
virtual void WriteFloat(Float_t f)=0
virtual void WriteStdString(std::string &s)
Definition: TBuffer.h:303
CacheList_t fCacheStack
Realloc function to be used when extending the buffer.
Definition: TBuffer.h:53
Int_t fVersion
Definition: TBuffer.h:46
virtual void ReadBool(Bool_t &b)=0
virtual void ReadULong(ULong_t &l)=0
Wrapper around an object and giving indirect access to its content even if the object is not of a cla...
Definition: TVirtualArray.h:26
virtual void WriteCharP(const Char_t *c)=0
virtual void ReadUShort(UShort_t &s)=0
virtual void WriteInt(Int_t i)=0
virtual void ReadCharP(Char_t *c)=0
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void WriteShort(Short_t s)=0
short Short_t
Definition: RtypesCore.h:35
TLine * l
Definition: textangle.C:4
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
char * fBufCur
Definition: TBuffer.h:49
void Reset(Detail::TBranchProxy *x)
Int_t GetBufferVersion() const
Definition: TBuffer.h:80
virtual void WriteChar(Char_t c)=0
TBuffer & operator>>(TBuffer &buf, Bool_t &b)
Definition: TBuffer.h:336
const Bool_t kFALSE
Definition: RtypesCore.h:92
long Long_t
Definition: RtypesCore.h:50
TBuffer & operator<<(TBuffer &buf, Bool_t b)
Definition: TBuffer.h:352
Int_t Write(const char *name, Int_t opt, Int_t bufs)
Write this object to the current directory.
Definition: TBuffer.h:64
TObject * fParent
Definition: TBuffer.h:51
virtual void WriteUInt(UInt_t i)=0
double f(double x)
double Double_t
Definition: RtypesCore.h:55
unsigned long long ULong64_t
Definition: RtypesCore.h:70
unsigned long ULong_t
Definition: RtypesCore.h:51
virtual void ReadULong64(ULong64_t &l)=0
A TRefTable maintains the association between a referenced object and the parent object supporting th...
Definition: TRefTable.h:35
virtual void * ReadObjectAny(const TClass *cast)=0
Int_t BufferSize() const
Definition: TBuffer.h:92
virtual void ReadTString(TString &s)=0
virtual void WriteLong(Long_t l)=0
Binding & operator=(OUT(*fun)(void))
virtual void ReadLong64(Long64_t &l)=0
Mother of all ROOT objects.
Definition: TObject.h:37
TBuffer()
Definition: TBuffer.h:56
char Char_t
Definition: RtypesCore.h:29
An array of clone (identical) objects.
Definition: TClonesArray.h:32
virtual void WriteUChar(UChar_t c)=0
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
Definition: TRolke.cxx:630
virtual void WriteULong(ULong_t l)=0
Int_t fBufSize
Definition: TBuffer.h:47
unsigned char UChar_t
Definition: RtypesCore.h:34
virtual void ReadFloat(Float_t &f)=0
Int_t Write(const char *name, Int_t opt, Int_t bufs) const
Write this object to the current directory.
Definition: TBuffer.h:66
Abstract Interface class describing Streamer information for one class.
void DetachBuffer()
Definition: TBuffer.h:93
const Bool_t kTRUE
Definition: RtypesCore.h:91
const Int_t n
Definition: legend1.C:16
char * fBufMax
Definition: TBuffer.h:50
virtual void WriteULong64(ULong64_t l)=0
virtual void ReadStdString(std::string &s)
Definition: TBuffer.h:283