Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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 <cctype>
28
29
30namespace ROOT {
31namespace Internal {
32
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Constructor.
35
37 const char *type,
38 const char *branchname,
39 bool split,
40 bool skipped,
41 bool isleaflist) :
42 TNamed(dataname,type),fBranchName(branchname),fIsSplit(split),fBranchIsSkipped(skipped),fIsLeafList(isleaflist)
43 {
45 if (fDataName.Length() && fDataName[fDataName.Length()-1]=='.') fDataName.Remove(fDataName.Length()-1);
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
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Get the name of the data member.
60
62 {
63 return fDataName;
64 }
65
66 ////////////////////////////////////////////////////////////////////////////////
67 /// Get the name of the type of the data member
68
70 {
71 return GetTitle();
72 }
73
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Get the branch name.
76
78 {
79 return fBranchName.Data();
80 }
81
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Return true if this description is the 'same' as the other description.
84
86 {
87 if ( !other ) return false;
88 if ( other == this ) return true;
89
90 if ( inClass ) {
91 // If this description belong to a class, the branchname will be
92 // stripped.
93 } else {
94 if ( fBranchName != other->fBranchName ) return false;
95 }
96 if ( fIsSplit != other->fIsSplit ) return false;
97 if ( fBranchIsSkipped != other->fBranchIsSkipped) return false;
98 if ( strcmp(GetName(),other->GetName()) ) return false;
99 if ( strcmp(GetTitle(),other->GetTitle()) ) return false;
100 return true;
101 }
102
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Return true if the branch is split
105
107 {
108 return fIsSplit;
109 }
110
111 ////////////////////////////////////////////////////////////////////////////////
112 /// Output the declaration corresponding to this proxy
113
114 void TBranchProxyDescriptor::OutputDecl(FILE *hf, int offset, UInt_t maxVarname)
115 {
116 fprintf(hf,"%-*s%-*s %s;\n", offset," ", maxVarname, GetTypeName(), GetDataName()); // might want to add a comment
117 }
118
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Output the initialization corresponding to this proxy
121
122 void TBranchProxyDescriptor::OutputInit(FILE *hf, int offset,
123 UInt_t maxVarname,
124 const char *prefix)
125 {
126 if (fIsSplit) {
127 const char *subbranchname = GetBranchName();
128 const char *above = "";
129 if (strncmp(prefix,subbranchname,strlen(prefix))==0
130 && strcmp(prefix,subbranchname)!=0) {
131 subbranchname += strlen(prefix)+1; // +1 for the dot "."
132 above = "ffPrefix, ";
133 }
134
135 if (fBranchIsSkipped) {
136 fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\", %s\"%s\")",
137 offset," ", maxVarname, GetDataName(), GetDataName(), above, subbranchname);
138 } else {
139 if (fIsLeafList) {
140 if (above[0]=='\0') {
141 fprintf(hf,"\n%-*s %-*s(director, \"%s\", \"\", \"%s\")",
142 offset," ", maxVarname, GetDataName(), subbranchname, GetDataName());
143 } else {
144 fprintf(hf,"\n%-*s %-*s(director, %s\"%s\", \"%s\")",
145 offset," ", maxVarname, GetDataName(), above, subbranchname, GetDataName());
146 }
147 } else {
148 fprintf(hf,"\n%-*s %-*s(director, %s\"%s\")",
149 offset," ", maxVarname, GetDataName(), above, subbranchname);
150 }
151 }
152 } else {
153
154 fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\")",
155 offset," ", maxVarname, GetDataName(), GetBranchName() );
156
157 //fprintf(hf,"\n%-*s %-*s(director, ffPrefix, \"\", \"%s\")",
158 // offset," ", maxVarname, GetName(), GetBranchName() );
159
160 }
161 }
162
163} // namespace Internal
164} // namespace ROOT
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool IsSplit() const
Return true if the branch is split.
TBranchProxyDescriptor(const char *dataname, const char *type, const char *branchname, bool split=true, bool skipped=false, bool 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.
bool IsEquivalent(const TBranchProxyDescriptor *other, bool inClass=false)
Return true if this description is the 'same' as the other description.
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.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TNamed()
Definition TNamed.h:38