00001 // @(#)root/meta:$Id: TGlobal.cxx 26610 2008-12-02 22:13:09Z pcanal $ 00002 // Author: Rene Brun 13/11/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 ////////////////////////////////////////////////////////////////////////// 00013 // // 00014 // Global variables class (global variables are obtained from CINT). // 00015 // This class describes the attributes of a global variable. // 00016 // The TROOT class contains a list of all currently defined global // 00017 // variables (accessible via TROOT::GetListOfGlobals()). // 00018 // // 00019 ////////////////////////////////////////////////////////////////////////// 00020 00021 #include "TGlobal.h" 00022 #include "TInterpreter.h" 00023 00024 00025 ClassImp(TGlobal) 00026 00027 //______________________________________________________________________________ 00028 TGlobal::TGlobal(DataMemberInfo_t *info) : TDictionary(), fInfo(info) 00029 { 00030 // Default TGlobal ctor. TGlobals are constructed in TROOT via 00031 // a call to TCint::UpdateListOfGlobals(). 00032 00033 if (fInfo) { 00034 SetName(gCint->DataMemberInfo_Name(fInfo)); 00035 SetTitle(gCint->DataMemberInfo_Title(fInfo)); 00036 } 00037 } 00038 00039 //______________________________________________________________________________ 00040 TGlobal::TGlobal(const TGlobal &rhs) : TDictionary( ), fInfo(0) 00041 { 00042 // Copy constructor 00043 00044 if (rhs.fInfo) { 00045 fInfo = gCint->DataMemberInfo_FactoryCopy(rhs.fInfo); 00046 SetName(gCint->DataMemberInfo_Name(fInfo)); 00047 SetTitle(gCint->DataMemberInfo_Title(fInfo)); 00048 } 00049 } 00050 00051 //______________________________________________________________________________ 00052 TGlobal &TGlobal::operator=(const TGlobal &rhs) 00053 { 00054 // Assignment operator. 00055 00056 gCint->DataMemberInfo_Delete(fInfo); 00057 if (rhs.fInfo) { 00058 fInfo = gCint->DataMemberInfo_FactoryCopy(rhs.fInfo); 00059 SetName(gCint->DataMemberInfo_Name(fInfo)); 00060 SetTitle(gCint->DataMemberInfo_Title(fInfo)); 00061 } 00062 return *this; 00063 } 00064 00065 //______________________________________________________________________________ 00066 TGlobal::~TGlobal() 00067 { 00068 // TGlobal dtor deletes adopted CINT DataMemberInfo object. 00069 00070 gCint->DataMemberInfo_Delete(fInfo); 00071 } 00072 00073 //______________________________________________________________________________ 00074 void *TGlobal::GetAddress() const 00075 { 00076 // Return address of global. 00077 00078 return (void *)gCint->DataMemberInfo_Offset(fInfo); 00079 } 00080 00081 //______________________________________________________________________________ 00082 Int_t TGlobal::GetArrayDim() const 00083 { 00084 // Return number of array dimensions. 00085 00086 if (!fInfo) return 0; 00087 return gCint->DataMemberInfo_ArrayDim(fInfo); 00088 } 00089 00090 //______________________________________________________________________________ 00091 Int_t TGlobal::GetMaxIndex(Int_t dim) const 00092 { 00093 // Return maximum index for array dimension "dim". 00094 00095 if (!fInfo) return 0; 00096 return gCint->DataMemberInfo_MaxIndex(fInfo,dim); 00097 } 00098 00099 //______________________________________________________________________________ 00100 const char *TGlobal::GetTypeName() const 00101 { 00102 // Get type of global variable, e,g.: "class TDirectory*" -> "TDirectory". 00103 // Result needs to be used or copied immediately. 00104 00105 if (!fInfo) return 0; 00106 return gCint->TypeName(gCint->DataMemberInfo_TypeName(fInfo)); 00107 } 00108 00109 //______________________________________________________________________________ 00110 const char *TGlobal::GetFullTypeName() const 00111 { 00112 // Get full type description of global variable, e,g.: "class TDirectory*". 00113 00114 if (!fInfo) return 0; 00115 return gCint->DataMemberInfo_TypeName(fInfo); 00116 } 00117 00118 //______________________________________________________________________________ 00119 Long_t TGlobal::Property() const 00120 { 00121 // Get property description word. For meaning of bits see EProperty. 00122 00123 if (!fInfo) return 0; 00124 return gCint->DataMemberInfo_Property(fInfo); 00125 }