Logo ROOT  
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
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
31namespace ROOT {
32namespace Internal {
33
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Constructor.
36
38 const char *type,
39 const char *branchname,
40 Bool_t split,
41 Bool_t skipped,
42 Bool_t isleaflist) :
43 TNamed(dataname,type),fBranchName(branchname),fIsSplit(split),fBranchIsSkipped(skipped),fIsLeafList(isleaflist)
44 {
47
48 fDataName.ReplaceAll(".","_");
49 fDataName.ReplaceAll(":","_");
50 fDataName.ReplaceAll("<","_");
51 fDataName.ReplaceAll(">","_");
52 if (!isalpha(fDataName[0])) fDataName.Insert(0,"_");
53 fDataName.ReplaceAll(" ","");
54 fDataName.ReplaceAll("*","st");
55 fDataName.ReplaceAll("&","rf");
56
57 }
58
59 ////////////////////////////////////////////////////////////////////////////////
60 /// Get the name of the data member.
61
63 {
64 return fDataName;
65 }
66
67 ////////////////////////////////////////////////////////////////////////////////
68 /// Get the name of the type of the data member
69
71 {
72 return GetTitle();
73 }
74
75 ////////////////////////////////////////////////////////////////////////////////
76 /// Get the branch name.
77
79 {
80 return fBranchName.Data();
81 }
82
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Return true if this description is the 'same' as the other description.
85
87 Bool_t inClass)
88 {
89 if ( !other ) return false;
90 if ( other == this ) return true;
91
92 if ( inClass ) {
93 // If this description belong to a class, the branchname will be
94 // stripped.
95 } else {
96 if ( fBranchName != other->fBranchName ) return false;
97 }
98 if ( fIsSplit != other->fIsSplit ) return false;
99 if ( fBranchIsSkipped != other->fBranchIsSkipped) return false;
100 if ( strcmp(GetName(),other->GetName()) ) return false;
101 if ( strcmp(GetTitle(),other->GetTitle()) ) return false;
102 return true;
103 }
104
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Return true if the branch is split
107
109 {
110 return fIsSplit;
111 }
112
113 ////////////////////////////////////////////////////////////////////////////////
114 /// Output the declaration corresponding to this proxy
115
116 void TBranchProxyDescriptor::OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
117 {
118 fprintf(hf,"%-*s%-*s %s;\n", offset," ", maxVarname, GetTypeName(), GetDataName()); // might want to add a comment
119 }
120
121 ////////////////////////////////////////////////////////////////////////////////
122 /// Output the initialization corresponding to this proxy
123
124 void TBranchProxyDescriptor::OutputInit(FILE *hf, int offset,
125 UInt_t maxVarname,
126 const char *prefix)
127 {
128 if (fIsSplit) {
129 const char *subbranchname = GetBranchName();
130 const char *above = "";
131 if (strncmp(prefix,subbranchname,strlen(prefix))==0
132 && strcmp(prefix,subbranchname)!=0) {
133 subbranchname += strlen(prefix)+1; // +1 for the dot "."
134 above = "ffPrefix, ";
135 }
136
137 if (fBranchIsSkipped) {
138 fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\", %s\"%s\")",
139 offset," ", maxVarname, GetDataName(), GetDataName(), above, subbranchname);
140 } else {
141 if (fIsLeafList) {
142 if (above[0]=='\0') {
143 fprintf(hf,"\n%-*s %-*s(director, \"%s\", \"\", \"%s\")",
144 offset," ", maxVarname, GetDataName(), subbranchname, GetDataName());
145 } else {
146 fprintf(hf,"\n%-*s %-*s(director, %s\"%s\", \"%s\")",
147 offset," ", maxVarname, GetDataName(), above, subbranchname, GetDataName());
148 }
149 } else {
150 fprintf(hf,"\n%-*s %-*s(director, %s\"%s\")",
151 offset," ", maxVarname, GetDataName(), above, subbranchname);
152 }
153 }
154 } else {
155
156 fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\")",
157 offset," ", maxVarname, GetDataName(), GetBranchName() );
158
159 //fprintf(hf,"\n%-*s %-*s(director, ffPrefix, \"\", \"%s\")",
160 // offset," ", maxVarname, GetName(), GetBranchName() );
161
162 }
163 }
164
165} // namespace Internal
166} // namespace ROOT
unsigned int UInt_t
Definition: RtypesCore.h:46
bool Bool_t
Definition: RtypesCore.h:63
#define ClassImp(name)
Definition: Rtypes.h:364
int type
Definition: TGX11.cxx:121
TBranchProxyDescriptor(const char *dataname, const char *type, const char *branchname, Bool_t split=true, Bool_t skipped=false, Bool_t isleaflist=false)
Constructor.
void OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
Output the declaration corresponding to this proxy.
const char * GetBranchName()
Get the branch name.
const char * GetTypeName()
Get the name of the type of the data member.
const char * GetDataName()
Get the name of the data member.
void OutputInit(FILE *hf, int offset, UInt_t maxVarname, const char *prefix)
Output the initialization corresponding to this proxy.
Bool_t IsSplit() const
Return true if the branch is split.
Bool_t IsEquivalent(const TBranchProxyDescriptor *other, Bool_t inClass=kFALSE)
Return true if this description is the 'same' as the other description.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Ssiz_t Length() const
Definition: TString.h:410
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:649
const char * Data() const
Definition: TString.h:369
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...