Logo ROOT   6.19/01
Reference Guide
TVirtualStreamerInfo.h
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Rene Brun 05/02/2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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_TVirtualStreamerInfo
13 #define ROOT_TVirtualStreamerInfo
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TVirtualStreamerInfo Abstract Interface class //
19 // //
20 // Abstract Interface describing Streamer information for one class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TNamed.h"
25 
26 #include "ESTLType.h"
27 
28 class TFile;
29 class TClass;
30 class TObjArray;
31 class TStreamerElement;
32 class TStreamerBasicType;
34 class TClassStreamer;
35 namespace ROOT { namespace Detail { class TCollectionProxyInfo; } }
36 
37 class TVirtualStreamerInfo : public TNamed {
38 
39 protected:
40  Bool_t fOptimized : 1; //! true if the StreamerInfo has been optimized
41  Bool_t fIsBuilt : 1; //! true if the StreamerInfo has been 'built' (i.e. has all the StreamerElements it should have)
42  std::atomic<Bool_t> fIsCompiled; //! true if the StreamerInfo has been compiled (i.e. fully built, ready to use for streaming).
43 
44 protected:
45  static Bool_t fgCanDelete; //True if ReadBuffer can delete object
46  static Bool_t fgOptimize; //True if optimization on
47  static Bool_t fgStreamMemberWise; //True if the collections are to be stream "member-wise" (when possible).
49 
52 
53  void ResetIsCompiled() {
55  ResetBit(kIsCompiled); /* for backward compatibility */
56  }
57  void SetIsCompiled() {
59  SetBit(kIsCompiled); /* for backward compatibility */
60  }
61 
62 public:
63 
64  //status bits
65  enum EStatusBits {
67  kIgnoreTObjectStreamer = BIT(13), // eventhough BIT(13) is taken up by TObject (to preserve forward compatibility)
68  kRecovered = BIT(14),
69  kNeedCheck = BIT(15),
73  };
74 
76  // This bit duplicates TObject::kInvalidObject. As the semantic of kIgnoreTObjectStreamer is a persistent,
77  // we can not change its value without breaking forward compatibility.
78  // Furthermore, TObject::kInvalidObject and its semantic is not (and should not be)
79  // used in TVirtualStreamerInfo
81  };
82 
83  enum EReadWrite {
84  kBase = 0, kOffsetL = 20, kOffsetP = 40, kCounter = 6, kCharStar = 7,
85  kChar = 1, kShort = 2, kInt = 3, kLong = 4, kFloat = 5,
86  kDouble = 8, kDouble32= 9,
87  kUChar = 11, kUShort = 12, kUInt = 13, kULong = 14, kBits = 15,
88  kLong64 = 16, kULong64 = 17, kBool = 18, kFloat16 = 19,
89  kObject = 61, kAny = 62, kObjectp = 63, kObjectP = 64, kTString = 65,
90  kTObject = 66, kTNamed = 67, kAnyp = 68, kAnyP = 69, kAnyPnoVT = 70,
91  kSTLp = 71,
92  kSkip = 100, kSkipL = 120, kSkipP = 140,
93  kConv = 200, kConvL = 220, kConvP = 240,
94  kSTL = ROOT::kSTLany /* 300 */,
96  kStreamer = 500, kStreamLoop = 501,
97  kCache = 600, // Cache the value in memory than is not part of the object but is accessible via a SchemaRule
98  kArtificial = 1000,
99  kCacheNew = 1001,
100  kCacheDelete = 1002,
102  kMissing = 99999
103  };
104 
105 // Some comments about EReadWrite
106 // kBase : base class element
107 // kOffsetL : fixed size array
108 // kOffsetP : pointer to object
109 // kCounter : counter for array size
110 // kCharStar: pointer to array of char
111 // kBits : TObject::fBits in case of a referenced object
112 // kObject : Class derived from TObject
113 // kObjectp : Class* derived from TObject and with comment field //->Class
114 // kObjectP : Class* derived from TObject and with NO comment field //->Class
115 // kAny : Class not derived from TObject
116 // kAnyp : Class* not derived from TObject with comment field //->Class
117 // kAnyP : Class* not derived from TObject with NO comment field //->Class
118 // kAnyPnoVT: Class* not derived from TObject with NO comment field //->Class and Class has NO virtual table
119 // kSTLp : Pointer to STL container.
120 // kTString : TString, special case
121 // kTObject : TObject, special case
122 // kTNamed : TNamed , special case
123 
124 
125 
127  TVirtualStreamerInfo(TClass * /*cl*/);
128  virtual ~TVirtualStreamerInfo();
129  virtual void Build() = 0;
130  virtual void BuildCheck(TFile *file = 0) = 0;
131  virtual void BuildEmulated(TFile *file) = 0;
132  virtual void BuildOld() = 0;
133  virtual Bool_t BuildFor( const TClass *cl ) = 0;
134  virtual void CallShowMembers(const void* obj, TMemberInspector &insp, Bool_t isTransient) const = 0;
135  virtual void Clear(Option_t *) = 0;
136  virtual Bool_t CompareContent(TClass *cl,TVirtualStreamerInfo *info, Bool_t warn, Bool_t complete, TFile *file) = 0;
137  virtual void Compile() = 0;
138  virtual void ForceWriteInfo(TFile *file, Bool_t force=kFALSE) = 0;
139  virtual Int_t GenerateHeaderFile(const char *dirname, const TList *subClasses = 0, const TList *extrainfos = 0) = 0;
140  virtual TClass *GetActualClass(const void *obj) const = 0;
141  virtual TClass *GetClass() const = 0;
142  virtual UInt_t GetCheckSum() const = 0;
143  virtual Int_t GetClassVersion() const = 0;
144  virtual TStreamerElement *GetElem(Int_t id) const = 0;
145  virtual TStreamerElement *GetElement(Int_t id) const = 0;
146  virtual TObjArray *GetElements() const = 0;
147  virtual Int_t GetOffset(const char *) const = 0;
148  virtual Int_t GetOffset(Int_t id) const = 0;
149  virtual Int_t GetElementOffset(Int_t id) const = 0;
150  virtual Version_t GetOldVersion() const = 0;
151  virtual Int_t GetOnFileClassVersion() const = 0;
152  virtual Int_t GetNumber() const = 0;
153  virtual Int_t GetSize() const = 0;
154  virtual TStreamerElement *GetStreamerElement(const char*datamember, Int_t& offset) const = 0;
155  Bool_t IsBuilt() const { return fIsBuilt; }
156  Bool_t IsCompiled() const { return fIsCompiled; }
157  Bool_t IsOptimized() const { return fOptimized; }
158  Int_t IsRecovered() const { return TestBit(kRecovered); }
159  virtual void ls(Option_t *option="") const = 0;
160  virtual TVirtualStreamerInfo *NewInfo(TClass *cl) = 0;
161  virtual void *New(void *obj = 0) = 0;
162  virtual void *NewArray(Long_t nElements, void* ary = 0) = 0;
163  virtual void Destructor(void* p, Bool_t dtorOnly = kFALSE) = 0;
164  virtual void DeleteArray(void* p, Bool_t dtorOnly = kFALSE) = 0;
165 
166  virtual void SetCheckSum(UInt_t checksum) = 0;
167  virtual void SetClass(TClass *cl) = 0;
168  virtual void SetClassVersion(Int_t vers) = 0;
169  static Bool_t SetStreamMemberWise(Bool_t enable = kTRUE);
170  virtual void TagFile(TFile *fFile) = 0;
171  virtual void Update(const TClass *oldClass, TClass *newClass) = 0;
172 
173  static const char *GetElementCounterStart(const char *dmTitle);
174  static TStreamerBasicType *GetElementCounter(const char *countName, TClass *cl);
175 
176  static Bool_t CanOptimize();
177  static Bool_t GetStreamMemberWise();
178  static void Optimize(Bool_t opt=kTRUE);
179  static Bool_t CanDelete();
180  static void SetCanDelete(Bool_t opt=kTRUE);
181  static void SetFactory(TVirtualStreamerInfo *factory);
182 
183  virtual TVirtualCollectionProxy *GenEmulatedProxy(const char* class_name, Bool_t silent) = 0;
184  virtual TClassStreamer *GenEmulatedClassStreamer(const char* class_name, Bool_t silent) = 0;
185  virtual TVirtualCollectionProxy *GenExplicitProxy( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
186  virtual TClassStreamer *GenExplicitClassStreamer( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
187  static TVirtualStreamerInfo *Factory();
188 
189  //WARNING this class version must be the same as TStreamerInfo
190  ClassDef(TVirtualStreamerInfo,6) //Abstract Interface describing Streamer information for one class
191 };
192 
193 #endif
virtual void Compile()=0
virtual void SetClass(TClass *cl)=0
virtual void * New(void *obj=0)=0
static Bool_t CanDelete()
static function returning true if ReadBuffer can delete object
virtual TClassStreamer * GenEmulatedClassStreamer(const char *class_name, Bool_t silent)=0
An array of TObjects.
Definition: TObjArray.h:37
static Bool_t GetStreamMemberWise()
Return whether the TStreamerInfos will save the collections in "member-wise" order whenever possible...
virtual Int_t GenerateHeaderFile(const char *dirname, const TList *subClasses=0, const TList *extrainfos=0)=0
VSD Structures.
Definition: StringConv.hxx:21
short Version_t
Definition: RtypesCore.h:61
virtual Bool_t CompareContent(TClass *cl, TVirtualStreamerInfo *info, Bool_t warn, Bool_t complete, TFile *file)=0
virtual TClass * GetClass() const =0
virtual TVirtualCollectionProxy * GenExplicitProxy(const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl)=0
const char Option_t
Definition: RtypesCore.h:62
virtual void SetClassVersion(Int_t vers)=0
#define BIT(n)
Definition: Rtypes.h:83
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:48
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
TVirtualStreamerInfo & operator=(const TVirtualStreamerInfo &)
assignment operator
virtual TVirtualStreamerInfo * NewInfo(TClass *cl)=0
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void TagFile(TFile *fFile)=0
virtual Int_t GetSize() const =0
static const char * GetElementCounterStart(const char *dmTitle)
Given a comment/title declaring an array counter, for example: //[fArraySize] array of size fArraySiz...
static TVirtualStreamerInfo * fgInfoFactory
Abstract base class for accessing the data-members of a class.
virtual void Clear(Option_t *)=0
Set name and title to empty strings ("").
virtual void ForceWriteInfo(TFile *file, Bool_t force=kFALSE)=0
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual TStreamerElement * GetElement(Int_t id) const =0
virtual void SetCheckSum(UInt_t checksum)=0
virtual Int_t GetClassVersion() const =0
#define ClassDef(name, id)
Definition: Rtypes.h:326
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual Int_t GetOffset(const char *) const =0
virtual TVirtualCollectionProxy * GenEmulatedProxy(const char *class_name, Bool_t silent)=0
virtual void BuildOld()=0
virtual ~TVirtualStreamerInfo()
Destructor.
static void SetCanDelete(Bool_t opt=kTRUE)
This is a static function.
virtual TClass * GetActualClass(const void *obj) const =0
virtual void * NewArray(Long_t nElements, void *ary=0)=0
A doubly linked list.
Definition: TList.h:44
virtual void BuildCheck(TFile *file=0)=0
virtual Bool_t BuildFor(const TClass *cl)=0
static void Optimize(Bool_t opt=kTRUE)
This is a static function.
virtual TStreamerElement * GetStreamerElement(const char *datamember, Int_t &offset) const =0
static Bool_t SetStreamMemberWise(Bool_t enable=kTRUE)
Set whether the TStreamerInfos will save the collections in "member-wise" order whenever possible...
virtual TClassStreamer * GenExplicitClassStreamer(const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl)=0
unsigned int UInt_t
Definition: RtypesCore.h:42
static Bool_t fgCanDelete
true if the StreamerInfo has been compiled (i.e. fully built, ready to use for streaming).
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
static Bool_t CanOptimize()
static function returning true if optimization can be on
Bool_t fIsBuilt
true if the StreamerInfo has been optimized
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void Destructor(void *p, Bool_t dtorOnly=kFALSE)=0
std::atomic< Bool_t > fIsCompiled
true if the StreamerInfo has been &#39;built&#39; (i.e. has all the StreamerElements it should have) ...
long Long_t
Definition: RtypesCore.h:50
virtual TObjArray * GetElements() const =0
EStatusBits
Definition: TObject.h:57
virtual Int_t GetNumber() const =0
virtual Version_t GetOldVersion() const =0
virtual void Update(const TClass *oldClass, TClass *newClass)=0
static TVirtualStreamerInfo * Factory()
Static function returning a pointer to a new TVirtualStreamerInfo object.
virtual TStreamerElement * GetElem(Int_t id) const =0
virtual void Build()=0
virtual Int_t GetOnFileClassVersion() const =0
virtual void DeleteArray(void *p, Bool_t dtorOnly=kFALSE)=0
Definition: file.py:1
virtual void ls(Option_t *option="") const =0
List TNamed name and title.
virtual void BuildEmulated(TFile *file)=0
static TStreamerBasicType * GetElementCounter(const char *countName, TClass *cl)
Get pointer to a TStreamerBasicType in TClass *cl static function.
static void SetFactory(TVirtualStreamerInfo *factory)
static function: Set the StreamerInfo factory
static Bool_t fgStreamMemberWise
void ResetBit(UInt_t f)
Definition: TObject.h:171
virtual void CallShowMembers(const void *obj, TMemberInspector &insp, Bool_t isTransient) const =0
Abstract Interface class describing Streamer information for one class.
TVirtualStreamerInfo()
Default constructor.
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual Int_t GetElementOffset(Int_t id) const =0
virtual UInt_t GetCheckSum() const =0