TFriendProxyDescriptor.cxx

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TFriendProxyDescriptor.cxx 21547 2007-12-20 18:19:50Z pcanal $
00002 // Author: Philippe Canal  13/05/2003
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun, Fons Rademakers and al.           *
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 // TFriendProxyDescriptor                                               //
00015 //                                                                      //
00016 // Hold the processed information about a Friend TTree while            //
00017 // TTreeProxyGenerator is parsing the TTree information.                //
00018 // Also contains the routine use to generate the appropriate code       //
00019 // fragment in the result of MakeProxy.                                 //
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       // Constructor
00039    }
00040 
00041    Bool_t TFriendProxyDescriptor::IsEquivalent(const TFriendProxyDescriptor *other)
00042    {
00043       // Return true if this descriptor and the other are equivalent (describe the
00044       // same entity).
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       // Print the declaration needed for this descriptor.
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       // Print the declaration needed for this descriptor.
00089 
00090       TString typeName = "TFriendPx_";
00091       typeName += GetName();
00092       fprintf(hf,"%-*s%-*s %s;\n",
00093               offset," ",maxVarname,typeName.Data(),GetTitle());
00094    }
00095 
00096 }

Generated on Tue Jul 5 15:43:00 2011 for ROOT_528-00b_version by  doxygen 1.5.1