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