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 {
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
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
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\")",
138 } else {
139 if (fIsLeafList) {
140 if (above[0]=='\0') {
141 fprintf(hf,"\n%-*s %-*s(director, \"%s\", \"\", \"%s\")",
143 } else {
144 fprintf(hf,"\n%-*s %-*s(director, %s\"%s\", \"%s\")",
146 }
147 } else {
148 fprintf(hf,"\n%-*s %-*s(director, %s\"%s\")",
150 }
151 }
152 } else {
153
154 fprintf(hf,"\n%-*s %-*s(director, obj.GetProxy(), \"%s\")",
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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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.
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
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
Ssiz_t Length() const
Definition TString.h:425
TString & Insert(Ssiz_t pos, const char *s)
Definition TString.h:669
const char * Data() const
Definition TString.h:384
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:712
TString & Remove(Ssiz_t pos)
Definition TString.h:693