Logo ROOT   6.10/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 #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() {
54  fIsCompiled = kFALSE;
55  ResetBit(kIsCompiled); /* for backward compatibility */
56  }
57  void SetIsCompiled() {
58  fIsCompiled = kTRUE;
59  SetBit(kIsCompiled); /* for backward compatibility */
60  }
61 
62 public:
63 
64  //status bits
65  enum { kCannotOptimize = BIT(12),
66  kIgnoreTObjectStreamer = BIT(13), // eventhough BIT(13) is taken up by TObject (to preserve forward compatibility)
67  kRecovered = BIT(14),
68  kNeedCheck = BIT(15),
70  kBuildOldUsed = BIT(17),
71  kBuildRunning = BIT(18)
72  };
73 
74  enum EReadWrite {
75  kBase = 0, kOffsetL = 20, kOffsetP = 40, kCounter = 6, kCharStar = 7,
76  kChar = 1, kShort = 2, kInt = 3, kLong = 4, kFloat = 5,
77  kDouble = 8, kDouble32= 9,
78  kUChar = 11, kUShort = 12, kUInt = 13, kULong = 14, kBits = 15,
79  kLong64 = 16, kULong64 = 17, kBool = 18, kFloat16 = 19,
80  kObject = 61, kAny = 62, kObjectp = 63, kObjectP = 64, kTString = 65,
81  kTObject = 66, kTNamed = 67, kAnyp = 68, kAnyP = 69, kAnyPnoVT = 70,
82  kSTLp = 71,
83  kSkip = 100, kSkipL = 120, kSkipP = 140,
84  kConv = 200, kConvL = 220, kConvP = 240,
85  kSTL = ROOT::kSTLany /* 300 */,
86  kSTLstring = ROOT::kSTLstring /* 365 */,
87  kStreamer = 500, kStreamLoop = 501,
88  kCache = 600, // Cache the value in memory than is not part of the object but is accessible via a SchemaRule
89  kArtificial = 1000,
90  kCacheNew = 1001,
91  kCacheDelete = 1002,
92  kNeedObjectForVirtualBaseClass = 99997,
93  kMissing = 99999
94  };
95 
96 // Some comments about EReadWrite
97 // kBase : base class element
98 // kOffsetL : fixed size array
99 // kOffsetP : pointer to object
100 // kCounter : counter for array size
101 // kCharStar: pointer to array of char
102 // kBits : TObject::fBits in case of a referenced object
103 // kObject : Class derived from TObject
104 // kObjectp : Class* derived from TObject and with comment field //->Class
105 // kObjectP : Class* derived from TObject and with NO comment field //->Class
106 // kAny : Class not derived from TObject
107 // kAnyp : Class* not derived from TObject with comment field //->Class
108 // kAnyP : Class* not derived from TObject with NO comment field //->Class
109 // kAnyPnoVT: Class* not derived from TObject with NO comment field //->Class and Class has NO virtual table
110 // kSTLp : Pointer to STL container.
111 // kTString : TString, special case
112 // kTObject : TObject, special case
113 // kTNamed : TNamed , special case
114 
115 
116 
118  TVirtualStreamerInfo(TClass * /*cl*/);
119  virtual ~TVirtualStreamerInfo();
120  virtual void Build() = 0;
121  virtual void BuildCheck(TFile *file = 0) = 0;
122  virtual void BuildEmulated(TFile *file) = 0;
123  virtual void BuildOld() = 0;
124  virtual Bool_t BuildFor( const TClass *cl ) = 0;
125  virtual void CallShowMembers(const void* obj, TMemberInspector &insp, Bool_t isTransient) const = 0;
126  virtual void Clear(Option_t *) = 0;
127  virtual Bool_t CompareContent(TClass *cl,TVirtualStreamerInfo *info, Bool_t warn, Bool_t complete, TFile *file) = 0;
128  virtual void Compile() = 0;
129  virtual void ForceWriteInfo(TFile *file, Bool_t force=kFALSE) = 0;
130  virtual Int_t GenerateHeaderFile(const char *dirname, const TList *subClasses = 0, const TList *extrainfos = 0) = 0;
131  virtual TClass *GetActualClass(const void *obj) const = 0;
132  virtual TClass *GetClass() const = 0;
133  virtual UInt_t GetCheckSum() const = 0;
134  virtual Int_t GetClassVersion() const = 0;
135  virtual TStreamerElement *GetElem(Int_t id) const = 0;
136  virtual TStreamerElement *GetElement(Int_t id) const = 0;
137  virtual TObjArray *GetElements() const = 0;
138  virtual Int_t GetOffset(const char *) const = 0;
139  virtual Int_t GetOffset(Int_t id) const = 0;
140  virtual Int_t GetElementOffset(Int_t id) const = 0;
141  virtual Version_t GetOldVersion() const = 0;
142  virtual Int_t GetOnFileClassVersion() const = 0;
143  virtual Int_t GetNumber() const = 0;
144  virtual Int_t GetSize() const = 0;
145  virtual TStreamerElement *GetStreamerElement(const char*datamember, Int_t& offset) const = 0;
146  Bool_t IsBuilt() const { return fIsBuilt; }
147  Bool_t IsCompiled() const { return fIsCompiled; }
148  Bool_t IsOptimized() const { return fOptimized; }
149  Int_t IsRecovered() const { return TestBit(kRecovered); }
150  virtual void ls(Option_t *option="") const = 0;
151  virtual TVirtualStreamerInfo *NewInfo(TClass *cl) = 0;
152  virtual void *New(void *obj = 0) = 0;
153  virtual void *NewArray(Long_t nElements, void* ary = 0) = 0;
154  virtual void Destructor(void* p, Bool_t dtorOnly = kFALSE) = 0;
155  virtual void DeleteArray(void* p, Bool_t dtorOnly = kFALSE) = 0;
156 
157  virtual void SetCheckSum(UInt_t checksum) = 0;
158  virtual void SetClass(TClass *cl) = 0;
159  virtual void SetClassVersion(Int_t vers) = 0;
160  static Bool_t SetStreamMemberWise(Bool_t enable = kTRUE);
161  virtual void TagFile(TFile *fFile) = 0;
162  virtual void Update(const TClass *oldClass, TClass *newClass) = 0;
163 
164  static const char *GetElementCounterStart(const char *dmTitle);
165  static TStreamerBasicType *GetElementCounter(const char *countName, TClass *cl);
166 
167  static Bool_t CanOptimize();
168  static Bool_t GetStreamMemberWise();
169  static void Optimize(Bool_t opt=kTRUE);
170  static Bool_t CanDelete();
171  static void SetCanDelete(Bool_t opt=kTRUE);
172  static void SetFactory(TVirtualStreamerInfo *factory);
173 
174  virtual TVirtualCollectionProxy *GenEmulatedProxy(const char* class_name, Bool_t silent) = 0;
175  virtual TClassStreamer *GenEmulatedClassStreamer(const char* class_name, Bool_t silent) = 0;
176  virtual TVirtualCollectionProxy *GenExplicitProxy( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
177  virtual TClassStreamer *GenExplicitClassStreamer( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0;
178  static TVirtualStreamerInfo *Factory();
179 
180  //WARNING this class version must be the same as TStreamerInfo
181  ClassDef(TVirtualStreamerInfo,6) //Abstract Interface describing Streamer information for one class
182 };
183 
184 #endif
RooCmdArg Optimize(Int_t flag=2)
An array of TObjects.
Definition: TObjArray.h:37
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
short Version_t
Definition: RtypesCore.h:61
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:75
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static TVirtualStreamerInfo * fgInfoFactory
Abstract base class for accessing the data-members of a class.
V GetOffset(E val1, E val2, V iso)
TClass * GetClass(T *)
Definition: TClass.h:545
#define ClassDef(name, id)
Definition: Rtypes.h:297
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
A doubly linked list.
Definition: TList.h:43
TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
Definition: Cppyy.cxx:207
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).
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
Bool_t fIsBuilt
true if the StreamerInfo has been optimized
Short_t SetClassVersion(RootClass *)
const Bool_t kFALSE
Definition: RtypesCore.h:92
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
Binding & operator=(OUT(*fun)(void))
Definition: file.py:1
static Bool_t fgStreamMemberWise
Abstract Interface class describing Streamer information for one class.
const Bool_t kTRUE
Definition: RtypesCore.h:91