#include "TBaseClass.h"
#include "TClass.h"
#include "TInterpreter.h"
#include <limits.h>
#include "TVirtualMutex.h"
ClassImp(TBaseClass)
TBaseClass::TBaseClass(BaseClassInfo_t *info, TClass *cl) :
TDictionary(), fInfo(info), fClass(cl), fDelta(INT_MAX),
fProperty(-1), fSTLType(-1)
{
if (fInfo) SetName(gCling->BaseClassInfo_FullName(fInfo));
}
TBaseClass::~TBaseClass()
{
gCling->BaseClassInfo_Delete(fInfo);
}
void TBaseClass::Browse(TBrowser *b)
{
TClass *c = GetClassPointer();
if (c) c->Browse(b);
}
TClass *TBaseClass::GetClassPointer(Bool_t load)
{
if (!fClassPtr) {
if (fInfo) fClassPtr = TClass::GetClass(gCling->BaseClassInfo_ClassInfo(fInfo),load);
else fClassPtr = TClass::GetClass(fName, load);
}
return fClassPtr;
}
Int_t TBaseClass::GetDelta()
{
if (fDelta == INT_MAX) {
R__LOCKGUARD(gInterpreterMutex);
if (Property() & kIsVirtualBase)
fDelta = -1;
else if (fInfo)
fDelta = (Int_t)gCling->BaseClassInfo_Offset(fInfo);
}
return fDelta;
}
const char *TBaseClass::GetTitle() const
{
TClass *c = ((TBaseClass *)this)->GetClassPointer();
return c ? c->GetTitle() : "";
}
ROOT::ESTLType TBaseClass::IsSTLContainer()
{
if (fSTLType < 0) {
if (!fInfo) {
fSTLType = -2;
} else {
const char *type = gCling->BaseClassInfo_TmpltName(fInfo);
if (!type) fSTLType = ROOT::kNotSTL;
else if (!strcmp(type, "vector")) fSTLType = ROOT::kSTLvector;
else if (!strcmp(type, "list")) fSTLType = ROOT::kSTLlist;
else if (!strcmp(type, "forward_list")) fSTLType = ROOT::kSTLforwardlist;
else if (!strcmp(type, "deque")) fSTLType = ROOT::kSTLdeque;
else if (!strcmp(type, "map")) fSTLType = ROOT::kSTLmap;
else if (!strcmp(type, "multimap")) fSTLType = ROOT::kSTLmultimap;
else if (!strcmp(type, "set")) fSTLType = ROOT::kSTLset;
else if (!strcmp(type, "multiset")) fSTLType = ROOT::kSTLmultiset;
else if (!strcmp(type, "unordered_set")) fSTLType = ROOT::kSTLunorderedset;
else if (!strcmp(type, "unordered_multiset")) fSTLType = ROOT::kSTLunorderedmultiset;
else if (!strcmp(type, "unordered_map")) fSTLType = ROOT::kSTLunorderedmap;
else if (!strcmp(type, "unordered_multimap")) fSTLType = ROOT::kSTLunorderedmultimap;
else fSTLType = ROOT::kNotSTL;
}
}
if (fSTLType == -2) return ROOT::kNotSTL;
return (ROOT::ESTLType) fSTLType;
}
Long_t TBaseClass::Property() const
{
if (fProperty == -1 && fInfo) {
R__LOCKGUARD(gInterpreterMutex);
fProperty = gCling->BaseClassInfo_Property(fInfo);
}
return fProperty;
}
void TBaseClass::Streamer(TBuffer& b) {
if (b.IsReading()) {
b.ReadClassBuffer(Class(), this);
} else {
GetDelta();
Property();
IsSTLContainer();
b.WriteClassBuffer(Class(), this);
}
}