#include "TROOT.h"
#include "TStreamerElement.h"
#include "TVirtualStreamerInfo.h"
#include "TClass.h"
#include "TClassEdit.h"
#include "TBaseClass.h"
#include "TDataMember.h"
#include "TDataType.h"
#include "TMethodCall.h"
#include "TRealData.h"
#include "TFolder.h"
#include "TRef.h"
#include "TInterpreter.h"
#include "TError.h"
#include "TDataType.h"
#include <iostream>
#include <string>
namespace std {} using namespace std;
const Int_t kMaxLen = 1024;
static char gIncludeName[kMaxLen];
static TStreamerBasicType *InitCounter(const char *countClass, const char *countName)
{
TClass *cl = TClass::GetClass(countClass);
if (cl==0) return 0;
TStreamerBasicType *counter = TVirtualStreamerInfo::GetElementCounter(countName,cl);
if (counter) {
if (counter->GetType() < TVirtualStreamerInfo::kCounter) counter->SetType(TVirtualStreamerInfo::kCounter);
}
return counter;
}
static void GetRange(const char *comments, Double_t &xmin, Double_t &xmax, Double_t &factor)
{
const Double_t kPi =3.14159265358979323846 ;
factor = xmin = xmax = 0;
if (!comments) return;
const char *left = strstr(comments,"[");
if (!left) return;
const char *right = strstr(left,"]");
if (!right) return;
const char *comma = strstr(left,",");
if (!comma || comma > right) {
left = strstr(right,"[");
if (!left) return;
right = strstr(left,"]");
if (!right) return;
comma = strstr(left,",");
if (!comma || comma >right) return;
}
const char *comma2 = 0;
if (comma) comma2 = strstr(comma+1,",");
if (comma2 > right) comma2 = 0;
Int_t nbits = 32;
if (comma2) {
TString sbits(comma2+1,right-comma2-1);
sscanf(sbits.Data(),"%d",&nbits);
if (nbits < 2 || nbits > 32) {
::Error("GetRange","Illegal specification for the number of bits; %d. reset to 32.",nbits);
nbits = 32;
}
right = comma2;
}
TString range(left+1,right-left-1);
TString sxmin(left+1,comma-left-1);
sxmin.ToLower();
sxmin.ReplaceAll(" ","");
if (sxmin.Contains("pi")) {
if (sxmin.Contains("2pi")) xmin = 2*kPi;
else if (sxmin.Contains("2*pi")) xmin = 2*kPi;
else if (sxmin.Contains("twopi")) xmin = 2*kPi;
else if (sxmin.Contains("pi/2")) xmin = kPi/2;
else if (sxmin.Contains("pi/4")) xmin = kPi/4;
else if (sxmin.Contains("pi")) xmin = kPi;
if (sxmin.Contains("-")) xmin = -xmin;
} else {
sscanf(sxmin.Data(),"%lg",&xmin);
}
TString sxmax(comma+1,right-comma-1);
sxmax.ToLower();
sxmax.ReplaceAll(" ","");
if (sxmax.Contains("pi")) {
if (sxmax.Contains("2pi")) xmax = 2*kPi;
else if (sxmax.Contains("2*pi")) xmax = 2*kPi;
else if (sxmax.Contains("twopi")) xmax = 2*kPi;
else if (sxmax.Contains("pi/2")) xmax = kPi/2;
else if (sxmax.Contains("pi/4")) xmax = kPi/4;
else if (sxmax.Contains("pi")) xmax = kPi;
if (sxmax.Contains("-")) xmax = -xmax;
} else {
sscanf(sxmax.Data(),"%lg",&xmax);
}
UInt_t bigint;
if (nbits < 32) bigint = 1<<nbits;
else bigint = 0xffffffff;
if (xmin < xmax) factor = bigint/(xmax-xmin);
if (xmin >= xmax && nbits <15) xmin = nbits+0.1;
}
ClassImp(TStreamerElement)
TStreamerElement::TStreamerElement()
{
fType = 0;
fSize = 0;
fNewType = 0;
fArrayDim = 0;
fArrayLength = 0;
fStreamer = 0;
fMethod = 0;
fOffset = 0;
fClassObject = (TClass*)(-1);
fNewClass = 0;
fTObjectOffset = 0;
fFactor = 0;
fXmin = 0;
fXmax = 0;
for (Int_t i=0;i<5;i++) fMaxIndex[i] = 0;
}
TStreamerElement::TStreamerElement(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName)
: TNamed(name,title)
{
fOffset = offset;
fType = dtype;
fSize = 0;
fNewType = fType;
fArrayDim = 0;
fArrayLength = 0;
fTypeName = TClassEdit::ResolveTypedef(typeName);
fStreamer = 0;
fMethod = 0;
fClassObject = (TClass*)(-1);
fNewClass = 0;
fTObjectOffset = 0;
fFactor = 0;
fXmin = 0;
fXmax = 0;
for (Int_t i=0;i<5;i++) fMaxIndex[i] = 0;
if (fTypeName == "Float16_t" || fTypeName == "Float16_t*") {
GetRange(title,fXmin,fXmax,fFactor);
if (fFactor > 0 || fXmin > 0) SetBit(kHasRange);
}
if (fTypeName == "Double32_t" || fTypeName == "Double32_t*") {
GetRange(title,fXmin,fXmax,fFactor);
if (fFactor > 0 || fXmin > 0) SetBit(kHasRange);
}
}
TStreamerElement::~TStreamerElement()
{
delete fMethod;
}
Bool_t TStreamerElement::CannotSplit() const
{
if (strspn(GetTitle(),"||") == 2) return kTRUE;
TClass *cl = GetClassPointer();
if (!cl) return kFALSE;
switch(fType) {
case TVirtualStreamerInfo::kAny +TVirtualStreamerInfo::kOffsetL:
case TVirtualStreamerInfo::kObject +TVirtualStreamerInfo::kOffsetL:
case TVirtualStreamerInfo::kTObject+TVirtualStreamerInfo::kOffsetL:
case TVirtualStreamerInfo::kTString+TVirtualStreamerInfo::kOffsetL:
case TVirtualStreamerInfo::kTNamed +TVirtualStreamerInfo::kOffsetL:
return kTRUE;
}
if ( !cl->CanSplit() ) return kTRUE;
return kFALSE;
}
TClass *TStreamerElement::GetClassPointer() const
{
if (fClassObject!=(TClass*)(-1)) return fClassObject;
TString className = fTypeName.Strip(TString::kTrailing, '*');
if (className.Index("const ")==0) className.Remove(0,6);
((TStreamerElement*)this)->fClassObject = TClass::GetClass(className);
return fClassObject;
}
Int_t TStreamerElement::GetExecID() const
{
if (strncmp(fTypeName.Data(),"TRef",4) != 0) return 0;
if (GetUniqueID()) return GetUniqueID();
char *action = (char*)strstr(GetTitle(),"EXEC:");
if (!action) return 0;
char caction[512];
strcpy(caction,action+5);
char *blank = (char*)strchr(caction,' ');
if (blank) *blank = 0;
Int_t index = TRef::AddExec(caction);
((TStreamerElement*)this)->SetUniqueID(index+1);
return index+1;
}
const char *TStreamerElement::GetFullName() const
{
static char name[kMaxLen];
char cdim[20];
sprintf(name,GetName());
for (Int_t i=0;i<fArrayDim;i++) {
sprintf(cdim,"[%d]",fMaxIndex[i]);
strcat(name,cdim);
}
return name;
}
Int_t TStreamerElement::GetSize() const
{
return fSize;
}
TMemberStreamer *TStreamerElement::GetStreamer() const
{
return fStreamer;
}
const char *TStreamerElement::GetTypeNameBasic() const
{
TDataType *dt = gROOT->GetType(fTypeName.Data());
if (fType < 1 || fType > 55) return fTypeName.Data();
if (dt && dt->GetType() > 0) return fTypeName.Data();
Int_t dtype = fType%20;
return TDataType::GetTypeName((EDataType)dtype);
}
void TStreamerElement::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
Bool_t TStreamerElement::IsOldFormat(const char *newTypeName)
{
if (!strstr(newTypeName,fTypeName.Data())) return kFALSE;
fTypeName = newTypeName;
return kTRUE;
}
Bool_t TStreamerElement::IsBase() const
{
return kFALSE;
}
void TStreamerElement::ls(Option_t *) const
{
sprintf(gIncludeName,GetTypeName());
if (IsaPointer() && !fTypeName.Contains("*")) strcat(gIncludeName,"*");
printf(" %-14s %-15s offset=%3d type=%2d %s%-20s\n",gIncludeName,GetFullName(),fOffset,fType,TestBit(kCache)?"(cached) ":"",GetTitle());
}
void TStreamerElement::SetArrayDim(Int_t dim)
{
fArrayDim = dim;
if (dim) fType += TVirtualStreamerInfo::kOffsetL;
fNewType = fType;
}
void TStreamerElement::SetMaxIndex(Int_t dim, Int_t max)
{
if (dim < 0 || dim > 4) return;
fMaxIndex[dim] = max;
if (fArrayLength == 0) fArrayLength = max;
else fArrayLength *= max;
}
void TStreamerElement::SetStreamer(TMemberStreamer *streamer)
{
fStreamer = streamer;
}
void TStreamerElement::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
R__b.ClassBegin(TStreamerElement::Class(), R__v);
R__b.ClassMember("TNamed");
TNamed::Streamer(R__b);
R__b.ClassMember("fType","Int_t");
R__b >> fType;
R__b.ClassMember("fSize","Int_t");
R__b >> fSize;
R__b.ClassMember("fArrayLength","Int_t");
R__b >> fArrayLength;
R__b.ClassMember("fArrayDim","Int_t");
R__b >> fArrayDim;
R__b.ClassMember("fMaxIndex","Int_t", 5);
if (R__v == 1) R__b.ReadStaticArray(fMaxIndex);
else R__b.ReadFastArray(fMaxIndex,5);
R__b.ClassMember("fTypeName","TString");
fTypeName.Streamer(R__b);
if (fType==11&&(fTypeName=="Bool_t"||fTypeName=="bool")) fType = 18;
if (R__v > 1) {
SetUniqueID(0);
GetExecID();
}
if (R__v <= 2 && this->IsA()==TStreamerBasicType::Class()) {
TDataType *type = gROOT->GetType(GetTypeName());
if (type && fArrayLength) fSize = fArrayLength * type->Size();
}
if (R__v == 3) {
R__b >> fXmin;
R__b >> fXmax;
R__b >> fFactor;
if (fFactor > 0) SetBit(kHasRange);
}
if (R__v > 3) {
if (TestBit(kHasRange)) GetRange(GetTitle(),fXmin,fXmax,fFactor);
}
R__b.ClassEnd(TStreamerElement::Class());
R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
} else {
R__b.WriteClassBuffer(TStreamerElement::Class(),this);
}
}
void TStreamerElement::Update(const TClass *oldClass, TClass *newClass)
{
if (fClassObject == oldClass) {
fClassObject = newClass;
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
} else if (fClassObject==0) {
fClassObject = (TClass*)-1;
GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
}
ClassImp(TStreamerBase)
TStreamerBase::TStreamerBase()
{
fBaseClass = (TClass*)(-1);
fBaseVersion = 0;
fNewBaseClass = 0;
}
TStreamerBase::TStreamerBase(const char *name, const char *title, Int_t offset)
: TStreamerElement(name,title,offset,TVirtualStreamerInfo::kBase,"BASE")
{
if (strcmp(name,"TObject") == 0) fType = TVirtualStreamerInfo::kTObject;
if (strcmp(name,"TNamed") == 0) fType = TVirtualStreamerInfo::kTNamed;
fNewType = fType;
fBaseClass = TClass::GetClass(GetName());
fBaseVersion = fBaseClass->GetClassVersion();
fNewBaseClass = 0;
Init();
}
TStreamerBase::~TStreamerBase()
{
}
TClass *TStreamerBase::GetClassPointer() const
{
if (fBaseClass!=(TClass*)(-1)) return fBaseClass;
((TStreamerBase*)this)->fBaseClass = TClass::GetClass(GetName());
return fBaseClass;
}
Int_t TStreamerBase::GetSize() const
{
TClass *cl = GetClassPointer();
if (cl) return cl->Size();
return 0;
}
void TStreamerBase::Init(TObject *)
{
if (fType == TVirtualStreamerInfo::kTObject || fType == TVirtualStreamerInfo::kTNamed) return;
fBaseClass = TClass::GetClass(GetName());
if (!fBaseClass) return;
if (!fBaseClass->GetMethodAny("StreamerNVirtual")) return;
delete fMethod;
fMethod = new TMethodCall();
fMethod->InitWithPrototype(fBaseClass,"StreamerNVirtual","TBuffer &");
}
Bool_t TStreamerBase::IsBase() const
{
return kTRUE;
}
const char *TStreamerBase::GetInclude() const
{
if (GetClassPointer() && fBaseClass->GetClassInfo()) {
sprintf(gIncludeName,"\"%s\"",fBaseClass->GetDeclFileName());
} else {
std::string shortname( TClassEdit::ShortType( GetName(), 1 ) );
sprintf(gIncludeName,"\"%s.h\"",shortname.c_str());
}
return gIncludeName;
}
void TStreamerBase::ls(Option_t *) const
{
printf(" %-14s %-15s offset=%3d type=%2d %s%-20s\n",GetFullName(),GetTypeName(),fOffset,fType,TestBit(kCache)?"(cached) ":"",GetTitle());
}
Int_t TStreamerBase::ReadBuffer (TBuffer &b, char *pointer)
{
if (fMethod) {
ULong_t args[1];
args[0] = (ULong_t)&b;
fMethod->SetParamPtrs(args);
fMethod->Execute((void*)(pointer+fOffset));
} else {
if( fNewBaseClass )
b.ReadClassBuffer( fNewBaseClass, pointer+fOffset, fBaseClass );
else
b.ReadClassBuffer( fBaseClass, pointer+fOffset );
}
return 0;
}
void TStreamerBase::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
R__b.ClassBegin(TStreamerBase::Class(), R__v);
R__b.ClassMember("TStreamerElement");
TStreamerElement::Streamer(R__b);
fBaseClass = (TClass*)-1;
fNewBaseClass = 0;
if (R__v > 2) {
R__b.ClassMember("fBaseVersion","Int_t");
R__b >> fBaseVersion;
} else {
fBaseClass = TClass::GetClass(GetName());
fBaseVersion = fBaseClass->GetClassVersion();
}
R__b.ClassEnd(TStreamerBase::Class());
R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
} else {
R__b.WriteClassBuffer(TStreamerBase::Class(),this);
}
}
void TStreamerBase::Update(const TClass *oldClass, TClass *newClass)
{
if (fClassObject == oldClass) fClassObject = newClass;
else if (fClassObject == 0) {
fClassObject = (TClass*)-1;
GetClassPointer();
}
if (fBaseClass == oldClass) fBaseClass = newClass;
else if (fBaseClass == 0 ) {
fBaseClass = (TClass*)-1;
GetClassPointer();
}
if (fClassObject != (TClass*)-1 &&
fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
Int_t TStreamerBase::WriteBuffer (TBuffer &b, char *pointer)
{
if (!fMethod) {
fBaseClass->WriteBuffer(b,pointer+fOffset);
return 0;
}
ULong_t args[1];
args[0] = (ULong_t)&b;
fMethod->SetParamPtrs(args);
fMethod->Execute((void*)(pointer+fOffset));
b.ForceWriteInfo(fBaseClass->GetStreamerInfo(),kFALSE);
return 0;
}
ClassImp(TStreamerBasicPointer)
TStreamerBasicPointer::TStreamerBasicPointer() : fCounter(0)
{
fCounter = 0;
}
TStreamerBasicPointer::TStreamerBasicPointer(const char *name, const char *title, Int_t offset, Int_t dtype, const char *countName, const char *countClass, Int_t countVersion, const char *typeName)
: TStreamerElement(name,title,offset,dtype,typeName)
{
fType += TVirtualStreamerInfo::kOffsetP;
fCountName = countName;
fCountClass = countClass;
fCountVersion = countVersion;
Init();
}
TStreamerBasicPointer::~TStreamerBasicPointer()
{
}
ULong_t TStreamerBasicPointer::GetMethod() const
{
if (!fCounter) ((TStreamerBasicPointer*)this)->Init();
if (!fCounter) return 0;
return (ULong_t)fCounter->GetOffset();
}
Int_t TStreamerBasicPointer::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(void *);
return sizeof(void *);
}
void TStreamerBasicPointer::Init(TObject *)
{
fCounter = InitCounter( fCountClass, fCountName );
}
void TStreamerBasicPointer::SetArrayDim(Int_t dim)
{
fArrayDim = dim;
fNewType = fType;
}
void TStreamerBasicPointer::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
R__b.ReadClassBuffer(TStreamerBasicPointer::Class(), this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b >> fCountVersion;
fCountName.Streamer(R__b);
fCountClass.Streamer(R__b);
R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
} else {
R__b.WriteClassBuffer(TStreamerBasicPointer::Class(),this);
}
}
ClassImp(TStreamerLoop)
TStreamerLoop::TStreamerLoop() : fCounter(0)
{
fCounter = 0;
}
TStreamerLoop::TStreamerLoop(const char *name, const char *title, Int_t offset, const char *countName, const char *countClass, Int_t countVersion, const char *typeName)
: TStreamerElement(name,title,offset,TVirtualStreamerInfo::kStreamLoop,typeName)
{
fCountName = countName;
fCountClass = countClass;
fCountVersion = countVersion;
Init();
}
TStreamerLoop::~TStreamerLoop()
{
}
ULong_t TStreamerLoop::GetMethod() const
{
if (!fCounter) return 0;
return (ULong_t)fCounter->GetOffset();
}
Int_t TStreamerLoop::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(Int_t);
return sizeof(Int_t);
}
void TStreamerLoop::Init(TObject *)
{
fCounter = InitCounter( fCountClass, fCountName );
}
const char *TStreamerLoop::GetInclude() const
{
sprintf(gIncludeName,"<%s>","TString.h");
return gIncludeName;
}
void TStreamerLoop::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
R__b.ReadClassBuffer(TStreamerLoop::Class(), this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b >> fCountVersion;
fCountName.Streamer(R__b);
fCountClass.Streamer(R__b);
R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
} else {
R__b.WriteClassBuffer(TStreamerLoop::Class(),this);
}
}
ClassImp(TStreamerBasicType)
TStreamerBasicType::TStreamerBasicType()
{
}
TStreamerBasicType::TStreamerBasicType(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName)
: TStreamerElement(name,title,offset,dtype,typeName)
{
}
TStreamerBasicType::~TStreamerBasicType()
{
}
ULong_t TStreamerBasicType::GetMethod() const
{
if (fType == TVirtualStreamerInfo::kCounter ||
fType == (TVirtualStreamerInfo::kCounter+TVirtualStreamerInfo::kSkip)) return (ULong_t)&fCounter;
return 0;
}
Int_t TStreamerBasicType::GetSize() const
{
return fSize;
}
void TStreamerBasicType::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
R__b.ReadClassBuffer(TStreamerBasicType::Class(), this, R__v, R__s, R__c);
} else {
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerBasicType::IsA());
}
switch(fType) {
case kBool_t: fSize = sizeof(bool); break;
case kShort_t: fSize = sizeof(Short_t); break;
case kInt_t: fSize = sizeof(Int_t); break;
case kLong_t: fSize = sizeof(Long_t); break;
case kLong64_t: fSize = sizeof(Long64_t); break;
case kFloat_t: fSize = sizeof(Float_t); break;
case kFloat16_t: fSize = sizeof(Float_t); break;
case kDouble_t: fSize = sizeof(Double_t); break;
case kDouble32_t: fSize = sizeof(Double_t); break;
case kUChar_t: fSize = sizeof(UChar_t); break;
case kUShort_t: fSize = sizeof(UShort_t); break;
case kUInt_t: fSize = sizeof(UInt_t); break;
case kULong_t: fSize = sizeof(ULong_t); break;
case kULong64_t: fSize = sizeof(ULong64_t); break;
case kBits: fSize = sizeof(UInt_t); break;
case kCounter: fSize = sizeof(Int_t); break;
case kChar_t: fSize = sizeof(Char_t); break;
case kCharStar: fSize = sizeof(Char_t*); break;
default: return;
}
if (fArrayLength) fSize *= GetArrayLength();
} else {
R__b.WriteClassBuffer(TStreamerBasicType::Class(),this);
}
}
ClassImp(TStreamerObject)
TStreamerObject::TStreamerObject()
{
}
TStreamerObject::TStreamerObject(const char *name, const char *title, Int_t offset, const char *typeName)
: TStreamerElement(name,title,offset,0,typeName)
{
fType = TVirtualStreamerInfo::kObject;
if (strcmp(typeName,"TObject") == 0) fType = TVirtualStreamerInfo::kTObject;
if (strcmp(typeName,"TNamed") == 0) fType = TVirtualStreamerInfo::kTNamed;
fNewType = fType;
Init();
}
TStreamerObject::~TStreamerObject()
{
}
void TStreamerObject::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
const char *TStreamerObject::GetInclude() const
{
TClass *cl = GetClassPointer();
if (cl && cl->GetClassInfo()) {
sprintf(gIncludeName,"\"%s\"",cl->GetDeclFileName());
} else {
std::string shortname( TClassEdit::ShortType( GetTypeName(), 1 ) );
sprintf(gIncludeName,"\"%s.h\"",shortname.c_str());
}
return gIncludeName;
}
Int_t TStreamerObject::GetSize() const
{
TClass *cl = GetClassPointer();
Int_t classSize = 8;
if (cl) classSize = cl->Size();
if (fArrayLength) return fArrayLength*classSize;
return classSize;
}
void TStreamerObject::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
R__b.ReadClassBuffer(TStreamerObject::Class(), this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerObject::IsA());
} else {
R__b.WriteClassBuffer(TStreamerObject::Class(),this);
}
}
ClassImp(TStreamerObjectAny)
TStreamerObjectAny::TStreamerObjectAny()
{
}
TStreamerObjectAny::TStreamerObjectAny(const char *name, const char *title, Int_t offset, const char *typeName)
: TStreamerElement(name,title,offset,TVirtualStreamerInfo::kAny,typeName)
{
Init();
}
TStreamerObjectAny::~TStreamerObjectAny()
{
}
void TStreamerObjectAny::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
const char *TStreamerObjectAny::GetInclude() const
{
TClass *cl = GetClassPointer();
if (cl && cl->GetClassInfo()) {
sprintf(gIncludeName,"\"%s\"",cl->GetDeclFileName());
} else {
std::string shortname( TClassEdit::ShortType( GetTypeName(), 1 ) );
sprintf(gIncludeName,"\"%s.h\"",shortname.c_str());
}
return gIncludeName;
}
Int_t TStreamerObjectAny::GetSize() const
{
TClass *cl = GetClassPointer();
Int_t classSize = 8;
if (cl) classSize = cl->Size();
if (fArrayLength) return fArrayLength*classSize;
return classSize;
}
void TStreamerObjectAny::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
R__b.ReadClassBuffer(TStreamerObjectAny::Class(), this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerObjectAny::IsA());
} else {
R__b.WriteClassBuffer(TStreamerObjectAny::Class(),this);
}
}
ClassImp(TStreamerObjectPointer)
TStreamerObjectPointer::TStreamerObjectPointer()
{
}
TStreamerObjectPointer::TStreamerObjectPointer(const char *name, const char *title,
Int_t offset, const char *typeName)
: TStreamerElement(name,title,offset,TVirtualStreamerInfo::kObjectP,typeName)
{
if (strncmp(title,"->",2) == 0) fType = TVirtualStreamerInfo::kObjectp;
fNewType = fType;
Init();
}
TStreamerObjectPointer::~TStreamerObjectPointer()
{
}
void TStreamerObjectPointer::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
const char *TStreamerObjectPointer::GetInclude() const
{
TClass *cl = GetClassPointer();
if (cl && cl->GetClassInfo()) {
sprintf(gIncludeName,"\"%s\"",cl->GetDeclFileName());
} else {
std::string shortname( TClassEdit::ShortType( GetTypeName(), 1 ) );
sprintf(gIncludeName,"\"%s.h\"",shortname.c_str());
}
return gIncludeName;
}
Int_t TStreamerObjectPointer::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(void *);
return sizeof(void *);
}
void TStreamerObjectPointer::SetArrayDim(Int_t dim)
{
fArrayDim = dim;
fNewType = fType;
}
void TStreamerObjectPointer::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
R__b.ReadClassBuffer(TStreamerObjectPointer::Class(), this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerObjectPointer::IsA());
} else {
R__b.WriteClassBuffer(TStreamerObjectPointer::Class(),this);
}
}
ClassImp(TStreamerObjectAnyPointer)
TStreamerObjectAnyPointer::TStreamerObjectAnyPointer()
{
}
TStreamerObjectAnyPointer::TStreamerObjectAnyPointer(const char *name, const char *title,
Int_t offset, const char *typeName)
: TStreamerElement(name,title,offset,TVirtualStreamerInfo::kAnyP,typeName)
{
if (strncmp(title,"->",2) == 0) fType = TVirtualStreamerInfo::kAnyp;
fNewType = fType;
Init();
}
TStreamerObjectAnyPointer::~TStreamerObjectAnyPointer()
{
}
void TStreamerObjectAnyPointer::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
const char *TStreamerObjectAnyPointer::GetInclude() const
{
TClass *cl = GetClassPointer();
if (cl && cl->GetClassInfo()) {
sprintf(gIncludeName,"\"%s\"",cl->GetDeclFileName());
} else {
std::string shortname( TClassEdit::ShortType( GetTypeName(), 1 ) );
sprintf(gIncludeName,"\"%s.h\"",shortname.c_str());
}
return gIncludeName;
}
Int_t TStreamerObjectAnyPointer::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(void *);
return sizeof(void *);
}
void TStreamerObjectAnyPointer::SetArrayDim(Int_t dim)
{
fArrayDim = dim;
fNewType = fType;
}
void TStreamerObjectAnyPointer::Streamer(TBuffer &R__b)
{
if (R__b.IsReading()) {
R__b.ReadClassBuffer(TStreamerObjectAnyPointer::Class(), this);
} else {
R__b.WriteClassBuffer(TStreamerObjectAnyPointer::Class(),this);
}
}
ClassImp(TStreamerString)
TStreamerString::TStreamerString()
{
}
TStreamerString::TStreamerString(const char *name, const char *title, Int_t offset)
: TStreamerElement(name,title,offset,TVirtualStreamerInfo::kTString,"TString")
{
}
TStreamerString::~TStreamerString()
{
}
Int_t TStreamerString::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(TString);
return sizeof(TString);
}
void TStreamerString::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
R__b.ReadClassBuffer(TStreamerString::Class(), this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerString::IsA());
} else {
R__b.WriteClassBuffer(TStreamerString::Class(),this);
}
}
ClassImp(TStreamerSTL)
TStreamerSTL::TStreamerSTL()
{
}
TStreamerSTL::TStreamerSTL(const char *name, const char *title, Int_t offset,
const char *typeName, const char *trueType, Bool_t dmPointer)
: TStreamerElement(name,title,offset,kSTL,typeName)
{
const char *t = trueType;
if (!t || !*t) t = typeName;
fTypeName = TClassEdit::ShortType(fTypeName,TClassEdit::kDropStlDefault).c_str();
if (name==typeName
|| strcmp(name,typeName)==0) {
fName = fTypeName;
}
Int_t nch = strlen(t);
char *s = new char[nch+1];
strcpy(s,t);
char *sopen = strchr(s,'<'); *sopen = 0; sopen++;
char* current=sopen;
for(int count = 0; *current!='\0'; current++) {
if (*current=='<') count++;
if (*current=='>') {
if (count==0) break;
count--;
}
if (*current==',' && count==0) break;
}
char *sclose = current; *sclose = 0; sclose--;
char *sconst = strstr(sopen,"const ");
char *sbracket = strstr(sopen,"<");
if (sconst && (sbracket==0 || sconst < sbracket)) {
char *pconst = sconst-1;
if (*pconst == ' ' || *pconst == '<' || *pconst == '*' || *pconst == '\0') sopen = sconst + 5;
}
fSTLtype = 0;
fCtype = 0;
if (strstr(s,"vector")) fSTLtype = kSTLvector;
else if (strstr(s,"list")) fSTLtype = kSTLlist;
else if (strstr(s,"deque")) fSTLtype = kSTLdeque;
else if (strstr(s,"map")) fSTLtype = kSTLmap;
else if (strstr(s,"set")) fSTLtype = kSTLset;
else if (strstr(s,"multimap")) fSTLtype = kSTLmultimap;
else if (strstr(s,"multiset")) fSTLtype = kSTLmultiset;
if (fSTLtype == 0) { delete [] s; return;}
if (dmPointer) fSTLtype += TVirtualStreamerInfo::kOffsetP;
while (*sopen==' ') sopen++;
Bool_t isPointer = kFALSE;
char *star = strrchr(sopen,'>');
if (star) star = strchr(star,'*');
else star = strchr(sopen,'*');
if (star) {
isPointer = kTRUE;
*star = 0;
sclose = star - 1;
}
while (*sclose == ' ') {*sclose = 0; sclose--;}
TDataType *dt = (TDataType*)gROOT->GetListOfTypes()->FindObject(sopen);
if (dt) {
fCtype = dt->GetType();
if (isPointer) fCtype += TVirtualStreamerInfo::kOffsetP;
} else {
TClass *cl = TClass::GetClass(sopen);
if (cl) {
if (isPointer) fCtype = TVirtualStreamerInfo::kObjectp;
else fCtype = TVirtualStreamerInfo::kObject;
} else {
if (gCint->ClassInfo_IsEnum(sopen)) {
if (isPointer) fCtype += TVirtualStreamerInfo::kOffsetP;
} else {
if(strcmp(sopen,"string")) {
if (GetClassPointer() && GetClassPointer()->IsLoaded()) {
Warning("TStreamerSTL","For %s we could not find any information about the type %s",fTypeName.Data(),sopen);
}
}
}
}
}
delete [] s;
if (TStreamerSTL::IsaPointer()) fType = TVirtualStreamerInfo::kSTLp;
}
TStreamerSTL::~TStreamerSTL()
{
}
Bool_t TStreamerSTL::CannotSplit() const
{
if (IsaPointer()) {
if (GetTitle()[0]=='[') return kTRUE;
return kTRUE;
}
if (GetArrayDim()>=1 && GetArrayLength()>1) return kTRUE;
if (TStreamerElement::CannotSplit()) return kTRUE;
return kFALSE;
}
Bool_t TStreamerSTL::IsaPointer() const
{
const char *type_name = GetTypeName();
if ( type_name[strlen(type_name)-1]=='*' ) return kTRUE;
else return kFALSE;
}
Bool_t TStreamerSTL::IsBase() const
{
TString ts(GetName());
if (strcmp(ts.Data(),GetTypeName())==0) return kTRUE;
if (strcmp(ts.Data(),GetTypeNameBasic())==0) return kTRUE;
return kFALSE;
}
Int_t TStreamerSTL::GetSize() const
{
UInt_t size = GetClassPointer()->Size();
if (fArrayLength) return fArrayLength*size;
return size;
}
void TStreamerSTL::ls(Option_t *) const
{
char name[kMaxLen];
char cdim[20];
sprintf(name,GetName());
for (Int_t i=0;i<fArrayDim;i++) {
sprintf(cdim,"[%d]",fMaxIndex[i]);
strcat(name,cdim);
}
printf(" %-14s %-15s offset=%3d type=%2d %s,stl=%d, ctype=%d, %-20s",GetTypeName(),name,fOffset,fType,TestBit(kCache)?"(cached)":"",fSTLtype,fCtype,GetTitle());
printf("\n");
}
const char *TStreamerSTL::GetInclude() const
{
if (fSTLtype == kSTLvector) sprintf(gIncludeName,"<%s>","vector");
else if (fSTLtype == kSTLlist) sprintf(gIncludeName,"<%s>","list");
else if (fSTLtype == kSTLdeque) sprintf(gIncludeName,"<%s>","deque");
else if (fSTLtype == kSTLmap) sprintf(gIncludeName,"<%s>","map");
else if (fSTLtype == kSTLset) sprintf(gIncludeName,"<%s>","set");
else if (fSTLtype == kSTLmultimap) sprintf(gIncludeName,"<%s>","multimap");
else if (fSTLtype == kSTLmultiset) sprintf(gIncludeName,"<%s>","multiset");
return gIncludeName;
}
void TStreamerSTL::SetStreamer(TMemberStreamer *streamer)
{
fStreamer = streamer;
}
void TStreamerSTL::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 2) {
R__b.ReadClassBuffer(TStreamerSTL::Class(), this, R__v, R__s, R__c);
} else {
TStreamerElement::Streamer(R__b);
R__b >> fSTLtype;
R__b >> fCtype;
R__b.CheckByteCount(R__s, R__c, TStreamerSTL::IsA());
}
if (IsaPointer()) fType = TVirtualStreamerInfo::kSTLp;
else fType = TVirtualStreamerInfo::kSTL;
return;
} else {
Int_t tmp = fType;
fType = TVirtualStreamerInfo::kStreamer;
R__b.WriteClassBuffer(TStreamerSTL::Class(),this);
fType = tmp;
}
}
ClassImp(TStreamerSTLstring)
TStreamerSTLstring::TStreamerSTLstring()
{
}
TStreamerSTLstring::TStreamerSTLstring(const char *name, const char *title, Int_t offset,
const char *typeName, Bool_t dmPointer)
: TStreamerSTL()
{
SetName(name);
SetTitle(title);
if (dmPointer) {
fType = TVirtualStreamerInfo::kSTLp;
} else {
fType = TVirtualStreamerInfo::kSTL;
}
fNewType = fType;
fOffset = offset;
fSTLtype = kSTLstring;
fCtype = kSTLstring;
fTypeName= typeName;
}
TStreamerSTLstring::~TStreamerSTLstring()
{
}
const char *TStreamerSTLstring::GetInclude() const
{
sprintf(gIncludeName,"<string>");
return gIncludeName;
}
Int_t TStreamerSTLstring::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(string);
return sizeof(string);
}
void TStreamerSTLstring::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
R__b.ReadClassBuffer(TStreamerSTLstring::Class(), this, R__v, R__s, R__c);
return;
}
TStreamerSTL::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerSTLstring::IsA());
} else {
R__b.WriteClassBuffer(TStreamerSTLstring::Class(),this);
}
}
ClassImp(TStreamerSTLstring);
void TStreamerArtificial::Streamer(TBuffer& )
{
return;
}
ROOT::TSchemaRule::ReadFuncPtr_t TStreamerArtificial::GetReadFunc()
{
return fReadFunc;
}
ROOT::TSchemaRule::ReadRawFuncPtr_t TStreamerArtificial::GetReadRawFunc()
{
return fReadRawFunc;
}
Last change: Wed Dec 3 08:49:30 2008
Last generated: 2008-12-03 08:49
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.