Logo ROOT   6.08/07
Reference Guide
TFriendProxyDescriptor.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Philippe Canal 13/05/2003
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun, Fons Rademakers and al. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \classTFriendProxyDescriptor
13 Hold the processed information about a Friend TTree while
14 TTreeProxyGenerator is parsing the TTree information.
15 Also contains the routine use to generate the appropriate code
16 fragment in the result of MakeProxy.
17 */
18 
19 #include "TFriendProxyDescriptor.h"
20 #include "TBranchProxyDescriptor.h"
21 #include "TList.h"
22 
24 
25 namespace ROOT {
26 namespace Internal {
27 
29  const char *aliasname,
30  Int_t index) :
31  TNamed(treename,aliasname),
32  fDuplicate(kFALSE),
33  fIndex(index)
34  {
35  // Constructor
36  }
37 
39  {
40  // Return true if this descriptor and the other are equivalent (describe the
41  // same entity).
42 
43  if ( !other ) return kFALSE;
44  if ( strcmp(GetName(),other->GetName()) ) return kFALSE;
45 
47  TBranchProxyDescriptor *othdesc;
48 
49  if ( fListOfTopProxies.GetSize() != other->fListOfTopProxies.GetSize() ) return kFALSE;
50  TIter next(&fListOfTopProxies);
51  TIter othnext(&other->fListOfTopProxies);
52  while ( (desc=(TBranchProxyDescriptor*)next()) ) {
53  othdesc=(TBranchProxyDescriptor*)othnext();
54  if (!desc->IsEquivalent(othdesc) ) return kFALSE;
55  }
56  return kTRUE;
57  }
58 
59  void TFriendProxyDescriptor::OutputClassDecl(FILE *hf, int offset, UInt_t maxVarname)
60  {
61  // Print the declaration needed for this descriptor.
62 
63  fprintf(hf,"%-*sstruct TFriendPx_%s : public TFriendProxy {\n", offset," ", GetName() );
64  fprintf(hf,"%-*s TFriendPx_%s(TBranchProxyDirector *director,TTree *tree,Int_t index) :\n",
65  offset," ", GetName() );
66  fprintf(hf,"%-*s %-*s(director,tree,index)",offset," ",maxVarname,"TFriendProxy");
68  TIter next = &fListOfTopProxies;
69  while ( (data = (TBranchProxyDescriptor*)next()) ) {
70  fprintf(hf,",\n%-*s %-*s(&fDirector,\"%s\")",
71  offset," ",maxVarname, data->GetDataName(), data->GetBranchName());
72  }
73  fprintf(hf,"\n%-*s { }\n",offset," ");
74 
75  fprintf(hf, "\n%-*s // Proxy for each of the branches and leaves of the tree\n",offset," ");
76  next.Reset();
77  while ( (data = (TBranchProxyDescriptor*)next()) ) {
78  data->OutputDecl(hf, offset+3, maxVarname);
79  }
80  fprintf(hf,"%-*s};\n",offset," ");
81  }
82 
83  void TFriendProxyDescriptor::OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
84  {
85  // Print the declaration needed for this descriptor.
86 
87  TString typeName = "TFriendPx_";
88  typeName += GetName();
89  fprintf(hf,"%-*s%-*s %s;\n",
90  offset," ",maxVarname,typeName.Data(),GetTitle());
91  }
92 
93 } // namespace Internal
94 } // namespace ROOT
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
Bool_t IsEquivalent(const TFriendProxyDescriptor *other)
void OutputClassDecl(FILE *hf, int offset, UInt_t maxVarname)
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void Reset()
Definition: TCollection.h:161
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
unsigned int UInt_t
Definition: RtypesCore.h:42
void OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
#define ClassImp(name)
Definition: Rtypes.h:279
Bool_t IsEquivalent(const TBranchProxyDescriptor *other, Bool_t inClass=kFALSE)
TFriendProxyDescriptor(const TFriendProxyDescriptor &b)
virtual Int_t GetSize() const
Definition: TCollection.h:95
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
const char * Data() const
Definition: TString.h:349