Logo ROOT   6.10/09
Reference Guide
TClass.h
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Rene Brun 07/01/95
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_TClass
13 #define ROOT_TClass
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TClass //
19 // //
20 // Dictionary of a class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TDictionary.h"
25 #include "TString.h"
26 #include "TObjArray.h"
27 #include "TObjString.h"
28 
29 #include <map>
30 #include <string>
31 #include <set>
32 #include <unordered_set>
33 #include <vector>
34 
35 #include <atomic>
36 #include "ThreadLocalStorage.h"
37 class TBaseClass;
38 class TBrowser;
39 class TDataMember;
40 class TCling;
41 class TMethod;
42 class TRealData;
43 class TBuffer;
46 class TMethodCall;
47 class TVirtualIsAProxy;
48 class TVirtualRefProxy;
49 class THashTable;
50 class TListOfFunctions;
52 class TListOfDataMembers;
53 class TListOfEnums;
54 class TViewPubFunctions;
56 class TFunctionTemplate;
57 class TProtoClass;
58 
59 namespace ROOT {
60  class TGenericClassInfo;
61  class TMapTypeToTClass;
62  class TMapDeclIdToTClass;
63  namespace Detail {
64  class TSchemaRuleSet;
65  class TCollectionProxyInfo;
66  }
67 }
68 typedef ROOT::TMapTypeToTClass IdMap_t;
69 typedef ROOT::TMapDeclIdToTClass DeclIdMap_t;
70 
71 class TClass : public TDictionary {
72 
73 friend class TCling;
74 friend void ROOT::ResetClassVersion(TClass*, const char*, Short_t);
76 friend class TProtoClass;
77 
78 public:
79  // TClass status bits
80  enum { kClassSaved = BIT(12), kIgnoreTObjectStreamer = BIT(15),
81  kUnloaded = BIT(16), // The library containing the dictionary for this class was
82  // loaded and has been unloaded from memory.
83  kIsTObject = BIT(17),
84  kIsForeign = BIT(18),
85  kIsEmulation = BIT(19), // Deprecated
86  kStartWithTObject = BIT(20), // see comments for IsStartingWithTObject()
87  kWarned = BIT(21),
88  kHasNameMapNode = BIT(22),
89  kHasCustomStreamerMember = BIT(23) // The class has a Streamer method and it is implemented by the user or an older (not StreamerInfo based) automatic streamer.
90  };
91  enum ENewType { kRealNew = 0, kClassNew, kDummyNew };
92  enum ECheckSum {
93  kCurrentCheckSum = 0,
94  kNoEnum = 1, // Used since v3.3
95  kReflexNoComment = 2, // Up to v5.34.18 (has no range/comment and no typedef at all)
96  kNoRange = 3, // Up to v5.17
97  kWithTypeDef = 4, // Up to v5.34.18 and v5.99/06
98  kReflex = 5, // Up to v5.34.18 (has no typedef at all)
99  kNoRangeCheck = 6, // Up to v5.34.18 and v5.99/06
100  kNoBaseCheckSum = 7, // Up to v5.34.18 and v5.99/06
101  kLatestCheckSum = 8
102  };
103 
104  // Describe the current state of the TClass itself.
105  enum EState {
106  kNoInfo, // The state has not yet been initialized, i.e. the TClass
107  // was just created and/or there is no trace of it in the interpreter.
108  kForwardDeclared, // The interpreted knows the entity is a class but that's it.
109  kEmulated, // The information about the class only comes from a TStreamerInfo
110  kInterpreted, // The class is described completely/only in the interpreter database.
111  kHasTClassInit, // The class has a TClass proper bootstrap coming from a run
112  // through rootcling/genreflex/TMetaUtils and the library
113  // containing this dictionary has been loaded in memory.
114  kLoaded = kHasTClassInit,
115  kNamespaceForMeta // Very transient state necessary to bootstrap namespace entries in ROOT Meta w/o interpreter information
116  };
117 
118 private:
119 
121  // Trivial spin lock guard
122  public:
123  TSpinLockGuard(std::atomic_flag& aflag);
124  ~TSpinLockGuard();
125  private:
126  std::atomic_flag& fAFlag;
127  };
128 
130  // A class which is used to collect decl names starting from normalised
131  // names (typedef resolution is excluded here, just string manipulation
132  // is performed). At the heart of the implementation, an unordered set.
133  public:
134  TDeclNameRegistry(Int_t verbLevel=0);
135  void AddQualifiedName(const char *name);
136  Bool_t HasDeclName(const char *name) const;
138  private:
139  Int_t fVerbLevel=0;
140  std::unordered_set<std::string> fClassNamesSet;
141  mutable std::atomic_flag fSpinLock; // MSVC doesn't support = ATOMIC_FLAG_INIT;
142  };
143 
145  // Trivial RAII used to insert names in the registry
147  const char* fName;
149  public:
150  InsertTClassInRegistryRAII(TClass::EState &state, const char *name, TDeclNameRegistry &emuRegistry);
152  };
153 
154  // TClass objects can be created as a result of opening a TFile (in which
155  // they are in emulated mode) or as a result of loading the dictionary for
156  // the corresponding class. When a dictionary is loaded any pre-existing
157  // emulated TClass is replaced by the one created/coming from the dictionary.
158  // To have a reference that always point to the 'current' TClass object for
159  // a given class, one should use a TClassRef.
160  // TClassRef works by holding on to the fPersistentRef which is updated
161  // atomically whenever a TClass is replaced. During the replacement the
162  // value of fPersistentRef is set to zero, leading the TClassRef to call
163  // TClass::GetClass which is also locked by the replacement. At the end
164  // of the replacement, fPersistentRef points to the new TClass object.
165  std::atomic<TClass**> fPersistentRef;//!Persistent address of pointer to this TClass object and its successors.
166 
167  typedef std::atomic<std::map<std::string, TObjArray*>*> ConvSIMap_t;
168 
169  mutable TObjArray *fStreamerInfo; //Array of TVirtualStreamerInfo
170  mutable ConvSIMap_t fConversionStreamerInfo; //Array of the streamer infos derived from another class.
171  TList *fRealData; //linked list for persistent members including base classes
172  std::atomic<TList*> fBase; //linked list for base classes
173  TListOfDataMembers *fData; //linked list for data members
174 
175  std::atomic<TListOfEnums*> fEnums; //linked list for the enums
176  TListOfFunctionTemplates *fFuncTemplate; //linked list for function templates [Not public until implemented as active list]
177  std::atomic<TListOfFunctions*> fMethod; //linked list for methods
178 
179  TViewPubDataMembers*fAllPubData; //all public data members (including from base classes)
180  TViewPubFunctions *fAllPubMethod; //all public methods (including from base classes)
181  mutable TList *fClassMenuList; //list of class menu items
182 
183  const char *fDeclFileName; //name of class declaration file
184  const char *fImplFileName; //name of class implementation file
185  Short_t fDeclFileLine; //line of class declaration
186  Short_t fImplFileLine; //line of class implementation
187  UInt_t fInstanceCount; //number of instances of this class
188  UInt_t fOnHeap; //number of instances on heap
189  mutable std::atomic<UInt_t> fCheckSum; //checksum of data members and base classes
190  TVirtualCollectionProxy *fCollectionProxy; //Collection interface
191  Version_t fClassVersion; //Class version Identifier
192  ClassInfo_t *fClassInfo; //pointer to CINT class info class
193  TString fContextMenuTitle;//context menu title
194  const std::type_info *fTypeInfo; //pointer to the C++ type information.
195  ShowMembersFunc_t fShowMembers; //pointer to the class's ShowMembers function
196  TClassStreamer *fStreamer; //pointer to streamer function
197  TString fSharedLibs; //shared libraries containing class code
198 
199  TVirtualIsAProxy *fIsA; //!pointer to the class's IsA proxy.
200  IsAGlobalFunc_t fGlobalIsA; //pointer to a global IsA function.
201  mutable std::atomic<TMethodCall*> fIsAMethod; //!saved info to call a IsA member function
202 
203  ROOT::MergeFunc_t fMerge; //pointer to a function implementing Merging objects of this class.
204  ROOT::ResetAfterMergeFunc_t fResetAfterMerge; //pointer to a function implementing Merging objects of this class.
205  ROOT::NewFunc_t fNew; //pointer to a function newing one object.
206  ROOT::NewArrFunc_t fNewArray; //pointer to a function newing an array of objects.
207  ROOT::DelFunc_t fDelete; //pointer to a function deleting one object.
208  ROOT::DelArrFunc_t fDeleteArray; //pointer to a function deleting an array of objects.
209  ROOT::DesFunc_t fDestructor; //pointer to a function call an object's destructor.
210  ROOT::DirAutoAdd_t fDirAutoAdd; //pointer which implements the Directory Auto Add feature for this class.']'
211  ClassStreamerFunc_t fStreamerFunc; //Wrapper around this class custom Streamer member function.
212  ClassConvStreamerFunc_t fConvStreamerFunc; //Wrapper around this class custom conversion Streamer member function.
213  Int_t fSizeof; //Sizeof the class.
214 
215  Int_t fCanSplit; //!Indicates whether this class can be split or not.
216  mutable std::atomic<Long_t> fProperty; //!Property
217  mutable Long_t fClassProperty; //!C++ Property of the class (is abstract, has virtual table, etc.)
218 
219  // fHasRootPcmInfo needs to be atomic as long as GetListOfBases needs to modify it.
220  std::atomic<Bool_t> fHasRootPcmInfo; //!Whether info was loaded from a root pcm.
221  mutable std::atomic<Bool_t> fCanLoadClassInfo; //!Indicates whether the ClassInfo is supposed to be available.
222  mutable std::atomic<Bool_t> fIsOffsetStreamerSet; //!saved remember if fOffsetStreamer has been set.
223  mutable std::atomic<Bool_t> fVersionUsed; //!Indicates whether GetClassVersion has been called
224 
225  mutable Long_t fOffsetStreamer; //!saved info to call Streamer
226  Int_t fStreamerType; //!cached of the streaming method to use
227  EState fState; //!Current 'state' of the class (Emulated,Interpreted,Loaded)
228  mutable std::atomic<TVirtualStreamerInfo*> fCurrentInfo; //!cached current streamer info.
229  mutable std::atomic<TVirtualStreamerInfo*> fLastReadInfo; //!cached streamer info used in the last read.
230  TVirtualRefProxy *fRefProxy; //!Pointer to reference proxy if this class represents a reference
231  ROOT::Detail::TSchemaRuleSet *fSchemaRules; //! Schema evolution rules
232 
233  typedef void (*StreamerImpl_t)(const TClass* pThis, void *obj, TBuffer &b, const TClass *onfile_class);
234 #ifdef R__NO_ATOMIC_FUNCTION_POINTER
235  mutable StreamerImpl_t fStreamerImpl; //! Pointer to the function implementing the right streaming behavior for the class represented by this object.
236 #else
237  mutable std::atomic<StreamerImpl_t> fStreamerImpl; //! Pointer to the function implementing the right streaming behavior for the class represented by this object.
238 #endif
239 
240  Bool_t CanSplitBaseAllow();
241  TListOfFunctions *GetMethodList();
242  TMethod *GetClassMethod(Long_t faddr);
243  TMethod *FindClassOrBaseMethodWithId(DeclId_t faddr);
244  Int_t GetBaseClassOffsetRecurse(const TClass *toBase);
245  void Init(const char *name, Version_t cversion, const std::type_info *info,
246  TVirtualIsAProxy *isa,
247  const char *dfil, const char *ifil,
248  Int_t dl, Int_t il,
249  ClassInfo_t *classInfo,
250  Bool_t silent);
251  void ForceReload (TClass* oldcl);
252  void LoadClassInfo() const;
253 
254  static TClass *LoadClassDefault(const char *requestedname, Bool_t silent);
255  static TClass *LoadClassCustom(const char *requestedname, Bool_t silent);
256 
257  void SetClassVersion(Version_t version);
258  void SetClassSize(Int_t sizof) { fSizeof = sizof; }
259  TVirtualStreamerInfo* DetermineCurrentStreamerInfo();
260 
261  void SetStreamerImpl();
262 
263  // Various implementation for TClass::Stramer
264  static void StreamerExternal(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
265  static void StreamerTObject(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
266  static void StreamerTObjectInitialized(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
267  static void StreamerTObjectEmulated(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
268  static void StreamerInstrumented(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
269  static void ConvStreamerInstrumented(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
270  static void StreamerStreamerInfo(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
271  static void StreamerDefault(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
272 
273  static IdMap_t *GetIdMap(); //Map from typeid to TClass pointer
274  static DeclIdMap_t *GetDeclIdMap(); //Map from DeclId_t to TClass pointer
275  static std::atomic<Int_t> fgClassCount; //provides unique id for a each class
276  //stored in TObject::fUniqueID
277  static TDeclNameRegistry fNoInfoOrEmuOrFwdDeclNameRegistry; // Store the decl names of the forwardd and no info instances
278  static Bool_t HasNoInfoOrEmuOrFwdDeclaredDecl(const char*);
279 
280  // Internal status bits, set and reset only during initialization and thus under the protection of the global lock.
281  enum { kLoading = BIT(14), kUnloading = BIT(14) };
282  // Internal streamer type.
283  enum EStreamerType {kDefault=0, kEmulatedStreamer=1, kTObject=2, kInstrumented=4, kForeign=8, kExternal=16};
284 
285  // When a new class is created, we need to be able to find
286  // if there are any existing classes that have the same name
287  // after any typedefs are expanded. (This only really affects
288  // template arguments.) To avoid having to search through all classes
289  // in that case, we keep a hash table mapping from the fully
290  // typedef-expanded names to the original class names.
291  // An entry is made in the table only if they are actually different.
292  //
293  // In these objects, the TObjString base holds the typedef-expanded
294  // name (the hash key), and fOrigName holds the original class name
295  // (the value to which the key maps).
296  //
297  class TNameMapNode : public TObjString
298  {
299  public:
300  TNameMapNode (const char* typedf, const char* orig);
302  };
303 
304  // These are the above-referenced hash tables. (The pointers are null
305  // if no entries have been made.)
307 
308 private:
309  TClass(const TClass& tc) = delete;
310  TClass& operator=(const TClass&) = delete;
311 
312 protected:
313  TVirtualStreamerInfo *FindStreamerInfo(TObjArray* arr, UInt_t checksum) const;
314  void GetMissingDictionariesForBaseClasses(TCollection& result, TCollection& visited, bool recurse);
315  void GetMissingDictionariesForMembers(TCollection& result, TCollection& visited, bool recurse);
316  void GetMissingDictionariesWithRecursionCheck(TCollection& result, TCollection& visited, bool recurse);
317  void GetMissingDictionariesForPairElements(TCollection& result, TCollection& visited, bool recurse);
318 
319 public:
320  TClass();
321  TClass(const char *name, Bool_t silent = kFALSE);
322  TClass(const char *name, Version_t cversion, Bool_t silent = kFALSE);
323  TClass(const char *name, Version_t cversion, EState theState, Bool_t silent = kFALSE);
324  TClass(ClassInfo_t *info, Version_t cversion,
325  const char *dfil, const char *ifil = 0,
326  Int_t dl = 0, Int_t il = 0, Bool_t silent = kFALSE);
327  TClass(const char *name, Version_t cversion,
328  const char *dfil, const char *ifil = 0,
329  Int_t dl = 0, Int_t il = 0, Bool_t silent = kFALSE);
330  TClass(const char *name, Version_t cversion,
331  const std::type_info &info, TVirtualIsAProxy *isa,
332  const char *dfil, const char *ifil,
333  Int_t dl, Int_t il, Bool_t silent = kFALSE);
334  virtual ~TClass();
335 
336  void AddInstance(Bool_t heap = kFALSE) { fInstanceCount++; if (heap) fOnHeap++; }
337  void AddImplFile(const char *filename, int line);
338  static Bool_t AddRule(const char *rule);
339  static Int_t ReadRules(const char *filename);
340  static Int_t ReadRules();
341  void AdoptSchemaRules( ROOT::Detail::TSchemaRuleSet *rules );
342  virtual void Browse(TBrowser *b);
343  void BuildRealData(void *pointer=0, Bool_t isTransient = kFALSE);
344  void BuildEmulatedRealData(const char *name, Long_t offset, TClass *cl);
345  void CalculateStreamerOffset() const;
346  Bool_t CallShowMembers(const void* obj, TMemberInspector &insp, Bool_t isTransient = kFALSE) const;
347  Bool_t CanSplit() const;
348  Bool_t CanIgnoreTObjectStreamer() { return TestBit(kIgnoreTObjectStreamer);}
349  Long_t ClassProperty() const;
350  TObject *Clone(const char *newname="") const;
351  void CopyCollectionProxy(const TVirtualCollectionProxy&);
352  void Draw(Option_t *option="");
353  void Dump() const { TDictionary::Dump(); }
354  void Dump(const void *obj, Bool_t noAddr = kFALSE) const;
355  char *EscapeChars(const char *text) const;
356  TVirtualStreamerInfo *FindStreamerInfo(UInt_t checksum) const;
357  TVirtualStreamerInfo *GetConversionStreamerInfo( const char* onfile_classname, Int_t version ) const;
358  TVirtualStreamerInfo *FindConversionStreamerInfo( const char* onfile_classname, UInt_t checksum ) const;
359  TVirtualStreamerInfo *GetConversionStreamerInfo( const TClass* onfile_cl, Int_t version ) const;
360  TVirtualStreamerInfo *FindConversionStreamerInfo( const TClass* onfile_cl, UInt_t checksum ) const;
361  Bool_t HasDataMemberInfo() const { return fHasRootPcmInfo || HasInterpreterInfo(); }
362  Bool_t HasDefaultConstructor() const;
363  Bool_t HasInterpreterInfoInMemory() const { return 0 != fClassInfo; }
364  Bool_t HasInterpreterInfo() const { return fCanLoadClassInfo || fClassInfo; }
365  UInt_t GetCheckSum(ECheckSum code = kCurrentCheckSum) const;
366  UInt_t GetCheckSum(Bool_t &isvalid) const;
367  UInt_t GetCheckSum(ECheckSum code, Bool_t &isvalid) const;
368  TVirtualCollectionProxy *GetCollectionProxy() const;
369  TVirtualIsAProxy *GetIsAProxy() const;
370  TMethod *GetClassMethod(const char *name, const char *params, Bool_t objectIsConst = kFALSE);
371  TMethod *GetClassMethodWithPrototype(const char *name, const char *proto, Bool_t objectIsConst = kFALSE, ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch);
372  Version_t GetClassVersion() const { fVersionUsed = kTRUE; return fClassVersion; }
373  Int_t GetClassSize() const { return Size(); }
374  TDataMember *GetDataMember(const char *datamember) const;
375  Long_t GetDataMemberOffset(const char *membername) const;
376  const char *GetDeclFileName() const { return fDeclFileName; }
377  Short_t GetDeclFileLine() const { return fDeclFileLine; }
378  ROOT::DelFunc_t GetDelete() const;
379  ROOT::DesFunc_t GetDestructor() const;
380  ROOT::DelArrFunc_t GetDeleteArray() const;
381  ClassInfo_t *GetClassInfo() const { if (fCanLoadClassInfo && !TestBit(kLoading)) LoadClassInfo(); return fClassInfo; }
382  const char *GetContextMenuTitle() const { return fContextMenuTitle; }
384  if (fCurrentInfo.load()) return fCurrentInfo;
385  else return DetermineCurrentStreamerInfo();
386  }
387  TVirtualStreamerInfo *GetLastReadInfo() const { return fLastReadInfo; }
388  void SetLastReadInfo(TVirtualStreamerInfo *info) { fLastReadInfo = info; }
389  TList *GetListOfDataMembers(Bool_t load = kTRUE);
390  TList *GetListOfEnums(Bool_t load = kTRUE);
391  TList *GetListOfFunctionTemplates(Bool_t load = kTRUE);
392  TList *GetListOfBases();
394  TCollection *GetListOfMethodOverloads(const char* name) const;
395  TList *GetListOfRealData() const { return fRealData; }
396  const TList *GetListOfAllPublicMethods(Bool_t load = kTRUE);
397  TList *GetListOfAllPublicDataMembers(Bool_t load = kTRUE);
398  const char *GetImplFileName() const { return fImplFileName; }
399  Short_t GetImplFileLine() const { return fImplFileLine; }
400  TClass *GetActualClass(const void *object) const;
401  TClass *GetBaseClass(const char *classname);
402  TClass *GetBaseClass(const TClass *base);
403  Int_t GetBaseClassOffset(const TClass *toBase, void *address = 0, bool isDerivedObject = true);
404  TClass *GetBaseDataMember(const char *datamember);
405  ROOT::ESTLType GetCollectionType() const;
406  ROOT::DirAutoAdd_t GetDirectoryAutoAdd() const;
407  TFunctionTemplate *GetFunctionTemplate(const char *name);
408  UInt_t GetInstanceCount() const { return fInstanceCount; }
409  UInt_t GetHeapInstanceCount() const { return fOnHeap; }
410  void GetMenuItems(TList *listitems);
411  TList *GetMenuList() const;
412  TMethod *GetMethod(const char *method, const char *params, Bool_t objectIsConst = kFALSE);
413  TMethod *GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst = kFALSE, ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch);
414  TMethod *GetMethodAny(const char *method);
415  TMethod *GetMethodAllAny(const char *method);
416  Int_t GetNdata();
417  ROOT::MergeFunc_t GetMerge() const;
418  ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const;
419  ROOT::NewFunc_t GetNew() const;
420  ROOT::NewArrFunc_t GetNewArray() const;
421  Int_t GetNmethods();
422 #ifdef __CINT__
423  TClass **GetPersistentRef() const { return fPersistentRef; }
424 #else
425  TClass *const*GetPersistentRef() const { return fPersistentRef; }
426 #endif
427  TRealData *GetRealData(const char *name) const;
428  TVirtualRefProxy *GetReferenceProxy() const { return fRefProxy; }
429  const ROOT::Detail::TSchemaRuleSet *GetSchemaRules() const;
430  ROOT::Detail::TSchemaRuleSet *GetSchemaRules(Bool_t create = kFALSE);
431  const char *GetSharedLibs();
432  ShowMembersFunc_t GetShowMembersWrapper() const { return fShowMembers; }
433  EState GetState() const { return fState; }
434  TClassStreamer *GetStreamer() const;
435  ClassStreamerFunc_t GetStreamerFunc() const;
436  ClassConvStreamerFunc_t GetConvStreamerFunc() const;
437  const TObjArray *GetStreamerInfos() const { return fStreamerInfo; }
438  TVirtualStreamerInfo *GetStreamerInfo(Int_t version=0) const;
439  TVirtualStreamerInfo *GetStreamerInfoAbstractEmulated(Int_t version=0) const;
440  TVirtualStreamerInfo *FindStreamerInfoAbstractEmulated(UInt_t checksum) const;
441  const std::type_info *GetTypeInfo() const { return fTypeInfo; };
442  Bool_t HasDictionary() const;
443  static Bool_t HasDictionarySelection(const char* clname);
444  void GetMissingDictionaries(THashTable& result, bool recurse = false);
445  void IgnoreTObjectStreamer(Bool_t ignore=kTRUE);
446  Bool_t InheritsFrom(const char *cl) const;
447  Bool_t InheritsFrom(const TClass *cl) const;
448  void InterpretedShowMembers(void* obj, TMemberInspector &insp, Bool_t isTransient);
449  Bool_t IsFolder() const { return kTRUE; }
450  Bool_t IsLoaded() const;
451  Bool_t IsForeign() const;
452  Bool_t IsStartingWithTObject() const;
453  Bool_t IsVersioned() const { return !( GetClassVersion()<=1 && IsForeign() ); }
454  Bool_t IsTObject() const;
455  static TClass *LoadClass(const char *requestedname, Bool_t silent);
456  void ls(Option_t *opt="") const;
457  void MakeCustomMenuList();
458  Bool_t MatchLegacyCheckSum(UInt_t checksum) const;
459  void Move(void *arenaFrom, void *arenaTo) const;
460  void *New(ENewType defConstructor = kClassNew, Bool_t quiet = kFALSE) const;
461  void *New(void *arena, ENewType defConstructor = kClassNew) const;
462  void *NewArray(Long_t nElements, ENewType defConstructor = kClassNew) const;
463  void *NewArray(Long_t nElements, void *arena, ENewType defConstructor = kClassNew) const;
464  virtual void PostLoadCheck();
465  Long_t Property() const;
466  Int_t ReadBuffer(TBuffer &b, void *pointer, Int_t version, UInt_t start, UInt_t count);
467  Int_t ReadBuffer(TBuffer &b, void *pointer);
468  void RegisterStreamerInfo(TVirtualStreamerInfo *info);
469  void RemoveStreamerInfo(Int_t slot);
470  void ReplaceWith(TClass *newcl) const;
471  void ResetCaches();
472  void ResetClassInfo(Long_t tagnum);
473  void ResetClassInfo();
474  void ResetInstanceCount() { fInstanceCount = fOnHeap = 0; }
475  void ResetMenuList();
476  Int_t Size() const;
477  void SetCanSplit(Int_t splitmode);
478  void SetCollectionProxy(const ROOT::Detail::TCollectionProxyInfo&);
479  void SetContextMenuTitle(const char *title);
480  void SetCurrentStreamerInfo(TVirtualStreamerInfo *info);
481  void SetGlobalIsA(IsAGlobalFunc_t);
482  void SetDeclFile(const char *name, int line) { fDeclFileName = name; fDeclFileLine = line; }
483  void SetDelete(ROOT::DelFunc_t deleteFunc);
484  void SetDeleteArray(ROOT::DelArrFunc_t deleteArrayFunc);
485  void SetDirectoryAutoAdd(ROOT::DirAutoAdd_t dirAutoAddFunc);
486  void SetDestructor(ROOT::DesFunc_t destructorFunc);
487  void SetImplFileName(const char *implFileName) { fImplFileName = implFileName; }
488  void SetMerge(ROOT::MergeFunc_t mergeFunc);
489  void SetResetAfterMerge(ROOT::ResetAfterMergeFunc_t resetFunc);
490  void SetNew(ROOT::NewFunc_t newFunc);
491  void SetNewArray(ROOT::NewArrFunc_t newArrayFunc);
492  TVirtualStreamerInfo *SetStreamerInfo(Int_t version, const char *info="");
493  void SetUnloaded();
494  Int_t WriteBuffer(TBuffer &b, void *pointer, const char *info="");
495 
496  void AdoptReferenceProxy(TVirtualRefProxy* proxy);
497  void AdoptStreamer(TClassStreamer *strm);
498  void AdoptMemberStreamer(const char *name, TMemberStreamer *strm);
499  void SetMemberStreamer(const char *name, MemberStreamerFunc_t strm);
500  void SetStreamerFunc(ClassStreamerFunc_t strm);
501  void SetConvStreamerFunc(ClassConvStreamerFunc_t strm);
502 
503  // Function to retrieve the TClass object and dictionary function
504  static void AddClass(TClass *cl);
505  static void AddClassToDeclIdMap(TDictionary::DeclId_t id, TClass* cl);
506  static void RemoveClass(TClass *cl);
507  static void RemoveClassDeclId(TDictionary::DeclId_t id);
508  static TClass *GetClass(const char *name, Bool_t load = kTRUE, Bool_t silent = kFALSE);
509  static TClass *GetClass(const std::type_info &typeinfo, Bool_t load = kTRUE, Bool_t silent = kFALSE);
510  static TClass *GetClass(ClassInfo_t *info, Bool_t load = kTRUE, Bool_t silent = kFALSE);
511  static Bool_t GetClass(DeclId_t id, std::vector<TClass*> &classes);
512  static DictFuncPtr_t GetDict (const char *cname);
513  static DictFuncPtr_t GetDict (const std::type_info &info);
514 
515  static Int_t AutoBrowse(TObject *obj, TBrowser *browser);
516  static ENewType IsCallingNew();
517  static TClass *Load(TBuffer &b);
518  void Store(TBuffer &b) const;
519 
520  // Pseudo-method apply to the 'obj'. In particular those are used to
521  // implement TObject like methods for non-TObject classes
522 
523  Int_t Browse(void *obj, TBrowser *b) const;
524  void DeleteArray(void *ary, Bool_t dtorOnly = kFALSE);
525  void Destructor(void *obj, Bool_t dtorOnly = kFALSE);
526  void *DynamicCast(const TClass *base, void *obj, Bool_t up = kTRUE);
527  const void *DynamicCast(const TClass *base, const void *obj, Bool_t up = kTRUE);
528  Bool_t IsFolder(void *obj) const;
529 
530  inline void Streamer(void *obj, TBuffer &b, const TClass *onfile_class = 0) const
531  {
532  // Inline for performance, skipping one function call.
533 #ifdef R__NO_ATOMIC_FUNCTION_POINTER
534  fStreamerImpl(this,obj,b,onfile_class);
535 #else
536  auto t = fStreamerImpl.load();
537  t(this,obj,b,onfile_class);
538 #endif
539  }
540 
541  ClassDef(TClass,0) //Dictionary containing class information
542 };
543 
544 namespace ROOT {
545  template <typename T> TClass* GetClass( T* /* dummy */) { return TClass::GetClass(typeid(T)); }
546  template <typename T> TClass* GetClass(const T* /* dummy */) { return TClass::GetClass(typeid(T)); }
547 
548 #ifndef R__NO_CLASS_TEMPLATE_SPECIALIZATION
549  // This can only be used when the template overload resolution can distringuish between
550  // T* and T**
551  template <typename T> TClass* GetClass( T** /* dummy */) { return GetClass((T*)0); }
552  template <typename T> TClass* GetClass(const T** /* dummy */) { return GetClass((T*)0); }
553  template <typename T> TClass* GetClass( T* const* /* dummy */) { return GetClass((T*)0); }
554  template <typename T> TClass* GetClass(const T* const* /* dummy */) { return GetClass((T*)0); }
555 #endif
556 
557  extern TClass *CreateClass(const char *cname, Version_t id,
558  const char *dfil, const char *ifil,
559  Int_t dl, Int_t il);
560 }
561 
562 #endif // ROOT_TClass
void AddClass(const char *cname, Version_t id, const std::type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Global function called by the ctor of a class&#39;s init class (see the ClassImp macro).
Short_t GetImplFileLine() const
Definition: TClass.h:399
ShowMembersFunc_t fShowMembers
Definition: TClass.h:195
Bool_t HasInterpreterInfoInMemory() const
Definition: TClass.h:363
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
An array of TObjects.
Definition: TObjArray.h:37
ROOT::NewArrFunc_t fNewArray
Definition: TClass.h:206
void(* ClassStreamerFunc_t)(TBuffer &, void *)
Definition: Rtypes.h:62
std::atomic< TMethodCall * > fIsAMethod
Definition: TClass.h:201
const char * GetDeclFileName() const
Definition: TClass.h:376
void(* ShowMembersFunc_t)(const void *obj, TMemberInspector &R__insp, Bool_t isTransient)
Definition: Rtypes.h:88
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
short Version_t
Definition: RtypesCore.h:61
TLine * line
void(* DelArrFunc_t)(void *)
Definition: Rtypes.h:105
const char * GetImplFileName() const
Definition: TClass.h:398
Collectable string class.
Definition: TObjString.h:28
void SetDeclFile(const char *name, int line)
Definition: TClass.h:482
ConvSIMap_t fConversionStreamerInfo
Definition: TClass.h:170
Long64_t(* MergeFunc_t)(void *, TCollection *, TFileMergeInfo *)
Definition: Rtypes.h:108
const char Option_t
Definition: RtypesCore.h:62
Dictionary for function template This class describes one single function template.
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:31
const char * Size
Definition: TXMLSetup.cxx:56
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
Short_t GetDeclFileLine() const
Definition: TClass.h:377
double T(double x)
Definition: ChebyshevPol.h:34
ENewType
Definition: TClass.h:91
T ReadBuffer(TBufferFile *buf)
One of the template functions used to read objects from messages.
Definition: MPSendRecv.h:157
std::atomic< TListOfEnums * > fEnums
Definition: TClass.h:175
TViewPubFunctions * fAllPubMethod
Definition: TClass.h:180
#define BIT(n)
Definition: Rtypes.h:75
Persistent version of a TClass.
Definition: TProtoClass.h:35
std::atomic< Bool_t > fHasRootPcmInfo
C++ Property of the class (is abstract, has virtual table, etc.)
Definition: TClass.h:220
static THashTable * fgClassTypedefHash
Definition: TClass.h:306
const std::type_info * GetTypeInfo() const
Definition: TClass.h:441
std::atomic< std::map< std::string, TObjArray * > * > ConvSIMap_t
Persistent address of pointer to this TClass object and its successors.
Definition: TClass.h:167
ROOT::DirAutoAdd_t fDirAutoAdd
Definition: TClass.h:210
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
Bool_t HasInterpreterInfo() const
Definition: TClass.h:364
Basic string class.
Definition: TString.h:129
TString fContextMenuTitle
Definition: TClass.h:193
TVirtualStreamerInfo * GetCurrentStreamerInfo()
Definition: TClass.h:383
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TVirtualRefProxy * fRefProxy
cached streamer info used in the last read.
Definition: TClass.h:230
const char * GetContextMenuTitle() const
Definition: TClass.h:382
Int_t fStreamerType
saved info to call Streamer
Definition: TClass.h:226
Abstract base class for accessing the data-members of a class.
void SetImplFileName(const char *implFileName)
Definition: TClass.h:487
UInt_t GetHeapInstanceCount() const
Definition: TClass.h:409
const void * DeclId_t
Definition: TDictionary.h:205
std::atomic< Bool_t > fIsOffsetStreamerSet
Indicates whether the ClassInfo is supposed to be available.
Definition: TClass.h:222
std::atomic< TVirtualStreamerInfo * > fLastReadInfo
cached current streamer info.
Definition: TClass.h:229
void SetClassSize(Int_t sizof)
Definition: TClass.h:258
Short_t fImplFileLine
Definition: TClass.h:186
ROOT::NewFunc_t fNew
Definition: TClass.h:205
void ResetInstanceCount()
Definition: TClass.h:474
void SetLastReadInfo(TVirtualStreamerInfo *info)
Definition: TClass.h:388
TDeclNameRegistry & fNoInfoOrEmuOrFwdDeclNameRegistry
Definition: TClass.h:148
TClass * GetClass(T *)
Definition: TClass.h:545
THashTable implements a hash table to store TObject&#39;s.
Definition: THashTable.h:35
#define ClassDef(name, id)
Definition: Rtypes.h:297
void Dump() const
Dump contents of object on stdout.
Definition: TClass.h:353
std::atomic< TList * > fBase
Definition: TClass.h:172
ClassStreamerFunc_t fStreamerFunc
Definition: TClass.h:211
ECheckSum
Definition: TClass.h:92
void(* MemberStreamerFunc_t)(TBuffer &, void *, Int_t)
Definition: Rtypes.h:64
ROOT::ResetAfterMergeFunc_t fResetAfterMerge
Definition: TClass.h:204
EFunctionMatchMode
Definition: TDictionary.h:151
EState GetState() const
Definition: TClass.h:433
ClassInfo_t * GetClassInfo() const
Definition: TClass.h:381
void *(* NewFunc_t)(void *)
Definition: Rtypes.h:102
Method or function calling interface.
Definition: TMethodCall.h:37
std::atomic< Bool_t > fVersionUsed
saved remember if fOffsetStreamer has been set.
Definition: TClass.h:223
TListOfFunctionTemplates * fFuncTemplate
Definition: TClass.h:176
TClass *(* DictFuncPtr_t)()
Definition: Rtypes.h:70
const TObjArray * GetStreamerInfos() const
Definition: TClass.h:437
TViewPubDataMembers * fAllPubData
Definition: TClass.h:179
TList * fClassMenuList
Definition: TClass.h:181
ROOT::Detail::TSchemaRuleSet * fSchemaRules
Pointer to reference proxy if this class represents a reference.
Definition: TClass.h:231
void(* ClassConvStreamerFunc_t)(TBuffer &, void *, const TClass *)
Definition: Rtypes.h:63
std::atomic< StreamerImpl_t > fStreamerImpl
Definition: TClass.h:237
TList * fRealData
Definition: TClass.h:171
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:727
EStreamerType
Definition: TClass.h:283
A doubly linked list.
Definition: TList.h:43
View implementing the TList interface and giving access all the TDictionary describing public data me...
const char * fImplFileName
Definition: TClass.h:184
TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
Definition: Cppyy.cxx:207
void(* ResetAfterMergeFunc_t)(void *, TFileMergeInfo *)
Definition: Rtypes.h:109
ShowMembersFunc_t GetShowMembersWrapper() const
Definition: TClass.h:432
void AddInstance(Bool_t heap=kFALSE)
Definition: TClass.h:336
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
std::atomic_flag & fAFlag
Definition: TClass.h:126
Int_t fCanSplit
Definition: TClass.h:215
th1 Draw()
std::atomic< TVirtualStreamerInfo * > fCurrentInfo
Current &#39;state&#39; of the class (Emulated,Interpreted,Loaded)
Definition: TClass.h:228
void ResetClassVersion(TClass *, const char *, Short_t)
Global function to update the version number.
void *(* NewArrFunc_t)(Long_t size, void *arena)
Definition: Rtypes.h:103
TString fOrigName
Definition: TClass.h:301
UInt_t GetInstanceCount() const
Definition: TClass.h:408
void RemoveClass(const char *cname)
Global function called by the dtor of a class&#39;s init class (see the ClassImp macro).
TVirtualStreamerInfo * GetLastReadInfo() const
Definition: TClass.h:387
This class defines an abstract interface that must be implemented by all classes that contain diction...
Definition: TDictionary.h:158
Collection abstract base class.
Definition: TCollection.h:42
unsigned int UInt_t
Definition: RtypesCore.h:42
TClass * CreateClass(const char *cname, Version_t id, const std::type_info &info, TVirtualIsAProxy *isa, const char *dfil, const char *ifil, Int_t dl, Int_t il)
Global function called by a class&#39; static Dictionary() method (see the ClassDef macro).
Definition: TClass.cxx:5506
short Short_t
Definition: RtypesCore.h:35
The TRealData class manages the effective list of all data members for a given class.
Definition: TRealData.h:30
Bool_t CanIgnoreTObjectStreamer()
Definition: TClass.h:348
TClass *const * GetPersistentRef() const
Definition: TClass.h:425
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
TVirtualCollectionProxy * fCollectionProxy
Definition: TClass.h:190
ROOT::TMapTypeToTClass IdMap_t
Definition: TClass.h:68
UInt_t fInstanceCount
Definition: TClass.h:187
TVirtualRefProxy * GetReferenceProxy() const
Definition: TClass.h:428
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=0) const
Definition: TClass.h:530
UInt_t fOnHeap
Definition: TClass.h:188
Each class (see TClass) has a linked list of its base class(es).
Definition: TBaseClass.h:31
View implementing the TList interface and giving access all the TFunction describing public methods i...
Short_t SetClassVersion(RootClass *)
const Bool_t kFALSE
Definition: RtypesCore.h:92
ROOT::DesFunc_t fDestructor
Definition: TClass.h:209
std::atomic_flag fSpinLock
Definition: TClass.h:141
Int_t fSizeof
Definition: TClass.h:213
std::unordered_set< std::string > fClassNamesSet
Definition: TClass.h:140
long Long_t
Definition: RtypesCore.h:50
std::atomic< TListOfFunctions * > fMethod
Definition: TClass.h:177
ROOT::DelArrFunc_t fDeleteArray
Definition: TClass.h:208
Version_t GetClassVersion() const
Definition: TClass.h:372
UInt_t GetListOfMethods(TList &methods, TDirectory *dir=0)
Definition: tmvaglob.cxx:582
TObjArray * fStreamerInfo
Definition: TClass.h:169
std::atomic< TClass ** > fPersistentRef
Definition: TClass.h:165
Long_t fOffsetStreamer
Indicates whether GetClassVersion has been called.
Definition: TClass.h:225
EState fState
cached of the streaming method to use
Definition: TClass.h:227
TText * text
ROOT::DelFunc_t fDelete
Definition: TClass.h:207
TList * GetListOfRealData() const
Definition: TClass.h:395
Bool_t HasDataMemberInfo() const
Definition: TClass.h:361
virtual void Dump() const
Dump contents of object on stdout.
Definition: TObject.cxx:273
const std::type_info * fTypeInfo
Definition: TClass.h:194
static TDeclNameRegistry fNoInfoOrEmuOrFwdDeclNameRegistry
Definition: TClass.h:277
TClass *(* IsAGlobalFunc_t)(const TClass *, const void *obj)
Definition: Rtypes.h:90
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2885
TVirtualIsAProxy * fIsA
Definition: TClass.h:199
std::atomic< Long_t > fProperty
Indicates whether this class can be split or not.
Definition: TClass.h:216
IsAGlobalFunc_t fGlobalIsA
pointer to the class&#39;s IsA proxy.
Definition: TClass.h:200
ROOT::TMapDeclIdToTClass DeclIdMap_t
Definition: TClass.h:69
Binding & operator=(OUT(*fun)(void))
Long_t fClassProperty
Property.
Definition: TClass.h:217
Int_t GetClassSize() const
Definition: TClass.h:373
Mother of all ROOT objects.
Definition: TObject.h:37
Short_t fDeclFileLine
Definition: TClass.h:185
void(* DelFunc_t)(void *)
Definition: Rtypes.h:104
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TClass.h:449
static std::atomic< Int_t > fgClassCount
Definition: TClass.h:275
typedef void((*Func_t)())
Version_t fClassVersion
Definition: TClass.h:191
TString fSharedLibs
Definition: TClass.h:197
std::atomic< UInt_t > fCheckSum
Definition: TClass.h:189
TListOfDataMembers * fData
Definition: TClass.h:173
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
Definition: TListOfEnums.h:32
ClassInfo_t * fClassInfo
Definition: TClass.h:192
void(* DirAutoAdd_t)(void *, TDirectory *)
Definition: Rtypes.h:107
Bool_t IsVersioned() const
Definition: TClass.h:453
Each ROOT class (see TClass) has a linked list of methods.
Definition: TMethod.h:38
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
ClassConvStreamerFunc_t fConvStreamerFunc
Definition: TClass.h:212
const char * proto
Definition: civetweb.c:11652
const char * fDeclFileName
Definition: TClass.h:183
TClassStreamer * fStreamer
Definition: TClass.h:196
std::atomic< Bool_t > fCanLoadClassInfo
Whether info was loaded from a root pcm.
Definition: TClass.h:221
double result[121]
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
Abstract Interface class describing Streamer information for one class.
const Bool_t kTRUE
Definition: RtypesCore.h:91
ROOT::MergeFunc_t fMerge
saved info to call a IsA member function
Definition: TClass.h:203
EState
Definition: TClass.h:105
void(* DesFunc_t)(void *)
Definition: Rtypes.h:106