ROOT  6.06/09
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 #ifndef ROOT_TNamed
25 #include "TNamed.h"
26 #endif
27 
28 #ifndef ROOT_ESTLType
29 #include "ESTLType.h"
30 #endif
31 
32 class TFile;
33 class TClass;
34 class TObjArray;
35 class TStreamerElement;
36 class TStreamerBasicType;
38 class TClassStreamer;
39 namespace ROOT { namespace Detail { class TCollectionProxyInfo; } }
40 
41 class TVirtualStreamerInfo : public TNamed {
42 
43 protected:
44  Bool_t fOptimized : 1; //! true if the StreamerInfo has been optimized
45  Bool_t fIsBuilt : 1; //! true if the StreamerInfo has been 'built' (i.e. has all the StreamerElements it should have)
46  std::atomic<Bool_t> fIsCompiled; //! true if the StreamerInfo has been compiled (i.e. fully built, ready to use for streaming).
47 
48 protected:
49  static Bool_t fgCanDelete; //True if ReadBuffer can delete object
50  static Bool_t fgOptimize; //True if optimization on
51  static Bool_t fgStreamMemberWise; //True if the collections are to be stream "member-wise" (when possible).
53 
56 
57  void ResetIsCompiled() {
58  fIsCompiled = kFALSE;
59  ResetBit(kIsCompiled); /* for backward compatibility */
60  }
61  void SetIsCompiled() {
62  fIsCompiled = kTRUE;
63  SetBit(kIsCompiled); /* for backward compatibility */
64  }
65 
66 public:
67 
68  //status bits
69  enum { kCannotOptimize = BIT(12),
70  kIgnoreTObjectStreamer = BIT(13), // eventhough BIT(13) is taken up by TObject (to preserve forward compatibility)
71  kRecovered = BIT(14),
72  kNeedCheck = BIT(15),
76  };
77 
78  enum EReadWrite {
79  kBase = 0, kOffsetL = 20, kOffsetP = 40, kCounter = 6, kCharStar = 7,
80  kChar = 1, kShort = 2, kInt = 3, kLong = 4, kFloat = 5,
81  kDouble = 8, kDouble32= 9,
82  kUChar = 11, kUShort = 12, kUInt = 13, kULong = 14, kBits = 15,
83  kLong64 = 16, kULong64 = 17, kBool = 18, kFloat16 = 19,
84  kObject = 61, kAny = 62, kObjectp = 63, kObjectP = 64, kTString = 65,
85  kTObject = 66, kTNamed = 67, kAnyp = 68, kAnyP = 69, kAnyPnoVT = 70,
86  kSTLp = 71,
87  kSkip = 100, kSkipL = 120, kSkipP = 140,
88  kConv = 200, kConvL = 220, kConvP = 240,
89  kSTL = ROOT::kSTLany /* 300 */,
91  kStreamer = 500, kStreamLoop = 501,
92  kCache = 600, // Cache the value in memory than is not part of the object but is accessible via a SchemaRule
93  kArtificial = 1000,
94  kCacheNew = 1001,
95  kCacheDelete = 1002,
97  kMissing = 99999
98  };
99 
100 // Some comments about EReadWrite
101 // kBase : base class element
102 // kOffsetL : fixed size array
103 // kOffsetP : pointer to object
104 // kCounter : counter for array size
105 // kCharStar: pointer to array of char
106 // kBits : TObject::fBits in case of a referenced object
107 // kObject : Class derived from TObject
108 // kObjectp : Class* derived from TObject and with comment field //->Class
109 // kObjectP : Class* derived from TObject and with NO comment field //->Class
110 // kAny : Class not derived from TObject
111 // kAnyp : Class* not derived from TObject with comment field //->Class
112 // kAnyP : Class* not derived from TObject with NO comment field //->Class
113 // kAnyPnoVT: Class* not derived from TObject with NO comment field //->Class and Class has NO virtual table
114 // kSTLp : Pointer to STL container.
115 // kTString : TString, special case
116 // kTObject : TObject, special case
117 // kTNamed : TNamed , special case
118 
119 
120 
122  TVirtualStreamerInfo(TClass * /*cl*/);
123  virtual ~TVirtualStreamerInfo();
124  virtual void Build() = 0;
125  virtual void BuildCheck(TFile *file = 0) = 0;
126  virtual void BuildEmulated(TFile *file) = 0;
127  virtual void BuildOld() = 0;
128  virtual Bool_t BuildFor( const TClass *cl ) = 0;
129  virtual void CallShowMembers(const void* obj, TMemberInspector &insp, Bool_t isTransient) const = 0;
130  virtual void Clear(Option_t *) = 0;
131  virtual Bool_t CompareContent(TClass *cl,TVirtualStreamerInfo *info, Bool_t warn, Bool_t complete, TFile *file) = 0;
132  virtual void Compile() = 0;
133  virtual void ForceWriteInfo(TFile *file, Bool_t force=kFALSE) = 0;
134  virtual Int_t GenerateHeaderFile(const char *dirname, const TList *subClasses = 0, const TList *extrainfos = 0) = 0;
135  virtual TClass *GetActualClass(const void *obj) const = 0;
136  virtual TClass *GetClass() const = 0;
137  virtual UInt_t GetCheckSum() const = 0;
138  virtual Int_t GetClassVersion() const = 0;
139  virtual TStreamerElement *GetElem(Int_t id) const = 0;
140  virtual TStreamerElement *GetElement(Int_t id) const = 0;
141  virtual TObjArray *GetElements() const = 0;
142  virtual Int_t GetOffset(const char *) const = 0;
143  virtual Int_t GetOffset(Int_t id) const = 0;
144  virtual Int_t GetElementOffset(Int_t id) const = 0;
145  virtual Version_t GetOldVersion() const = 0;
146  virtual Int_t GetOnFileClassVersion() const = 0;
147  virtual Int_t GetNumber() const = 0;
148  virtual Int_t GetSize() const = 0;
149  virtual TStreamerElement *GetStreamerElement(const char*datamember, Int_t& offset) const = 0;
150  Bool_t IsBuilt() const { return fIsBuilt; }
151  Bool_t IsCompiled() const { return fIsCompiled; }
152  Bool_t IsOptimized() const { return fOptimized; }
153  Int_t IsRecovered() const { return TestBit(kRecovered); }
154  virtual void ls(Option_t *option="") const = 0;
155  virtual TVirtualStreamerInfo *NewInfo(TClass *cl) = 0;
156  virtual void *New(void *obj = 0) = 0;
157  virtual void *NewArray(Long_t nElements, void* ary = 0) = 0;
158  virtual void Destructor(void* p, Bool_t dtorOnly = kFALSE) = 0;
159  virtual void DeleteArray(void* p, Bool_t dtorOnly = kFALSE) = 0;
160 
161  virtual void SetCheckSum(UInt_t checksum) = 0;
162  virtual void SetClass(TClass *cl) = 0;
163  virtual void SetClassVersion(Int_t vers) = 0;
164  static Bool_t SetStreamMemberWise(Bool_t enable = kTRUE);
165  virtual void TagFile(TFile *fFile) = 0;
166  virtual void Update(const TClass *oldClass, TClass *newClass) = 0;
167 
168  static const char *GetElementCounterStart(const char *dmTitle);
169  static TStreamerBasicType *GetElementCounter(const char *countName, TClass *cl);
170 
171  static Bool_t CanOptimize();
172  static Bool_t GetStreamMemberWise();
173  static void Optimize(Bool_t opt=kTRUE);
174  static Bool_t CanDelete();
175  static void SetCanDelete(Bool_t opt=kTRUE);
176  static void SetFactory(TVirtualStreamerInfo *factory);
177 
178  virtual TVirtualCollectionProxy *GenEmulatedProxy(const char* class_name, Bool_t silent) = 0;
179  virtual TClassStreamer *GenEmulatedClassStreamer(const char* class_name, Bool_t silent) = 0;
180  virtual TVirtualCollectionProxy *GenExplicitProxy( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
181  virtual TClassStreamer *GenExplicitClassStreamer( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
182  static TVirtualStreamerInfo *Factory();
183 
184  //WARNING this class version must be the same as TStreamerInfo
185  ClassDef(TVirtualStreamerInfo,6) //Abstract Interface describing Streamer information for one class
186 };
187 
188 #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:39
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
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
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:120
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
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
const Bool_t kFALSE
Definition: Rtypes.h:92
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:732
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:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
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:47
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
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
static Bool_t fgCanDelete
true if the StreamerInfo has been compiled (i.e. fully built, ready to use for streaming).
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
static Bool_t CanOptimize()
static function returning true if optimization can be on
Bool_t fIsBuilt
true if the StreamerInfo has been optimized
virtual void Destructor(void *p, Bool_t dtorOnly=kFALSE)=0
std::atomic< Bool_t > fIsCompiled
true if the StreamerInfo has been 'built' (i.e. has all the StreamerElements it should have) ...
long Long_t
Definition: RtypesCore.h:50
virtual TObjArray * GetElements() const =0
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
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:172
virtual void CallShowMembers(const void *obj, TMemberInspector &insp, Bool_t isTransient) const =0
Abstract Interface class describing Streamer information for one class.
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
virtual Int_t GetElementOffset(Int_t id) const =0
virtual UInt_t GetCheckSum() const =0