00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "TFriendProxyDescriptor.h"
00024 #include "TBranchProxyDescriptor.h"
00025 #include "TList.h"
00026
00027 ClassImp(ROOT::TFriendProxyDescriptor);
00028
00029 namespace ROOT {
00030
00031 TFriendProxyDescriptor::TFriendProxyDescriptor(const char *treename,
00032 const char *aliasname,
00033 Int_t index) :
00034 TNamed(treename,aliasname),
00035 fDuplicate(kFALSE),
00036 fIndex(index)
00037 {
00038
00039 }
00040
00041 Bool_t TFriendProxyDescriptor::IsEquivalent(const TFriendProxyDescriptor *other)
00042 {
00043
00044
00045
00046 if ( !other ) return kFALSE;
00047 if ( strcmp(GetName(),other->GetName()) ) return kFALSE;
00048
00049 TBranchProxyDescriptor *desc;
00050 TBranchProxyDescriptor *othdesc;
00051
00052 if ( fListOfTopProxies.GetSize() != other->fListOfTopProxies.GetSize() ) return kFALSE;
00053 TIter next(&fListOfTopProxies);
00054 TIter othnext(&other->fListOfTopProxies);
00055 while ( (desc=(TBranchProxyDescriptor*)next()) ) {
00056 othdesc=(TBranchProxyDescriptor*)othnext();
00057 if (!desc->IsEquivalent(othdesc) ) return kFALSE;
00058 }
00059 return kTRUE;
00060 }
00061
00062 void TFriendProxyDescriptor::OutputClassDecl(FILE *hf, int offset, UInt_t maxVarname)
00063 {
00064
00065
00066 fprintf(hf,"%-*sstruct TFriendPx_%s : public TFriendProxy {\n", offset," ", GetName() );
00067 fprintf(hf,"%-*s TFriendPx_%s(TBranchProxyDirector *director,TTree *tree,Int_t index) :\n",
00068 offset," ", GetName() );
00069 fprintf(hf,"%-*s %-*s(director,tree,index)",offset," ",maxVarname,"TFriendProxy");
00070 TBranchProxyDescriptor *data;
00071 TIter next = &fListOfTopProxies;
00072 while ( (data = (TBranchProxyDescriptor*)next()) ) {
00073 fprintf(hf,",\n%-*s %-*s(&fDirector,\"%s\")",
00074 offset," ",maxVarname, data->GetDataName(), data->GetBranchName());
00075 }
00076 fprintf(hf,"\n%-*s { }\n",offset," ");
00077
00078 fprintf(hf, "\n%-*s // Proxy for each of the branches and leaves of the tree\n",offset," ");
00079 next.Reset();
00080 while ( (data = (TBranchProxyDescriptor*)next()) ) {
00081 data->OutputDecl(hf, offset+3, maxVarname);
00082 }
00083 fprintf(hf,"%-*s};\n",offset," ");
00084 }
00085
00086 void TFriendProxyDescriptor::OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
00087 {
00088
00089
00090 TString typeName = "TFriendPx_";
00091 typeName += GetName();
00092 fprintf(hf,"%-*s%-*s %s;\n",
00093 offset," ",maxVarname,typeName.Data(),GetTitle());
00094 }
00095
00096 }