ROOT  6.06/09
Reference Guide
TBranchProxyDescriptor.cxx
Go to the documentation of this file.
1 // @(#)root/treeplayer:$Id$
2 // Author: Philippe Canal 06/06/2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and 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 /** \class TBranchProxyDescriptor
13 /Hold the processed information about a TBranch 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 "TBranchProxyDescriptor.h"
20 
21 #include "TClonesArray.h"
22 #include "TError.h"
23 #include "TROOT.h"
24 
25 #include "TTreeFormula.h"
26 #include "TFormLeafInfo.h"
27 #include <ctype.h>
28 
30 
31 namespace ROOT {
32 namespace Internal {
33 
35  const char *type,
36  const char *branchname,
37  Bool_t split,
38  Bool_t skipped,
39  Bool_t isleaflist) :
40  TNamed(dataname,type),fBranchName(branchname),fIsSplit(split),fBranchIsSkipped(skipped),fIsLeafList(isleaflist)
41  {
42  // Constructor.
43 
44  fDataName = GetName();
46 
47  fDataName.ReplaceAll(".","_");
48  fDataName.ReplaceAll(":","_");
49  fDataName.ReplaceAll("<","_");
50  fDataName.ReplaceAll(">","_");
51  if (!isalpha(fDataName[0])) fDataName.Insert(0,"_");
52  fDataName.ReplaceAll(" ","");
53  fDataName.ReplaceAll("*","st");
54  fDataName.ReplaceAll("&","rf");
55 
56  }
57 
59  {
60  // Get the name of the data member.
61  return fDataName;
62  }
63 
65  {
66  // Get the name of the type of the data member
67  return GetTitle();
68  }
69 
71  {
72  // Get the branch name.
73  return fBranchName.Data();
74  }
75 
77  Bool_t inClass)
78  {
79  // Return true if this description is the 'same' as the other decription.
80 
81  if ( !other ) return false;
82  if ( other == this ) return true;
83 
84  if ( inClass ) {
85  // If this description belong to a class, the branchname will be
86  // stripped.
87  } else {
88  if ( fBranchName != other->fBranchName ) return false;
89  }
90  if ( fIsSplit != other->fIsSplit ) return false;
91  if ( fBranchIsSkipped != other->fBranchIsSkipped) return false;
92  if ( strcmp(GetName(),other->GetName()) ) return false;
93  if ( strcmp(GetTitle(),other->GetTitle()) ) return false;
94  return true;
95  }
96 
98  {
99  // Return true if the branch is split
100  return fIsSplit;
101  }
102 
103  void TBranchProxyDescriptor::OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
104  {
105  // Output the declaration corresponding to this proxy
106  fprintf(hf,"%-*s%-*s %s;\n", offset," ", maxVarname, GetTypeName(), GetDataName()); // might want to add a comment
107  }
108 
109  void TBranchProxyDescriptor::OutputInit(FILE *hf, int offset,
110  UInt_t maxVarname,
111  const char *prefix)
112  {
113  // Output the initialization corresponding to this proxy
114  if (fIsSplit) {
115  const char *subbranchname = GetBranchName();
116  const char *above = "";
117  if (strncmp(prefix,subbranchname,strlen(prefix))==0
118  && strcmp(prefix,subbranchname)!=0) {
119  subbranchname += strlen(prefix)+1; // +1 for the dot "."
120  above = "ffPrefix, ";
121  }
122 
123  if (fBranchIsSkipped) {
124  fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\", %s\"%s\")",
125  offset," ", maxVarname, GetDataName(), GetDataName(), above, subbranchname);
126  } else {
127  if (fIsLeafList) {
128  if (above[0]=='\0') {
129  fprintf(hf,"\n%-*s %-*s(director, \"%s\", \"\", \"%s\")",
130  offset," ", maxVarname, GetDataName(), subbranchname, GetDataName());
131  } else {
132  fprintf(hf,"\n%-*s %-*s(director, %s\"%s\", \"%s\")",
133  offset," ", maxVarname, GetDataName(), above, subbranchname, GetDataName());
134  }
135  } else {
136  fprintf(hf,"\n%-*s %-*s(director, %s\"%s\")",
137  offset," ", maxVarname, GetDataName(), above, subbranchname);
138  }
139  }
140  } else {
141 
142  fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\")",
143  offset," ", maxVarname, GetDataName(), GetBranchName() );
144 
145  //fprintf(hf,"\n%-*s %-*s(director, ffPrefix, \"\", \"%s\")",
146  // offset," ", maxVarname, GetName(), GetBranchName() );
147 
148  }
149  }
150 
151 } // namespace Internal
152 } // namespace ROOT
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
Ssiz_t Length() const
Definition: TString.h:390
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
void OutputInit(FILE *hf, int offset, UInt_t maxVarname, const char *prefix)
bool Bool_t
Definition: RtypesCore.h:59
TBranchProxyDescriptor(const char *dataname, const char *type, const char *branchname, Bool_t split=true, Bool_t skipped=false, Bool_t isleaflist=false)
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:592
const char * Data() const
Definition: TString.h:349
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
def split(str)
helpers ------------------------------------------------------------------—
Definition: ROOT.py:170
void OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
unsigned int UInt_t
Definition: RtypesCore.h:42
ClassImp(ROOT::Internal::TBranchProxyDescriptor)
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
Bool_t IsEquivalent(const TBranchProxyDescriptor *other, Bool_t inClass=kFALSE)
int type
Definition: TGX11.cxx:120