#include "TClass.h"
#include "TError.h"
#include "TInterpreter.h"
#include "TIsAProxy.h"
#include <map>
namespace {
struct DynamicType {
virtual ~DynamicType() {}
};
}
typedef std::map<long, TClass*> ClassMap_t;
inline ClassMap_t *GetMap(void* p)
{
return (ClassMap_t*)p;
}
TIsAProxy::TIsAProxy(const std::type_info& typ, void* ctxt)
: fType(&typ), fLastType(&typ), fClass(0), fLastClass(0),
fVirtual(false), fContext(ctxt), fInit(false)
{
::new(fSubTypes) ClassMap_t();
if ( sizeof(ClassMap_t) > sizeof(fSubTypes) ) {
Fatal("TIsAProxy::TIsAProxy",
"Classmap size is badly adjusted: it needs %d instead of %d bytes.",
sizeof(ClassMap_t), sizeof(fSubTypes));
}
}
TIsAProxy::TIsAProxy(const TIsAProxy& iap) :
TVirtualIsAProxy(iap),
fType(iap.fType),
fLastType(iap.fLastType),
fClass(iap.fClass),
fLastClass(iap.fLastClass),
fVirtual(iap.fVirtual),
fContext(iap.fContext),
fInit(iap.fInit)
{
for(Int_t i=0; i<72; i++) fSubTypes[i]=iap.fSubTypes[i];
}
TIsAProxy& TIsAProxy::operator=(const TIsAProxy& iap)
{
if(this!=&iap) {
TVirtualIsAProxy::operator=(iap);
fType=iap.fType;
fLastType=iap.fLastType;
fClass=iap.fClass;
fLastClass=iap.fLastClass;
for(Int_t i=0; i<72; i++) fSubTypes[i]=iap.fSubTypes[i];
fVirtual=iap.fVirtual;
fContext=iap.fContext;
fInit=iap.fInit;
}
return *this;
}
TIsAProxy::~TIsAProxy()
{
ClassMap_t* m = GetMap(fSubTypes);
m->clear();
m->~ClassMap_t();
}
void TIsAProxy::SetClass(TClass *cl)
{
GetMap(fSubTypes)->clear();
fClass = fLastClass = cl;
}
TClass* TIsAProxy::operator()(const void *obj)
{
if ( !fInit ) {
fInit = kTRUE;
if ( !fClass && fType ) fClass = TClass::GetClass(*fType);
fClass->Property();
if ( fClass->GetClassInfo() ) {
fVirtual = (gCint->ClassInfo_ClassProperty(fClass->GetClassInfo())&G__CLS_HASVIRTUAL) == G__CLS_HASVIRTUAL;
}
}
if ( !obj || !fVirtual ) {
return fClass;
} else {
Long_t offset = **(Long_t**)obj;
if ( offset == 0 ) return fClass;
DynamicType* ptr = (DynamicType*)obj;
const std::type_info* typ = &typeid(*ptr);
if ( typ == fType ) {
return fClass;
}
else if ( typ == fLastType ) {
return fLastClass;
}
else if ( 0 != (fLastClass=(*GetMap(fSubTypes))[long(typ)]) ) {
fLastType = typ;
}
else {
fLastClass = TClass::GetClass(*typ);
fLastType = typ;
(*GetMap(fSubTypes))[long(fLastType)] = fLastClass;
}
}
return fLastClass;
}
Last change: Wed Jun 25 08:47:43 2008
Last generated: 2008-06-25 08:47
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.