#ifndef ROOT_TClass
#define ROOT_TClass
#ifndef ROOT_TDictionary
#include "TDictionary.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TObjArray
#include "TObjArray.h"
#endif
#ifndef ROOT_TObjString
#include "TObjString.h"
#endif
#include <map>
#include <string>
#if __cplusplus >= 201103L
#include <atomic>
#endif
#ifndef ROOT_ThreadLocalStorage
#include "ThreadLocalStorage.h"
#endif
class TBaseClass;
class TBrowser;
class TDataMember;
class TMethod;
class TRealData;
class TCint;
class TBuffer;
class TVirtualStreamerInfo;
class TVirtualCollectionProxy;
class TMethodCall;
class TVirtualIsAProxy;
class TVirtualRefProxy;
class THashTable;
namespace clang {
class Decl;
}
namespace ROOT {
class TGenericClassInfo;
class TCollectionProxyInfo;
class TSchemaRuleSet;
}
namespace ROOT {
class TMapTypeToTClass;
}
typedef ROOT::TMapTypeToTClass IdMap_t;
class TClass : public TDictionary {
friend class TCint;
friend class TCintWithCling;
friend void ROOT::ResetClassVersion(TClass*, const char*, Short_t);
friend class ROOT::TGenericClassInfo;
public:
enum { kClassSaved = BIT(12), kIgnoreTObjectStreamer = BIT(15),
kUnloaded = BIT(16), kIsTObject = BIT(17),
kIsForeign = BIT(18), kIsEmulation = BIT(19),
kStartWithTObject = BIT(20),
kWarned = BIT(21),
kHasNameMapNode = BIT(22)
};
enum ENewType { kRealNew = 0, kClassNew, kDummyNew };
enum ECheckSum {
kCurrentCheckSum = 0,
kNoEnum = 1,
kNoRange = 2,
kWithTypeDef = 3,
kNoBaseCheckSum = 4,
kLatestCheckSum = 5
};
private:
#if __cplusplus >= 201103L
std::atomic<TClass**> fPersistentRef;
#else
TClass **fPersistentRef;
#endif
mutable TObjArray *fStreamerInfo;
#if __cplusplus >= 201103L
mutable std::atomic<std::map<std::string, TObjArray*>*> fConversionStreamerInfo;
#else
mutable std::map<std::string, TObjArray*> *fConversionStreamerInfo;
#endif
TList *fRealData;
TList *fBase;
TList *fData;
TList *fMethod;
TList *fAllPubData;
TList *fAllPubMethod;
mutable TList *fClassMenuList;
const char *fDeclFileName;
const char *fImplFileName;
Short_t fDeclFileLine;
Short_t fImplFileLine;
UInt_t fInstanceCount;
UInt_t fOnHeap;
mutable UInt_t fCheckSum;
TVirtualCollectionProxy *fCollectionProxy;
Version_t fClassVersion;
ClassInfo_t *fClassInfo;
TString fContextMenuTitle;
const type_info *fTypeInfo;
ShowMembersFunc_t fShowMembers;
#if __cplusplus >= 201103L
mutable std::atomic<void*> fInterShowMembers;
#else
mutable void *fInterShowMembers;
#endif
TClassStreamer *fStreamer;
TString fSharedLibs;
TVirtualIsAProxy *fIsA;
IsAGlobalFunc_t fGlobalIsA;
#if __cplusplus >= 201103L
mutable std::atomic<TMethodCall*> fIsAMethod;
#else
mutable TMethodCall *fIsAMethod;
#endif
ROOT::MergeFunc_t fMerge;
ROOT::ResetAfterMergeFunc_t fResetAfterMerge;
ROOT::NewFunc_t fNew;
ROOT::NewArrFunc_t fNewArray;
ROOT::DelFunc_t fDelete;
ROOT::DelArrFunc_t fDeleteArray;
ROOT::DesFunc_t fDestructor;
ROOT::DirAutoAdd_t fDirAutoAdd;
ClassStreamerFunc_t fStreamerFunc;
Int_t fSizeof;
mutable Int_t fCanSplit;
#if __cplusplus >= 201103L
mutable std::atomic<Long_t> fProperty;
mutable std::atomic<Bool_t> fVersionUsed;
#else
mutable Long_t fProperty;
mutable Bool_t fVersionUsed;
#endif
mutable Bool_t fIsOffsetStreamerSet;
mutable Long_t fOffsetStreamer;
Int_t fStreamerType;
#if __cplusplus >= 201103L
mutable std::atomic<TVirtualStreamerInfo*> fCurrentInfo;
mutable std::atomic<TVirtualStreamerInfo*> fLastReadInfo;
#else
mutable TVirtualStreamerInfo *fCurrentInfo;
mutable TVirtualStreamerInfo *fLastReadInfo;
#endif
TVirtualRefProxy *fRefProxy;
ROOT::TSchemaRuleSet *fSchemaRules;
typedef void (TClass::*StreamerImpl_t)(void *obj, TBuffer &b, const TClass *onfile_class) const;
mutable StreamerImpl_t fStreamerImpl;
TMethod *GetClassMethod(Long_t faddr);
TMethod *GetClassMethod(const char *name, const char *signature);
Int_t GetBaseClassOffsetRecurse(const TClass *base);
void Init(const char *name, Version_t cversion, const type_info *info,
TVirtualIsAProxy *isa, ShowMembersFunc_t showmember,
const char *dfil, const char *ifil,
Int_t dl, Int_t il,
Bool_t silent);
void ForceReload (TClass* oldcl);
void SetClassVersion(Version_t version);
void SetClassSize(Int_t sizof) { fSizeof = sizof; }
TVirtualStreamerInfo* DetermineCurrentStreamerInfo();
void StreamerExternal(void *object, TBuffer &b, const TClass *onfile_class) const;
void StreamerTObject(void *object, TBuffer &b, const TClass *onfile_class) const;
void StreamerTObjectInitialized(void *object, TBuffer &b, const TClass *onfile_class) const;
void StreamerTObjectEmulated(void *object, TBuffer &b, const TClass *onfile_class) const;
void StreamerInstrumented(void *object, TBuffer &b, const TClass *onfile_class) const;
void StreamerStreamerInfo(void *object, TBuffer &b, const TClass *onfile_class) const;
void StreamerDefault(void *object, TBuffer &b, const TClass *onfile_class) const;
static IdMap_t *GetIdMap();
#if __cplusplus >= 201103L
static std::atomic<Int_t> fgClassCount;
#else
static Int_t fgClassCount;
#endif
enum { kLoading = BIT(14) };
enum EStreamerType {kDefault=0, kEmulated=1, kTObject=2, kInstrumented=4, kForeign=8, kExternal=16};
class TNameMapNode : public TObjString
{
public:
TNameMapNode (const char* typedf, const char* orig);
TString fOrigName;
};
static THashTable* fgClassTypedefHash;
static THashTable* fgClassShortTypedefHash;
private:
TClass(const TClass& tc);
TClass& operator=(const TClass&);
protected:
TVirtualStreamerInfo *FindStreamerInfo(TObjArray* arr, UInt_t checksum) const;
static THashTable *GetClassShortTypedefHash();
public:
TClass();
TClass(const char *name, Bool_t silent = kFALSE);
TClass(const char *name, Version_t cversion,
const char *dfil = 0, const char *ifil = 0,
Int_t dl = 0, Int_t il = 0, Bool_t silent = kFALSE);
TClass(const char *name, Version_t cversion,
const type_info &info, TVirtualIsAProxy *isa,
ShowMembersFunc_t showmember,
const char *dfil, const char *ifil,
Int_t dl, Int_t il, Bool_t silent = kFALSE);
virtual ~TClass();
void AddInstance(Bool_t heap = kFALSE) { fInstanceCount++; if (heap) fOnHeap++; }
void AddImplFile(const char *filename, int line);
static Bool_t AddRule(const char *rule);
static Int_t ReadRules(const char *filename);
static Int_t ReadRules();
void AdoptSchemaRules( ROOT::TSchemaRuleSet *rules );
virtual void Browse(TBrowser *b);
void BuildRealData(void *pointer=0, Bool_t isTransient = kFALSE);
void BuildEmulatedRealData(const char *name, Long_t offset, TClass *cl);
void CalculateStreamerOffset() const;
Bool_t CallShowMembers(void* obj, TMemberInspector &insp,
Int_t isATObject = -1) const;
Bool_t CanSplit() const;
Bool_t CanIgnoreTObjectStreamer() { return TestBit(kIgnoreTObjectStreamer);}
TObject *Clone(const char *newname="") const;
void CopyCollectionProxy(const TVirtualCollectionProxy&);
void Draw(Option_t *option="");
void Dump() const { TDictionary::Dump(); }
void Dump(void *obj) const;
char *EscapeChars(const char *text) const;
TVirtualStreamerInfo *FindStreamerInfo(UInt_t checksum) const;
TVirtualStreamerInfo *GetConversionStreamerInfo( const char* onfile_classname, Int_t version ) const;
TVirtualStreamerInfo *FindConversionStreamerInfo( const char* onfile_classname, UInt_t checksum ) const;
TVirtualStreamerInfo *GetConversionStreamerInfo( const TClass* onfile_cl, Int_t version ) const;
TVirtualStreamerInfo *FindConversionStreamerInfo( const TClass* onfile_cl, UInt_t checksum ) const;
Bool_t HasDefaultConstructor() const;
UInt_t GetCheckSum(ECheckSum code = kCurrentCheckSum) const;
TVirtualCollectionProxy *GetCollectionProxy() const;
TVirtualIsAProxy *GetIsAProxy() const;
Version_t GetClassVersion() const { fVersionUsed = kTRUE; return fClassVersion; }
Int_t GetClassSize() const { return Size(); }
TDataMember *GetDataMember(const char *datamember) const;
Long_t GetDataMemberOffset(const char *membername) const;
const char *GetDeclFileName() const { return fDeclFileName; }
Short_t GetDeclFileLine() const { return fDeclFileLine; }
ROOT::DelFunc_t GetDelete() const;
ROOT::DesFunc_t GetDestructor() const;
ROOT::DelArrFunc_t GetDeleteArray() const;
ClassInfo_t *GetClassInfo() const { return fClassInfo; }
const char *GetContextMenuTitle() const { return fContextMenuTitle; }
TVirtualStreamerInfo *GetCurrentStreamerInfo() {
if (fCurrentInfo) return fCurrentInfo;
else return DetermineCurrentStreamerInfo();
}
TVirtualStreamerInfo *GetLastReadInfo() const { return fLastReadInfo; }
void SetLastReadInfo(TVirtualStreamerInfo *info) { fLastReadInfo = info; }
TList *GetListOfDataMembers();
TList *GetListOfBases();
TList *GetListOfMethods();
TList *GetListOfRealData() const { return fRealData; }
TList *GetListOfAllPublicMethods();
TList *GetListOfAllPublicDataMembers();
const char *GetImplFileName() const { return fImplFileName; }
Short_t GetImplFileLine() const { return fImplFileLine; }
TClass *GetActualClass(const void *object) const;
TClass *GetBaseClass(const char *classname);
TClass *GetBaseClass(const TClass *base);
Int_t GetBaseClassOffset(const TClass *base);
TClass *GetBaseDataMember(const char *datamember);
ROOT::DirAutoAdd_t GetDirectoryAutoAdd() const;
UInt_t GetInstanceCount() const { return fInstanceCount; }
UInt_t GetHeapInstanceCount() const { return fOnHeap; }
void GetMenuItems(TList *listitems);
TList *GetMenuList() const;
TMethod *GetMethod(const char *method, const char *params);
TMethod *GetMethodWithPrototype(const char *method, const char *proto);
TMethod *GetMethodAny(const char *method);
TMethod *GetMethodAllAny(const char *method);
Int_t GetNdata();
ROOT::MergeFunc_t GetMerge() const;
ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const;
ROOT::NewFunc_t GetNew() const;
ROOT::NewArrFunc_t GetNewArray() const;
Int_t GetNmethods();
#ifdef __CINT__
TClass **GetPersistentRef() const { return fPersistentRef; }
#else
TClass *const*GetPersistentRef() const { return fPersistentRef; }
#endif
TRealData *GetRealData(const char *name) const;
TVirtualRefProxy *GetReferenceProxy() const { return fRefProxy; }
const ROOT::TSchemaRuleSet *GetSchemaRules() const;
ROOT::TSchemaRuleSet *GetSchemaRules(Bool_t create = kFALSE);
const char *GetSharedLibs();
ShowMembersFunc_t GetShowMembersWrapper() const { return fShowMembers; }
TClassStreamer *GetStreamer() const;
ClassStreamerFunc_t GetStreamerFunc() const;
TObjArray *GetStreamerInfos() const { return fStreamerInfo; }
TVirtualStreamerInfo *GetStreamerInfo(Int_t version=0) const;
TVirtualStreamerInfo *GetStreamerInfoAbstractEmulated(Int_t version=0) const;
TVirtualStreamerInfo *FindStreamerInfoAbstractEmulated(UInt_t checksum) const;
const type_info *GetTypeInfo() const { return fTypeInfo; };
void IgnoreTObjectStreamer(Bool_t ignore=kTRUE);
Bool_t InheritsFrom(const char *cl) const;
Bool_t InheritsFrom(const TClass *cl) const;
void InterpretedShowMembers(void* obj, TMemberInspector &insp);
Bool_t IsFolder() const { return kTRUE; }
Bool_t IsLoaded() const;
Bool_t IsForeign() const;
Bool_t IsStartingWithTObject() const;
Bool_t IsVersioned() const { return !( GetClassVersion()<=1 && IsForeign() ); }
Bool_t IsTObject() const;
void ls(Option_t *opt="") const;
void MakeCustomMenuList();
Bool_t MatchLegacyCheckSum(UInt_t checksum) const;
void Move(void *arenaFrom, void *arenaTo) const;
void *New(ENewType defConstructor = kClassNew) const;
void *New(void *arena, ENewType defConstructor = kClassNew) const;
void *NewArray(Long_t nElements, ENewType defConstructor = kClassNew) const;
void *NewArray(Long_t nElements, void *arena, ENewType defConstructor = kClassNew) const;
virtual void PostLoadCheck();
Long_t Property() const;
Int_t ReadBuffer(TBuffer &b, void *pointer, Int_t version, UInt_t start, UInt_t count);
Int_t ReadBuffer(TBuffer &b, void *pointer);
void ReplaceWith(TClass *newcl, Bool_t recurse = kTRUE) const;
void ResetClassInfo(Long_t tagnum);
void ResetInstanceCount() { fInstanceCount = fOnHeap = 0; }
void ResetMenuList();
Int_t Size() const;
void SetCanSplit(Int_t splitmode);
void SetCollectionProxy(const ROOT::TCollectionProxyInfo&);
void SetContextMenuTitle(const char *title);
void SetCurrentStreamerInfo(TVirtualStreamerInfo *info);
void SetGlobalIsA(IsAGlobalFunc_t);
void SetDeclFile(const char *name, int line) { fDeclFileName = name; fDeclFileLine = line; }
void SetDelete(ROOT::DelFunc_t deleteFunc);
void SetDeleteArray(ROOT::DelArrFunc_t deleteArrayFunc);
void SetDirectoryAutoAdd(ROOT::DirAutoAdd_t dirAutoAddFunc);
void SetDestructor(ROOT::DesFunc_t destructorFunc);
void SetImplFileName(const char *implFileName) { fImplFileName = implFileName; }
void SetMerge(ROOT::MergeFunc_t mergeFunc);
void SetResetAfterMerge(ROOT::ResetAfterMergeFunc_t resetFunc);
void SetNew(ROOT::NewFunc_t newFunc);
void SetNewArray(ROOT::NewArrFunc_t newArrayFunc);
TVirtualStreamerInfo *SetStreamerInfo(Int_t version, const char *info="");
void SetUnloaded();
Int_t WriteBuffer(TBuffer &b, void *pointer, const char *info="");
void AdoptReferenceProxy(TVirtualRefProxy* proxy);
void AdoptStreamer(TClassStreamer *strm);
void AdoptMemberStreamer(const char *name, TMemberStreamer *strm);
void SetMemberStreamer(const char *name, MemberStreamerFunc_t strm);
void SetStreamerFunc(ClassStreamerFunc_t strm);
static void AddClass(TClass *cl);
static void RemoveClass(TClass *cl);
static TClass *GetClass(const char *name, Bool_t load = kTRUE, Bool_t silent = kFALSE);
static TClass *GetClass(const type_info &typeinfo, Bool_t load = kTRUE, Bool_t silent = kFALSE);
static VoidFuncPtr_t GetDict (const char *cname);
static VoidFuncPtr_t GetDict (const type_info &info);
static Int_t AutoBrowse(TObject *obj, TBrowser *browser);
static ENewType IsCallingNew();
static TClass *Load(TBuffer &b);
void Store(TBuffer &b) const;
Int_t Browse(void *obj, TBrowser *b) const;
void DeleteArray(void *ary, Bool_t dtorOnly = kFALSE);
void Destructor(void *obj, Bool_t dtorOnly = kFALSE);
void *DynamicCast(const TClass *base, void *obj, Bool_t up = kTRUE);
Bool_t IsFolder(void *obj) const;
inline void Streamer(void *obj, TBuffer &b, const TClass *onfile_class = 0) const
{
(this->*fStreamerImpl)(obj,b,onfile_class);
}
ClassDef(TClass,0)
};
namespace ROOT {
#ifndef R__NO_CLASS_TEMPLATE_SPECIALIZATION
template <typename T> struct IsPointer { enum { kVal = 0 }; };
template <typename T> struct IsPointer<T*> { enum { kVal = 1 }; };
#else
template <typename T> Bool_t IsPointer(const T* ) { return false; };
template <typename T> Bool_t IsPointer(const T** ) { return true; };
#endif
template <typename T> TClass* GetClass( T* ) { return TClass::GetClass(typeid(T)); }
template <typename T> TClass* GetClass(const T* ) { return TClass::GetClass(typeid(T)); }
#ifndef R__NO_CLASS_TEMPLATE_SPECIALIZATION
template <typename T> TClass* GetClass( T** ) { return GetClass((T*)0); }
template <typename T> TClass* GetClass(const T** ) { return GetClass((T*)0); }
template <typename T> TClass* GetClass( T* const* ) { return GetClass((T*)0); }
template <typename T> TClass* GetClass(const T* const* ) { return GetClass((T*)0); }
#endif
extern TClass *CreateClass(const char *cname, Version_t id,
const char *dfil, const char *ifil,
Int_t dl, Int_t il);
}
#endif // ROOT_TClass