00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "TBranchProxyDescriptor.h"
00024
00025 #include "TClonesArray.h"
00026 #include "TError.h"
00027 #include "TROOT.h"
00028
00029 #include "TTreeFormula.h"
00030 #include "TFormLeafInfo.h"
00031 #include <ctype.h>
00032
00033 ClassImp(ROOT::TBranchProxyDescriptor);
00034
00035 namespace ROOT {
00036
00037 TBranchProxyDescriptor::TBranchProxyDescriptor(const char *dataname,
00038 const char *type,
00039 const char *branchname,
00040 Bool_t split,
00041 Bool_t skipped,
00042 Bool_t isleaflist) :
00043 TNamed(dataname,type),fBranchName(branchname),fIsSplit(split),fBranchIsSkipped(skipped),fIsLeafList(isleaflist)
00044 {
00045
00046
00047 fDataName = GetName();
00048 if (fDataName.Length() && fDataName[fDataName.Length()-1]=='.') fDataName.Remove(fDataName.Length()-1);
00049
00050 fDataName.ReplaceAll(".","_");
00051 fDataName.ReplaceAll(":","_");
00052 fDataName.ReplaceAll("<","_");
00053 fDataName.ReplaceAll(">","_");
00054 if (!isalpha(fDataName[0])) fDataName.Insert(0,"_");
00055 fDataName.ReplaceAll(" ","");
00056 fDataName.ReplaceAll("*","st");
00057 fDataName.ReplaceAll("&","rf");
00058
00059 }
00060
00061 const char *TBranchProxyDescriptor::GetDataName()
00062 {
00063
00064 return fDataName;
00065 }
00066
00067 const char *TBranchProxyDescriptor::GetTypeName()
00068 {
00069
00070 return GetTitle();
00071 }
00072
00073 const char *TBranchProxyDescriptor::GetBranchName()
00074 {
00075
00076 return fBranchName.Data();
00077 }
00078
00079 Bool_t TBranchProxyDescriptor::IsEquivalent(const TBranchProxyDescriptor *other,
00080 Bool_t inClass)
00081 {
00082
00083
00084 if ( !other ) return false;
00085 if ( other == this ) return true;
00086
00087 if ( inClass ) {
00088
00089
00090 } else {
00091 if ( fBranchName != other->fBranchName ) return false;
00092 }
00093 if ( fIsSplit != other->fIsSplit ) return false;
00094 if ( fBranchIsSkipped != other->fBranchIsSkipped) return false;
00095 if ( strcmp(GetName(),other->GetName()) ) return false;
00096 if ( strcmp(GetTitle(),other->GetTitle()) ) return false;
00097 return true;
00098 }
00099
00100 Bool_t TBranchProxyDescriptor::IsSplit() const
00101 {
00102
00103 return fIsSplit;
00104 }
00105
00106 void TBranchProxyDescriptor::OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
00107 {
00108
00109 fprintf(hf,"%-*s%-*s %s;\n", offset," ", maxVarname, GetTypeName(), GetDataName());
00110 }
00111
00112 void TBranchProxyDescriptor::OutputInit(FILE *hf, int offset,
00113 UInt_t maxVarname,
00114 const char *prefix)
00115 {
00116
00117 if (fIsSplit) {
00118 const char *subbranchname = GetBranchName();
00119 const char *above = "";
00120 if (strncmp(prefix,subbranchname,strlen(prefix))==0
00121 && strcmp(prefix,subbranchname)!=0) {
00122 subbranchname += strlen(prefix)+1;
00123 above = "ffPrefix, ";
00124 }
00125
00126 if (fBranchIsSkipped) {
00127 fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\", %s\"%s\")",
00128 offset," ", maxVarname, GetDataName(), GetDataName(), above, subbranchname);
00129 } else {
00130 if (fIsLeafList) {
00131 if (above[0]=='\0') {
00132 fprintf(hf,"\n%-*s %-*s(director, \"%s\", \"\", \"%s\")",
00133 offset," ", maxVarname, GetDataName(), subbranchname, GetDataName());
00134 } else {
00135 fprintf(hf,"\n%-*s %-*s(director, %s\"%s\", \"%s\")",
00136 offset," ", maxVarname, GetDataName(), above, subbranchname, GetDataName());
00137 }
00138 } else {
00139 fprintf(hf,"\n%-*s %-*s(director, %s\"%s\")",
00140 offset," ", maxVarname, GetDataName(), above, subbranchname);
00141 }
00142 }
00143 } else {
00144
00145 fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\")",
00146 offset," ", maxVarname, GetDataName(), GetBranchName() );
00147
00148
00149
00150
00151 }
00152 }
00153 }