00001 // @(#)root/meta:$Id: TBaseClass.cxx 34924 2010-08-21 05:39:09Z pcanal $ 00002 // Author: Fons Rademakers 08/02/95 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #include "TBaseClass.h" 00013 #include "TClass.h" 00014 #include "TInterpreter.h" 00015 00016 ////////////////////////////////////////////////////////////////////////// 00017 // // 00018 // Each class (see TClass) has a linked list of its base class(es). // 00019 // This class describes one single base class. // 00020 // The base class info is obtained via the CINT api. // 00021 // see class TCint. // 00022 // // 00023 // The base class information is used a.o. in to find all inherited // 00024 // methods. // 00025 // // 00026 ////////////////////////////////////////////////////////////////////////// 00027 00028 00029 ClassImp(TBaseClass) 00030 00031 //______________________________________________________________________________ 00032 TBaseClass::TBaseClass(BaseClassInfo_t *info, TClass *cl) : TDictionary() 00033 { 00034 // Default TBaseClass ctor. TBaseClasses are constructed in TClass 00035 // via a call to TCint::CreateListOfBaseClasses(). 00036 00037 fInfo = info; 00038 fClass = cl; 00039 fClassPtr = 0; 00040 if (fInfo) SetName(gCint->BaseClassInfo_FullName(fInfo)); 00041 } 00042 00043 //______________________________________________________________________________ 00044 TBaseClass::~TBaseClass() 00045 { 00046 // TBaseClass dtor deletes adopted CINT BaseClassInfo object. 00047 00048 gCint->BaseClassInfo_Delete(fInfo); 00049 } 00050 00051 //______________________________________________________________________________ 00052 void TBaseClass::Browse(TBrowser *b) 00053 { 00054 // Called by the browser, to browse a baseclass. 00055 00056 TClass *c = GetClassPointer(); 00057 if (c) c->Browse(b); 00058 } 00059 00060 //______________________________________________________________________________ 00061 TClass *TBaseClass::GetClassPointer(Bool_t load) 00062 { 00063 // Get pointer to the base class TClass. 00064 00065 if (!fClassPtr) fClassPtr = TClass::GetClass(fName, load); 00066 return fClassPtr; 00067 } 00068 00069 //______________________________________________________________________________ 00070 Int_t TBaseClass::GetDelta() const 00071 { 00072 // Get offset from "this" to part of base class. 00073 00074 return (Int_t)gCint->BaseClassInfo_Offset(fInfo); 00075 } 00076 00077 //______________________________________________________________________________ 00078 const char *TBaseClass::GetTitle() const 00079 { 00080 // Get base class description (comment). 00081 00082 TClass *c = ((TBaseClass *)this)->GetClassPointer(); 00083 return c ? c->GetTitle() : ""; 00084 } 00085 00086 //______________________________________________________________________________ 00087 int TBaseClass::IsSTLContainer() 00088 { 00089 // Return which type (if any) of STL container the data member is. 00090 00091 if (!fInfo) return kNone; 00092 const char *type = gCint->BaseClassInfo_TmpltName(fInfo); 00093 if (!type) return kNone; 00094 00095 if (!strcmp(type, "vector")) return kVector; 00096 if (!strcmp(type, "list")) return kList; 00097 if (!strcmp(type, "deque")) return kDeque; 00098 if (!strcmp(type, "map")) return kMap; 00099 if (!strcmp(type, "multimap")) return kMultimap; 00100 if (!strcmp(type, "set")) return kSet; 00101 if (!strcmp(type, "multiset")) return kMultiset; 00102 return kNone; 00103 } 00104 00105 //______________________________________________________________________________ 00106 Long_t TBaseClass::Property() const 00107 { 00108 // Get property description word. For meaning of bits see EProperty. 00109 00110 return gCint->BaseClassInfo_Property(fInfo); 00111 }