Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 // TClass //
18 // //
19 // Dictionary of a class. //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TDictionary.h"
24 #include "TString.h"
25 #include "TObjArray.h"
26 #include "TObjString.h"
27 
28 #include <map>
29 #include <string>
30 #include <set>
31 #include <unordered_set>
32 #include <vector>
33 
34 #include <atomic>
35 #include "ThreadLocalStorage.h"
36 
37 class TBaseClass;
38 class TBrowser;
39 class TDataMember;
40 class TCling;
41 class TMethod;
42 class TRealData;
43 class TBuffer;
44 class TVirtualStreamerInfo;
45 class TVirtualCollectionProxy;
46 class TMethodCall;
47 class TVirtualIsAProxy;
48 class TVirtualRefProxy;
49 class THashTable;
50 class TListOfFunctions;
51 class TListOfFunctionTemplates;
52 class TListOfDataMembers;
53 class TListOfEnums;
54 class TViewPubFunctions;
55 class TViewPubDataMembers;
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  namespace Internal {
68  class TCheckHashRecursiveRemoveConsistency;
69  }
70 }
71 
72 typedef ROOT::TMapTypeToTClass IdMap_t;
73 typedef ROOT::TMapDeclIdToTClass DeclIdMap_t;
74 
75 class TClass : public TDictionary {
76 
77 friend class TCling;
78 friend void ROOT::ResetClassVersion(TClass*, const char*, Short_t);
79 friend class ROOT::TGenericClassInfo;
80 friend class TProtoClass;
81 friend class ROOT::Internal::TCheckHashRecursiveRemoveConsistency;
82 
83 public:
84  // TClass status bits
85  enum EStatusBits {
86  kReservedLoading = BIT(7), // Internal status bits, set and reset only during initialization
87 
88  kClassSaved = BIT(12),
89  kHasLocalHashMember = BIT(14),
90  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
126  // in ROOT Meta w/o interpreter information
127  };
128 
129 private:
130 
131 
132 
133  class TDeclNameRegistry {
134  // A class which is used to collect decl names starting from normalised
135  // names (typedef resolution is excluded here, just string manipulation
136  // is performed). At the heart of the implementation, an unordered set.
137  public:
138  TDeclNameRegistry(Int_t verbLevel=0);
139  void AddQualifiedName(const char *name);
140  Bool_t HasDeclName(const char *name) const;
141  ~TDeclNameRegistry();
142  private:
143  Int_t fVerbLevel=0;
144  std::unordered_set<std::string> fClassNamesSet;
145  mutable std::atomic_flag fSpinLock; // MSVC doesn't support = ATOMIC_FLAG_INIT;
146  };
147 
148  class InsertTClassInRegistryRAII {
149  // Trivial RAII used to insert names in the registry
150  TClass::EState& fState;
151  const char* fName;
152  TDeclNameRegistry& fNoInfoOrEmuOrFwdDeclNameRegistry;
153  public:
154  InsertTClassInRegistryRAII(TClass::EState &state, const char *name, TDeclNameRegistry &emuRegistry);
155  ~InsertTClassInRegistryRAII();
156  };
157 
158  // TClass objects can be created as a result of opening a TFile (in which
159  // they are in emulated mode) or as a result of loading the dictionary for
160  // the corresponding class. When a dictionary is loaded any pre-existing
161  // emulated TClass is replaced by the one created/coming from the dictionary.
162  // To have a reference that always point to the 'current' TClass object for
163  // a given class, one should use a TClassRef.
164  // TClassRef works by holding on to the fPersistentRef which is updated
165  // atomically whenever a TClass is replaced. During the replacement the
166  // value of fPersistentRef is set to zero, leading the TClassRef to call
167  // TClass::GetClass which is also locked by the replacement. At the end
168  // of the replacement, fPersistentRef points to the new TClass object.
169  std::atomic<TClass**> fPersistentRef;//!Persistent address of pointer to this TClass object and its successors.
170 
171  typedef std::atomic<std::map<std::string, TObjArray*>*> ConvSIMap_t;
172 
173  mutable TObjArray *fStreamerInfo; //Array of TVirtualStreamerInfo
174  mutable ConvSIMap_t fConversionStreamerInfo; //Array of the streamer infos derived from another class.
175  TList *fRealData; //linked list for persistent members including base classes
176  std::atomic<TList*> fBase; //linked list for base classes
177  TListOfDataMembers *fData; //linked list for data members
178 
179  std::atomic<TListOfEnums*> fEnums; //linked list for the enums
180  TListOfFunctionTemplates *fFuncTemplate; //linked list for function templates [Not public until implemented as active list]
181  std::atomic<TListOfFunctions*> fMethod; //linked list for methods
182 
183  TViewPubDataMembers*fAllPubData; //all public data members (including from base classes)
184  TViewPubFunctions *fAllPubMethod; //all public methods (including from base classes)
185  mutable TList *fClassMenuList; //list of class menu items
186 
187  const char *fDeclFileName; //name of class declaration file
188  const char *fImplFileName; //name of class implementation file
189  Short_t fDeclFileLine; //line of class declaration
190  Short_t fImplFileLine; //line of class implementation
191  UInt_t fInstanceCount; //number of instances of this class
192  UInt_t fOnHeap; //number of instances on heap
193  mutable std::atomic<UInt_t> fCheckSum; //checksum of data members and base classes
194  TVirtualCollectionProxy *fCollectionProxy; //Collection interface
195  Version_t fClassVersion; //Class version Identifier
196  ClassInfo_t *fClassInfo; //pointer to CINT class info class
197  TString fContextMenuTitle;//context menu title
198  const std::type_info *fTypeInfo; //pointer to the C++ type information.
199  ShowMembersFunc_t fShowMembers; //pointer to the class's ShowMembers function
200  TClassStreamer *fStreamer; //pointer to streamer function
201  TString fSharedLibs; //shared libraries containing class code
202 
203  TVirtualIsAProxy *fIsA; //!pointer to the class's IsA proxy.
204  IsAGlobalFunc_t fGlobalIsA; //pointer to a global IsA function.
205  mutable std::atomic<TMethodCall*> fIsAMethod; //!saved info to call a IsA member function
206 
207  ROOT::MergeFunc_t fMerge; //pointer to a function implementing Merging objects of this class.
208  ROOT::ResetAfterMergeFunc_t fResetAfterMerge; //pointer to a function implementing Merging objects of this class.
209  ROOT::NewFunc_t fNew; //pointer to a function newing one object.
210  ROOT::NewArrFunc_t fNewArray; //pointer to a function newing an array of objects.
211  ROOT::DelFunc_t fDelete; //pointer to a function deleting one object.
212  ROOT::DelArrFunc_t fDeleteArray; //pointer to a function deleting an array of objects.
213  ROOT::DesFunc_t fDestructor; //pointer to a function call an object's destructor.
214  ROOT::DirAutoAdd_t fDirAutoAdd; //pointer which implements the Directory Auto Add feature for this class.']'
215  ClassStreamerFunc_t fStreamerFunc; //Wrapper around this class custom Streamer member function.
216  ClassConvStreamerFunc_t fConvStreamerFunc; //Wrapper around this class custom conversion Streamer member function.
217  Int_t fSizeof; //Sizeof the class.
218 
219  Int_t fCanSplit; //!Indicates whether this class can be split or not.
220  mutable std::atomic<Long_t> fProperty; //!Property
221  mutable Long_t fClassProperty; //!C++ Property of the class (is abstract, has virtual table, etc.)
222 
223  // fHasRootPcmInfo needs to be atomic as long as GetListOfBases needs to modify it.
224  std::atomic<Bool_t> fHasRootPcmInfo; //!Whether info was loaded from a root pcm.
225  mutable std::atomic<Bool_t> fCanLoadClassInfo; //!Indicates whether the ClassInfo is supposed to be available.
226  mutable std::atomic<Bool_t> fIsOffsetStreamerSet; //!saved remember if fOffsetStreamer has been set.
227  mutable std::atomic<Bool_t> fVersionUsed; //!Indicates whether GetClassVersion has been called
228 
229  enum class ERuntimeProperties : UChar_t {
230  kNotInitialized = 0,
231  kSet = BIT(0),
232  // kInconsistent when kSet & !kConsistent.
233  kConsistentHash = BIT(1)
234  };
235  friend bool operator&(UChar_t l, ERuntimeProperties r) {
236  return l & static_cast<UChar_t>(r);
237  }
238  mutable std::atomic<UChar_t> fRuntimeProperties; //! Properties that can only be evaluated at run-time
239 
240  mutable Long_t fOffsetStreamer; //!saved info to call Streamer
241  Int_t fStreamerType; //!cached of the streaming method to use
242  EState fState; //!Current 'state' of the class (Emulated,Interpreted,Loaded)
243  mutable std::atomic<TVirtualStreamerInfo*> fCurrentInfo; //!cached current streamer info.
244  mutable std::atomic<TVirtualStreamerInfo*> fLastReadInfo; //!cached streamer info used in the last read.
245  TVirtualRefProxy *fRefProxy; //!Pointer to reference proxy if this class represents a reference
246  ROOT::Detail::TSchemaRuleSet *fSchemaRules; //! Schema evolution rules
247 
248  typedef void (*StreamerImpl_t)(const TClass* pThis, void *obj, TBuffer &b, const TClass *onfile_class);
249 #ifdef R__NO_ATOMIC_FUNCTION_POINTER
250  mutable StreamerImpl_t fStreamerImpl; //! Pointer to the function implementing streaming for this class
251 #else
252  mutable std::atomic<StreamerImpl_t> fStreamerImpl; //! Pointer to the function implementing streaming for this class
253 #endif
254 
255  Bool_t CanSplitBaseAllow();
256  TListOfFunctions *GetMethodList();
257  TMethod *GetClassMethod(Long_t faddr);
258  TMethod *FindClassOrBaseMethodWithId(DeclId_t faddr);
259  Int_t GetBaseClassOffsetRecurse(const TClass *toBase);
260  void Init(const char *name, Version_t cversion, const std::type_info *info,
261  TVirtualIsAProxy *isa,
262  const char *dfil, const char *ifil,
263  Int_t dl, Int_t il,
264  ClassInfo_t *classInfo,
265  Bool_t silent);
266  void ForceReload (TClass* oldcl);
267  void LoadClassInfo() const;
268 
269  static TClass *LoadClassDefault(const char *requestedname, Bool_t silent);
270  static TClass *LoadClassCustom(const char *requestedname, Bool_t silent);
271 
272  void SetClassVersion(Version_t version);
273  void SetClassSize(Int_t sizof) { fSizeof = sizof; }
274  TVirtualStreamerInfo* DetermineCurrentStreamerInfo();
275 
276  void SetStreamerImpl();
277 
278  void SetRuntimeProperties();
279 
280  // Various implementation for TClass::Stramer
281  static void StreamerExternal(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
282  static void StreamerTObject(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
283  static void StreamerTObjectInitialized(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
284  static void StreamerTObjectEmulated(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
285  static void StreamerInstrumented(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
286  static void ConvStreamerInstrumented(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
287  static void StreamerStreamerInfo(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
288  static void StreamerDefault(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class);
289 
290  static IdMap_t *GetIdMap(); //Map from typeid to TClass pointer
291  static DeclIdMap_t *GetDeclIdMap(); //Map from DeclId_t to TClass pointer
292  static std::atomic<Int_t> fgClassCount; //provides unique id for a each class
293  //stored in TObject::fUniqueID
294  static TDeclNameRegistry fNoInfoOrEmuOrFwdDeclNameRegistry; // Store decl names of the forwardd and no info instances
295  static Bool_t HasNoInfoOrEmuOrFwdDeclaredDecl(const char*);
296 
297  // Internal status bits, set and reset only during initialization and thus under the protection of the global lock.
298  enum { kLoading = kReservedLoading, kUnloading = kReservedLoading };
299  // Internal streamer type.
300  enum EStreamerType {kDefault=0, kEmulatedStreamer=1, kTObject=2, kInstrumented=4, kForeign=8, kExternal=16};
301 
302  // When a new class is created, we need to be able to find
303  // if there are any existing classes that have the same name
304  // after any typedefs are expanded. (This only really affects
305  // template arguments.) To avoid having to search through all classes
306  // in that case, we keep a hash table mapping from the fully
307  // typedef-expanded names to the original class names.
308  // An entry is made in the table only if they are actually different.
309  //
310  // In these objects, the TObjString base holds the typedef-expanded
311  // name (the hash key), and fOrigName holds the original class name
312  // (the value to which the key maps).
313  //
314  class TNameMapNode : public TObjString
315  {
316  public:
317  TNameMapNode (const char* typedf, const char* orig);
318  TString fOrigName;
319  };
320 
321  // These are the above-referenced hash tables. (The pointers are null
322  // if no entries have been made.)
323  static THashTable* fgClassTypedefHash;
324 
325 private:
326  TClass(const TClass& tc) = delete;
327  TClass& operator=(const TClass&) = delete;
328 
329 protected:
330  TVirtualStreamerInfo *FindStreamerInfo(TObjArray *arr, UInt_t checksum) const;
331  void GetMissingDictionariesForBaseClasses(TCollection &result, TCollection &visited, bool recurse);
332  void GetMissingDictionariesForMembers(TCollection &result, TCollection &visited, bool recurse);
333  void GetMissingDictionariesWithRecursionCheck(TCollection &result, TCollection &visited, bool recurse);
334  void GetMissingDictionariesForPairElements(TCollection &result, TCollection &visited, bool recurse);
335 
336 public:
337  TClass();
338  TClass(const char *name, Bool_t silent = kFALSE);
339  TClass(const char *name, Version_t cversion, Bool_t silent = kFALSE);
340  TClass(const char *name, Version_t cversion, EState theState, Bool_t silent = kFALSE);
341  TClass(ClassInfo_t *info, Version_t cversion,
342  const char *dfil, const char *ifil = 0,
343  Int_t dl = 0, Int_t il = 0, Bool_t silent = kFALSE);
344  TClass(const char *name, Version_t cversion,
345  const char *dfil, const char *ifil = 0,
346  Int_t dl = 0, Int_t il = 0, Bool_t silent = kFALSE);
347  TClass(const char *name, Version_t cversion,
348  const std::type_info &info, TVirtualIsAProxy *isa,
349  const char *dfil, const char *ifil,
350  Int_t dl, Int_t il, Bool_t silent = kFALSE);
351  virtual ~TClass();
352 
353  void AddInstance(Bool_t heap = kFALSE) { fInstanceCount++; if (heap) fOnHeap++; }
354  void AddImplFile(const char *filename, int line);
355  static Bool_t AddRule(const char *rule);
356  static Int_t ReadRules(const char *filename);
357  static Int_t ReadRules();
358  void AdoptSchemaRules( ROOT::Detail::TSchemaRuleSet *rules );
359  virtual void Browse(TBrowser *b);
360  void BuildRealData(void *pointer=0, Bool_t isTransient = kFALSE);
361  void BuildEmulatedRealData(const char *name, Long_t offset, TClass *cl);
362  void CalculateStreamerOffset() const;
363  Bool_t CallShowMembers(const void* obj, TMemberInspector &insp, Bool_t isTransient = kFALSE) const;
364  Bool_t CanSplit() const;
365  Bool_t CanIgnoreTObjectStreamer() { return TestBit(kIgnoreTObjectStreamer);}
366  Long_t ClassProperty() const;
367  TObject *Clone(const char *newname="") const;
368  void CopyCollectionProxy(const TVirtualCollectionProxy&);
369  void Draw(Option_t *option="");
370  void Dump() const { TDictionary::Dump(); }
371  void Dump(const void *obj, Bool_t noAddr = kFALSE) const;
372  char *EscapeChars(const char *text) const;
373  TVirtualStreamerInfo *FindStreamerInfo(UInt_t checksum) const;
374  TVirtualStreamerInfo *GetConversionStreamerInfo( const char* onfile_classname, Int_t version ) const;
375  TVirtualStreamerInfo *FindConversionStreamerInfo( const char* onfile_classname, UInt_t checksum ) const;
376  TVirtualStreamerInfo *GetConversionStreamerInfo( const TClass* onfile_cl, Int_t version ) const;
377  TVirtualStreamerInfo *FindConversionStreamerInfo( const TClass* onfile_cl, UInt_t checksum ) const;
378  Bool_t HasDataMemberInfo() const { return fHasRootPcmInfo || HasInterpreterInfo(); }
379  Bool_t HasDefaultConstructor() const;
380  Bool_t HasInterpreterInfoInMemory() const { return 0 != fClassInfo; }
381  Bool_t HasInterpreterInfo() const { return fCanLoadClassInfo || fClassInfo; }
382  UInt_t GetCheckSum(ECheckSum code = kCurrentCheckSum) const;
383  UInt_t GetCheckSum(Bool_t &isvalid) const;
384  UInt_t GetCheckSum(ECheckSum code, Bool_t &isvalid) const;
385  TVirtualCollectionProxy *GetCollectionProxy() const;
386  TVirtualIsAProxy *GetIsAProxy() const;
387  TMethod *GetClassMethod(const char *name, const char *params, Bool_t objectIsConst = kFALSE);
388  TMethod *GetClassMethodWithPrototype(const char *name, const char *proto,
389  Bool_t objectIsConst = kFALSE,
390  ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch);
391  Version_t GetClassVersion() const { fVersionUsed = kTRUE; return fClassVersion; }
392  Int_t GetClassSize() const { return Size(); }
393  TDataMember *GetDataMember(const char *datamember) const;
394  Long_t GetDataMemberOffset(const char *membername) const;
395  const char *GetDeclFileName() const;
396  Short_t GetDeclFileLine() const { return fDeclFileLine; }
397  ROOT::DelFunc_t GetDelete() const;
398  ROOT::DesFunc_t GetDestructor() const;
399  ROOT::DelArrFunc_t GetDeleteArray() const;
400  ClassInfo_t *GetClassInfo() const {
401  if (fCanLoadClassInfo && !TestBit(kLoading))
402  LoadClassInfo();
403  return fClassInfo;
404  }
405  const char *GetContextMenuTitle() const { return fContextMenuTitle; }
406  TVirtualStreamerInfo *GetCurrentStreamerInfo() {
407  if (fCurrentInfo.load()) return fCurrentInfo;
408  else return DetermineCurrentStreamerInfo();
409  }
410  TVirtualStreamerInfo *GetLastReadInfo() const { return fLastReadInfo; }
411  void SetLastReadInfo(TVirtualStreamerInfo *info) { fLastReadInfo = info; }
412  TList *GetListOfDataMembers(Bool_t load = kTRUE);
413  TList *GetListOfEnums(Bool_t load = kTRUE);
414  TList *GetListOfFunctionTemplates(Bool_t load = kTRUE);
415  TList *GetListOfBases();
416  TList *GetListOfMethods(Bool_t load = kTRUE);
417  TCollection *GetListOfMethodOverloads(const char* name) const;
418  TList *GetListOfRealData() const { return fRealData; }
419  const TList *GetListOfAllPublicMethods(Bool_t load = kTRUE);
420  TList *GetListOfAllPublicDataMembers(Bool_t load = kTRUE);
421  const char *GetImplFileName() const { return fImplFileName; }
422  Short_t GetImplFileLine() const { return fImplFileLine; }
423  TClass *GetActualClass(const void *object) const;
424  TClass *GetBaseClass(const char *classname);
425  TClass *GetBaseClass(const TClass *base);
426  Int_t GetBaseClassOffset(const TClass *toBase, void *address = 0, bool isDerivedObject = true);
427  TClass *GetBaseDataMember(const char *datamember);
428  ROOT::ESTLType GetCollectionType() const;
429  ROOT::DirAutoAdd_t GetDirectoryAutoAdd() const;
430  TFunctionTemplate *GetFunctionTemplate(const char *name);
431  UInt_t GetInstanceCount() const { return fInstanceCount; }
432  UInt_t GetHeapInstanceCount() const { return fOnHeap; }
433  void GetMenuItems(TList *listitems);
434  TList *GetMenuList() const;
435  TMethod *GetMethod(const char *method, const char *params, Bool_t objectIsConst = kFALSE);
436  TMethod *GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst = kFALSE,
437  ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch);
438  TMethod *GetMethodAny(const char *method);
439  TMethod *GetMethodAllAny(const char *method);
440  Int_t GetNdata();
441  ROOT::MergeFunc_t GetMerge() const;
442  ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const;
443  ROOT::NewFunc_t GetNew() const;
444  ROOT::NewArrFunc_t GetNewArray() const;
445  Int_t GetNmethods();
446  TClass *const*GetPersistentRef() const { return fPersistentRef; }
447  TRealData *GetRealData(const char *name) const;
448  TVirtualRefProxy *GetReferenceProxy() const { return fRefProxy; }
449  const ROOT::Detail::TSchemaRuleSet *GetSchemaRules() const;
450  ROOT::Detail::TSchemaRuleSet *GetSchemaRules(Bool_t create = kFALSE);
451  const char *GetSharedLibs();
452  ShowMembersFunc_t GetShowMembersWrapper() const { return fShowMembers; }
453  EState GetState() const { return fState; }
454  TClassStreamer *GetStreamer() const;
455  ClassStreamerFunc_t GetStreamerFunc() const;
456  ClassConvStreamerFunc_t GetConvStreamerFunc() const;
457  const TObjArray *GetStreamerInfos() const { return fStreamerInfo; }
458  TVirtualStreamerInfo *GetStreamerInfo(Int_t version=0) const;
459  TVirtualStreamerInfo *GetStreamerInfoAbstractEmulated(Int_t version=0) const;
460  TVirtualStreamerInfo *FindStreamerInfoAbstractEmulated(UInt_t checksum) const;
461  const std::type_info *GetTypeInfo() const { return fTypeInfo; };
462 
463  /// @brief Return 'true' if we can guarantee that if this class (or any class in
464  /// this class inheritance hierarchy) overload TObject::Hash it also starts
465  /// the RecursiveRemove process from its own destructor.
466  Bool_t HasConsistentHashMember()
467  {
468  if (!fRuntimeProperties)
469  SetRuntimeProperties();
470  return fRuntimeProperties.load() & ERuntimeProperties::kConsistentHash;
471  }
472  Bool_t HasDictionary() const;
473  static Bool_t HasDictionarySelection(const char* clname);
474  Bool_t HasLocalHashMember() const;
475  void GetMissingDictionaries(THashTable& result, bool recurse = false);
476  void IgnoreTObjectStreamer(Bool_t ignore=kTRUE);
477  Bool_t InheritsFrom(const char *cl) const;
478  Bool_t InheritsFrom(const TClass *cl) const;
479  void InterpretedShowMembers(void* obj, TMemberInspector &insp, Bool_t isTransient);
480  Bool_t IsFolder() const { return kTRUE; }
481  Bool_t IsLoaded() const;
482  Bool_t IsForeign() const;
483  Bool_t IsStartingWithTObject() const;
484  Bool_t IsVersioned() const { return !( GetClassVersion()<=1 && IsForeign() ); }
485  Bool_t IsTObject() const;
486  static TClass *LoadClass(const char *requestedname, Bool_t silent);
487  void ls(Option_t *opt="") const;
488  void MakeCustomMenuList();
489  Bool_t MatchLegacyCheckSum(UInt_t checksum) const;
490  void Move(void *arenaFrom, void *arenaTo) const;
491  void *New(ENewType defConstructor = kClassNew, Bool_t quiet = kFALSE) const;
492  void *New(void *arena, ENewType defConstructor = kClassNew) const;
493  void *NewArray(Long_t nElements, ENewType defConstructor = kClassNew) const;
494  void *NewArray(Long_t nElements, void *arena, ENewType defConstructor = kClassNew) const;
495  virtual void PostLoadCheck();
496  Long_t Property() const;
497  Int_t ReadBuffer(TBuffer &b, void *pointer, Int_t version, UInt_t start, UInt_t count);
498  Int_t ReadBuffer(TBuffer &b, void *pointer);
499  void RegisterStreamerInfo(TVirtualStreamerInfo *info);
500  void RemoveStreamerInfo(Int_t slot);
501  void ReplaceWith(TClass *newcl) const;
502  void ResetCaches();
503  void ResetClassInfo(Long_t tagnum);
504  void ResetClassInfo();
505  void ResetInstanceCount() { fInstanceCount = fOnHeap = 0; }
506  void ResetMenuList();
507  Int_t Size() const;
508  void SetCanSplit(Int_t splitmode);
509  void SetCollectionProxy(const ROOT::Detail::TCollectionProxyInfo&);
510  void SetContextMenuTitle(const char *title);
511  void SetCurrentStreamerInfo(TVirtualStreamerInfo *info);
512  void SetGlobalIsA(IsAGlobalFunc_t);
513  void SetDeclFile(const char *name, int line) { fDeclFileName = name; fDeclFileLine = line; }
514  void SetDelete(ROOT::DelFunc_t deleteFunc);
515  void SetDeleteArray(ROOT::DelArrFunc_t deleteArrayFunc);
516  void SetDirectoryAutoAdd(ROOT::DirAutoAdd_t dirAutoAddFunc);
517  void SetDestructor(ROOT::DesFunc_t destructorFunc);
518  void SetImplFileName(const char *implFileName) { fImplFileName = implFileName; }
519  void SetMerge(ROOT::MergeFunc_t mergeFunc);
520  void SetResetAfterMerge(ROOT::ResetAfterMergeFunc_t resetFunc);
521  void SetNew(ROOT::NewFunc_t newFunc);
522  void SetNewArray(ROOT::NewArrFunc_t newArrayFunc);
523  TVirtualStreamerInfo *SetStreamerInfo(Int_t version, const char *info="");
524  void SetUnloaded();
525  Int_t WriteBuffer(TBuffer &b, void *pointer, const char *info="");
526 
527  void AdoptReferenceProxy(TVirtualRefProxy* proxy);
528  void AdoptStreamer(TClassStreamer *strm);
529  void AdoptMemberStreamer(const char *name, TMemberStreamer *strm);
530  void SetMemberStreamer(const char *name, MemberStreamerFunc_t strm);
531  void SetStreamerFunc(ClassStreamerFunc_t strm);
532  void SetConvStreamerFunc(ClassConvStreamerFunc_t strm);
533 
534  // Function to retrieve the TClass object and dictionary function
535  static void AddClass(TClass *cl);
536  static void AddClassToDeclIdMap(TDictionary::DeclId_t id, TClass* cl);
537  static void RemoveClass(TClass *cl);
538  static void RemoveClassDeclId(TDictionary::DeclId_t id);
539  static TClass *GetClass(const char *name, Bool_t load = kTRUE, Bool_t silent = kFALSE);
540  static TClass *GetClass(const std::type_info &typeinfo, Bool_t load = kTRUE, Bool_t silent = kFALSE);
541  static TClass *GetClass(ClassInfo_t *info, Bool_t load = kTRUE, Bool_t silent = kFALSE);
542  template<typename T>
543  static TClass *GetClass(Bool_t load = kTRUE, Bool_t silent = kFALSE);
544  static Bool_t GetClass(DeclId_t id, std::vector<TClass*> &classes);
545  static DictFuncPtr_t GetDict (const char *cname);
546  static DictFuncPtr_t GetDict (const std::type_info &info);
547 
548  static Int_t AutoBrowse(TObject *obj, TBrowser *browser);
549  static ENewType IsCallingNew();
550  static TClass *Load(TBuffer &b);
551  void Store(TBuffer &b) const;
552 
553  // Pseudo-method apply to the 'obj'. In particular those are used to
554  // implement TObject like methods for non-TObject classes
555 
556  Int_t Browse(void *obj, TBrowser *b) const;
557  void DeleteArray(void *ary, Bool_t dtorOnly = kFALSE);
558  void Destructor(void *obj, Bool_t dtorOnly = kFALSE);
559  void *DynamicCast(const TClass *base, void *obj, Bool_t up = kTRUE);
560  const void *DynamicCast(const TClass *base, const void *obj, Bool_t up = kTRUE);
561  Bool_t IsFolder(void *obj) const;
562 
563  inline void Streamer(void *obj, TBuffer &b, const TClass *onfile_class = 0) const
564  {
565  // Inline for performance, skipping one function call.
566 #ifdef R__NO_ATOMIC_FUNCTION_POINTER
567  fStreamerImpl(this,obj,b,onfile_class);
568 #else
569  auto t = fStreamerImpl.load();
570  t(this,obj,b,onfile_class);
571 #endif
572  }
573 
574  ClassDef(TClass,0) //Dictionary containing class information
575 };
576 
577 namespace ROOT {
578 namespace Internal {
579 template <typename T>
580 TClass *GetClassHelper(Bool_t, Bool_t, std::true_type)
581 {
582  return T::Class();
583 }
584 
585 template <typename T>
586 TClass *GetClassHelper(Bool_t load, Bool_t silent, std::false_type)
587 {
588  return TClass::GetClass(typeid(T), load, silent);
589 }
590 
591 } // namespace Internal
592 } // namespace ROOT
593 
594 template <typename T>
595 TClass *TClass::GetClass(Bool_t load, Bool_t silent)
596 {
597  typename std::is_base_of<TObject, T>::type tag;
598  return ROOT::Internal::GetClassHelper<T>(load, silent, tag);
599 }
600 
601 namespace ROOT {
602 
603 template <typename T> TClass *GetClass(T * /* dummy */) { return TClass::GetClass<T>(); }
604 template <typename T> TClass *GetClass(const T * /* dummy */) { return TClass::GetClass<T>(); }
605 
606 #ifndef R__NO_CLASS_TEMPLATE_SPECIALIZATION
607  // This can only be used when the template overload resolution can distinguish between T* and T**
608  template <typename T> TClass* GetClass( T** /* dummy */) { return TClass::GetClass<T>(); }
609  template <typename T> TClass* GetClass(const T** /* dummy */) { return TClass::GetClass<T>(); }
610  template <typename T> TClass* GetClass( T* const* /* dummy */) { return TClass::GetClass<T>(); }
611  template <typename T> TClass* GetClass(const T* const* /* dummy */) { return TClass::GetClass<T>(); }
612 #endif
613 
614  extern TClass *CreateClass(const char *cname, Version_t id,
615  const char *dfil, const char *ifil,
616  Int_t dl, Int_t il);
617 }
618 
619 #endif // ROOT_TClass