Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TStreamerElement.h
Go to the documentation of this file.
1 // @(#)root/meta:$Id: e0eac11e63ad37390c9467c97c5c6849c4ab7d39 $
2 // Author: Rene Brun 12/10/2000
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TStreamerElement
13 #define ROOT_TStreamerElement
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TStreamerElement //
19 // //
20 // Describe one element (data member) to be Streamed //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TNamed.h"
25 
26 #include "ESTLType.h"
27 
28 class TMethodCall;
29 class TClass;
30 class TStreamerBasicType;
31 class TVirtualStreamerInfo;
32 
33 class TStreamerElement : public TNamed {
34 
35 private:
36  TStreamerElement(const TStreamerElement &); // Not implemented
37  TStreamerElement&operator=(const TStreamerElement&); // Not implemented
38 
39 protected:
40  Int_t fType; //element type
41  Int_t fSize; //sizeof element
42  Int_t fArrayLength; //cumulative size of all array dims
43  Int_t fArrayDim; //number of array dimensions
44  Int_t fMaxIndex[5]; //Maximum array index for array dimension "dim"
45  Int_t fOffset; //!element offset in class
46  Int_t fTObjectOffset; //!base offset for TObject if the element inherits from it
47  Int_t fNewType; //!new element type when reading
48  TString fTypeName; //Data type name of data member
49  TClass *fClassObject; //!pointer to class of object
50  TClass *fNewClass; //!new element class when reading
51  TMemberStreamer *fStreamer; //!pointer to element Streamer
52  Double_t fXmin; //!Minimum of data member if a range is specified [xmin,xmax,nbits]
53  Double_t fXmax; //!Maximum of data member if a range is specified [xmin,xmax,nbits]
54  Double_t fFactor; //!Conversion factor if a range is specified fFactor = (1<<nbits/(xmax-xmin)
55 
56 public:
57 
58  enum ESTLtype {
59  kSTL = ROOT::kSTLany,
60  kSTLstring = ROOT::kSTLstring,
61  kSTLvector = ROOT::kSTLvector,
62  kSTLlist = ROOT::kSTLlist,
63  kSTLforwardlist = ROOT::kSTLforwardlist,
64  kSTLdeque = ROOT::kSTLdeque,
65  kSTLmap = ROOT::kSTLmap,
66  kSTLmultimap = ROOT::kSTLmultimap,
67  kSTLset = ROOT::kSTLset,
68  kSTLmultiset = ROOT::kSTLmultiset,
69  kSTLunorderedset = ROOT::kSTLunorderedset,
70  kSTLunorderedmultiset = ROOT::kSTLunorderedmultiset,
71  kSTLunorderedmap = ROOT::kSTLunorderedmap,
72  kSTLunorderedmultimap = ROOT::kSTLunorderedmultimap,
73  kSTLbitset = ROOT::kSTLbitset
74  };
75  // TStreamerElement status bits
76  enum EStatusBits {
77  kHasRange = BIT(6),
78  kCache = BIT(9),
79  kRepeat = BIT(10),
80  kRead = BIT(11),
81  kWrite = BIT(12),
82  kDoNotDelete = BIT(13),
83  kWholeObject = BIT(14),
84  kWarned = BIT(21)
85  };
86 
87  enum class EStatusBitsDupExceptions {
88  // This bit duplicates TObject::kInvalidObject. As the semantic of kDoNotDelete is a persistent,
89  // we can not change its value without breaking forward compatibility.
90  // Furthermore, TObject::kInvalidObject and its semantic is not (and should not be)
91  // used in TStreamerElement
92  kDoNotDelete = TStreamerElement::kDoNotDelete,
93 
94  // This bit duplicates TObject::kCannotPick. As the semantic of kHasRange is a persistent,
95  // we can not change its value without breaking forward compatibility.
96  // Furthermore, TObject::kCannotPick and its semantic is not (and should not be)
97  // used in TStreamerElement
98  kHasRange = TStreamerElement::kHasRange
99  };
100 
101 
102  TStreamerElement();
103  TStreamerElement(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName);
104  virtual ~TStreamerElement();
105  virtual Bool_t CannotSplit() const;
106  Int_t GetArrayDim() const {return fArrayDim;}
107  Int_t GetArrayLength() const {return fArrayLength;}
108  virtual TClass *GetClassPointer() const;
109  TClass *GetClass() const {return GetClassPointer();}
110  virtual Int_t GetExecID() const;
111  virtual const char *GetFullName() const;
112  virtual const char *GetInclude() const {return "";}
113  Int_t GetMaxIndex(Int_t i) const {return fMaxIndex[i];}
114  virtual ULong_t GetMethod() const {return ULong_t(fStreamer);}
115  TMemberStreamer *GetStreamer() const;
116  virtual Int_t GetSize() const;
117  Int_t GetNewType() const {return fNewType;}
118  TClass* GetNewClass() const { return fNewClass; }
119  Int_t GetType() const {return fType;}
120  Int_t GetOffset() const {return fOffset;}
121  void GetSequenceType(TString &type) const;
122  Int_t GetTObjectOffset() const { return fTObjectOffset; }
123  const char *GetTypeName() const {return fTypeName.Data();}
124  const char *GetTypeNameBasic() const;
125  Double_t GetFactor() const {return fFactor;}
126  Double_t GetXmin() const {return fXmin;}
127  Double_t GetXmax() const {return fXmax;}
128  virtual void Init(TVirtualStreamerInfo *obj=0);
129  virtual Bool_t IsaPointer() const {return kFALSE;}
130  virtual Bool_t HasCounter() const {return kFALSE;}
131  virtual Bool_t IsOldFormat(const char *newTypeName);
132  virtual Bool_t IsBase() const;
133  virtual Bool_t IsTransient() const;
134  virtual void ls(Option_t *option="") const;
135  virtual void SetArrayDim(Int_t dim);
136  virtual void SetMaxIndex(Int_t dim, Int_t max);
137  virtual void SetOffset(Int_t offset) {fOffset=offset;}
138  virtual void SetTObjectOffset(Int_t tobjoffset) {fTObjectOffset=tobjoffset;}
139  virtual void SetStreamer(TMemberStreamer *streamer);
140  virtual void SetSize(Int_t dsize) {fSize = dsize;}
141  virtual void SetNewType(Int_t dtype) {fNewType = dtype;}
142  virtual void SetNewClass( TClass* cl ) { fNewClass= cl; }
143  virtual void SetType(Int_t dtype) {fType = dtype;}
144  virtual void SetTypeName(const char *name) {fTypeName = name; fClassObject = (TClass*)-1; }
145  virtual void Update(const TClass *oldClass, TClass *newClass);
146 
147  ClassDef(TStreamerElement,4) //Base class for one element (data member) to be Streamed
148 };
149 
150 //________________________________________________________________________
151 class TStreamerBase : public TStreamerElement {
152 
153 private:
154  TStreamerBase(const TStreamerBase &); // Not implemented
155  TStreamerBase&operator=(const TStreamerBase&); // Not implemented
156 
157 protected:
158  Int_t fBaseVersion; //version number of the base class (used during memberwise streaming)
159  UInt_t &fBaseCheckSum; //!checksum of the base class (used during memberwise streaming)
160  TClass *fBaseClass; //!pointer to base class
161  TClass *fNewBaseClass; //!pointer to new base class if renamed
162  ClassStreamerFunc_t fStreamerFunc; //!Pointer to a wrapper around a custom streamer member function.
163  ClassConvStreamerFunc_t fConvStreamerFunc; //!Pointer to a wrapper around a custom convertion streamer member function.
164  TVirtualStreamerInfo *fStreamerInfo; //!Pointer to the current StreamerInfo for the baset class.
165  TString fErrorMsg; //!Error message in case of checksum/version mismatch.
166 
167  void InitStreaming();
168 
169 public:
170 
171  TStreamerBase();
172  TStreamerBase(const char *name, const char *title, Int_t offset);
173  virtual ~TStreamerBase();
174  Int_t GetBaseVersion() {return fBaseVersion;}
175  UInt_t GetBaseCheckSum() {return fBaseCheckSum;}
176  virtual TClass *GetClassPointer() const;
177  const char *GetErrorMessage() const { return fErrorMsg; }
178  const char *GetInclude() const;
179  TClass *GetNewBaseClass() { return fNewBaseClass; }
180  ULong_t GetMethod() const {return 0;}
181  Int_t GetSize() const;
182  TVirtualStreamerInfo *GetBaseStreamerInfo () const { return fStreamerInfo; }
183  virtual void Init(TVirtualStreamerInfo *obj=0);
184  Bool_t IsBase() const;
185  virtual void ls(Option_t *option="") const;
186  Int_t ReadBuffer (TBuffer &b, char *pointer);
187  void SetNewBaseClass( TClass* cl ) { fNewBaseClass = cl; InitStreaming(); }
188  void SetBaseVersion(Int_t v) {fBaseVersion = v;}
189  void SetBaseCheckSum(UInt_t cs) {fBaseCheckSum = cs;}
190  void SetErrorMessage(const char *msg) { fErrorMsg = msg; }
191  virtual void Update(const TClass *oldClass, TClass *newClass);
192  Int_t WriteBuffer(TBuffer &b, char *pointer);
193 
194  ClassDef(TStreamerBase,3) //Streamer element of type base class
195 };
196 
197 //________________________________________________________________________
198 class TStreamerBasicPointer : public TStreamerElement {
199 
200 private:
201  TStreamerBasicPointer(const TStreamerBasicPointer &); // Not implemented
202  TStreamerBasicPointer&operator=(const TStreamerBasicPointer&); // Not implemented
203 
204 protected:
205  Int_t fCountVersion; //version number of the class with the counter
206  TString fCountName; //name of data member holding the array count
207  TString fCountClass; //name of the class with the counter
208  TStreamerBasicType *fCounter; //!pointer to basic type counter
209 
210 public:
211 
212  TStreamerBasicPointer();
213  TStreamerBasicPointer(const char *name, const char *title, Int_t offset, Int_t dtype,
214  const char *countName, const char *countClass, Int_t version, const char *typeName);
215  virtual ~TStreamerBasicPointer();
216  TClass *GetClassPointer() const { return 0; }
217  const char *GetCountClass() const {return fCountClass.Data();}
218  const char *GetCountName() const {return fCountName.Data();}
219  Int_t GetCountVersion() const {return fCountVersion;}
220  ULong_t GetMethod() const;
221  Int_t GetSize() const;
222  virtual void Init(TVirtualStreamerInfo *obj=0);
223  virtual Bool_t HasCounter() const {return fCounter!=0; }
224  virtual Bool_t IsaPointer() const {return kTRUE; }
225  void SetArrayDim(Int_t dim);
226  void SetCountClass(const char *clname) {fCountClass = clname; }
227  void SetCountName(const char *name) {fCountName = name; }
228  void SetCountVersion(Int_t count) {fCountVersion = count;}
229  virtual void Update(const TClass * /* oldClass */, TClass * /*newClass*/ ) {}
230 
231  ClassDef(TStreamerBasicPointer,2) //Streamer element for a pointer to a basic type
232 };
233 
234 //________________________________________________________________________
235 class TStreamerLoop : public TStreamerElement {
236 
237 private:
238  TStreamerLoop(const TStreamerLoop&); // Not implemented
239  TStreamerLoop&operator=(const TStreamerLoop&); // Not implemented
240 
241 protected:
242  Int_t fCountVersion; //version number of the class with the counter
243  TString fCountName; //name of data member holding the array count
244  TString fCountClass; //name of the class with the counter
245  TStreamerBasicType *fCounter; //!pointer to basic type counter
246 
247 public:
248 
249  TStreamerLoop();
250  TStreamerLoop(const char *name, const char *title, Int_t offset, const char *countName, const char *countClass, Int_t version, const char *typeName);
251  virtual ~TStreamerLoop();
252  const char *GetCountClass() const {return fCountClass.Data();}
253  const char *GetCountName() const {return fCountName.Data();}
254  Int_t GetCountVersion() const {return fCountVersion;}
255  const char *GetInclude() const;
256  ULong_t GetMethod() const;
257  Int_t GetSize() const;
258  virtual void Init(TVirtualStreamerInfo *obj=0);
259  virtual Bool_t IsaPointer() const {return kTRUE; }
260  virtual Bool_t HasCounter() const {return fCounter!=0; }
261  void SetCountClass(const char *clname) {fCountClass = clname; }
262  void SetCountName(const char *name) {fCountName = name; }
263  void SetCountVersion(Int_t count) {fCountVersion = count;}
264 
265  ClassDef(TStreamerLoop,2) //Streamer element for a pointer to an array of objects
266 };
267 
268 //________________________________________________________________________
269 class TStreamerBasicType : public TStreamerElement {
270 
271 private:
272  TStreamerBasicType(const TStreamerBasicType&); // Not implemented
273  TStreamerBasicType&operator=(const TStreamerBasicType&); // Not implemented
274 
275 protected:
276  Int_t fCounter; //!value of data member when referenced by an array
277 
278 public:
279 
280  TStreamerBasicType();
281  TStreamerBasicType(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName);
282  virtual ~TStreamerBasicType();
283  TClass *GetClassPointer() const { return 0; }
284  Int_t GetCounter() const {return fCounter;}
285  ULong_t GetMethod() const;
286  Int_t GetSize() const;
287  virtual void Update(const TClass * /* oldClass */, TClass * /* newClass */) {}
288 
289  ClassDef(TStreamerBasicType,2) //Streamer element for a basic type
290 };
291 
292 //________________________________________________________________________
293 class TStreamerObject : public TStreamerElement {
294 
295 private:
296  TStreamerObject(const TStreamerObject&); // Not implemented
297  TStreamerObject&operator=(const TStreamerObject&); // Not implemented
298 
299 public:
300 
301  TStreamerObject();
302  TStreamerObject(const char *name, const char *title, Int_t offset, const char *typeName);
303  virtual ~TStreamerObject();
304  const char *GetInclude() const;
305  Int_t GetSize() const;
306  virtual void Init(TVirtualStreamerInfo *obj=0);
307 
308  ClassDef(TStreamerObject,2) //Streamer element of type object
309 };
310 
311 //________________________________________________________________________
312 class TStreamerObjectAny : public TStreamerElement {
313 
314 private:
315  TStreamerObjectAny(const TStreamerObjectAny&); // Not implemented
316  TStreamerObjectAny&operator=(const TStreamerObjectAny&); // Not implemented
317 
318 public:
319 
320  TStreamerObjectAny();
321  TStreamerObjectAny(const char *name, const char *title, Int_t offset, const char *typeName);
322  virtual ~TStreamerObjectAny();
323  const char *GetInclude() const;
324  Int_t GetSize() const;
325  virtual void Init(TVirtualStreamerInfo *obj=0);
326 
327  ClassDef(TStreamerObjectAny,2) //Streamer element of type object other than TObject
328 };
329 
330 //________________________________________________________________________
331 class TStreamerObjectPointer : public TStreamerElement {
332 
333 private:
334  TStreamerObjectPointer(const TStreamerObjectPointer&); // Not implemented
335  TStreamerObjectPointer&operator=(const TStreamerObjectPointer&); // Not implemented
336 
337 public:
338 
339  TStreamerObjectPointer();
340  TStreamerObjectPointer(const char *name, const char *title, Int_t offset, const char *typeName);
341  virtual ~TStreamerObjectPointer();
342  const char *GetInclude() const;
343  Int_t GetSize() const;
344  virtual void Init(TVirtualStreamerInfo *obj=0);
345  virtual Bool_t IsaPointer() const {return kTRUE;}
346  virtual void SetArrayDim(Int_t dim);
347 
348  ClassDef(TStreamerObjectPointer,2) //Streamer element of type pointer to a TObject
349 };
350 
351 //________________________________________________________________________
352 class TStreamerObjectAnyPointer : public TStreamerElement {
353 
354 private:
355  TStreamerObjectAnyPointer(const TStreamerObjectAnyPointer&); // Not implemented
356  TStreamerObjectAnyPointer&operator=(const TStreamerObjectAnyPointer&); // Not implemented
357 
358 public:
359 
360  TStreamerObjectAnyPointer();
361  TStreamerObjectAnyPointer(const char *name, const char *title, Int_t offset, const char *typeName);
362  virtual ~TStreamerObjectAnyPointer();
363  const char *GetInclude() const;
364  Int_t GetSize() const;
365  virtual void Init(TVirtualStreamerInfo *obj=0);
366  virtual Bool_t IsaPointer() const {return kTRUE;}
367  virtual void SetArrayDim(Int_t dim);
368 
369  ClassDef(TStreamerObjectAnyPointer,1) //Streamer element of type pointer to a non TObject
370 };
371 
372 //________________________________________________________________________
373 class TStreamerString : public TStreamerElement {
374 
375 private:
376  TStreamerString(const TStreamerString&); // Not implemented
377  TStreamerString&operator=(const TStreamerString&); // Not implemented
378 
379 public:
380 
381  TStreamerString();
382  TStreamerString(const char *name, const char *title, Int_t offset);
383  virtual ~TStreamerString();
384  const char *GetInclude() const;
385  Int_t GetSize() const;
386 
387  ClassDef(TStreamerString,2) //Streamer element of type TString
388 };
389 
390 //________________________________________________________________________
391 class TStreamerSTL : public TStreamerElement {
392 
393 private:
394  TStreamerSTL(const TStreamerSTL&); // Not implemented
395  TStreamerSTL&operator=(const TStreamerSTL&); // Not implemented
396 
397 protected:
398  Int_t fSTLtype; //type of STL vector
399  Int_t fCtype; //STL contained type
400 
401 public:
402 
403  TStreamerSTL();
404  TStreamerSTL(const char *name, const char *title, Int_t offset,
405  const char *typeName, const char *trueType, Bool_t dmPointer);
406  TStreamerSTL(const char *name, const char *title, Int_t offset,
407  const char *typeName, const TVirtualCollectionProxy &proxy , Bool_t dmPointer);
408  virtual ~TStreamerSTL();
409  Bool_t CannotSplit() const;
410  Bool_t IsaPointer() const;
411  Bool_t IsBase() const;
412  Int_t GetSTLtype() const {return fSTLtype;}
413  Int_t GetCtype() const {return fCtype;}
414  const char *GetInclude() const;
415  Int_t GetSize() const;
416  virtual void ls(Option_t *option="") const;
417  void SetSTLtype(Int_t t) {fSTLtype = t;}
418  void SetCtype(Int_t t) {fCtype = t;}
419  virtual void SetStreamer(TMemberStreamer *streamer);
420 
421  ClassDef(TStreamerSTL,3) //Streamer element of type STL container
422 };
423 
424 //________________________________________________________________________
425 class TStreamerSTLstring : public TStreamerSTL {
426 
427 private:
428  TStreamerSTLstring(const TStreamerSTLstring&); // Not implemented
429  TStreamerSTLstring&operator=(const TStreamerSTLstring&); // Not implemented
430 
431 public:
432 
433  TStreamerSTLstring();
434  TStreamerSTLstring(const char *name, const char *title, Int_t offset,
435  const char *typeName, Bool_t dmPointer);
436  virtual ~TStreamerSTLstring();
437  const char *GetInclude() const;
438  Int_t GetSize() const;
439 
440  ClassDef(TStreamerSTLstring,2) //Streamer element of type C++ string
441 };
442 
443 class TVirtualObject;
444 class TBuffer;
445 
446 #include "TSchemaRule.h"
447 
448 //________________________________________________________________________
449 class TStreamerArtificial : public TStreamerElement {
450 private:
451  TStreamerArtificial(const TStreamerArtificial&); // Not implemented
452  TStreamerArtificial&operator=(const TStreamerArtificial&); // Not implemented
453 
454 protected:
455  ROOT::TSchemaRule::ReadFuncPtr_t fReadFunc; //!
456  ROOT::TSchemaRule::ReadRawFuncPtr_t fReadRawFunc; //!
457 
458 public:
459 
460  // TStreamerArtificial() : fReadFunc(0),fReadRawFunc(0) {}
461 
462  TStreamerArtificial(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName) : TStreamerElement(name,title,offset,dtype,typeName), fReadFunc(0), fReadRawFunc(0) {}
463 
464  void SetReadFunc( ROOT::TSchemaRule::ReadFuncPtr_t val ) { fReadFunc = val; };
465  void SetReadRawFunc( ROOT::TSchemaRule::ReadRawFuncPtr_t val ) { fReadRawFunc = val; };
466 
467  ROOT::TSchemaRule::ReadFuncPtr_t GetReadFunc();
468  ROOT::TSchemaRule::ReadRawFuncPtr_t GetReadRawFunc();
469 
470  ClassDef(TStreamerArtificial, 0); // StreamerElement injected by a TSchemaRule. Transient only to preverse forward compatibility.
471 };
472 
473 #endif