Logo ROOT  
Reference Guide
TBranchBrowsable.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Axel Naumann 14/10/2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
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 #ifndef ROOT_TBranchBrowsable
13 #define ROOT_TBranchBrowsable
14 
15 #include "TNamed.h"
16 
17 #include "TList.h"
18 
19 #include <list>
20 
21 class TMethod;
22 class TBowser;
23 class TClass;
24 class TBranch;
25 class TBranchElement;
26 class TString;
27 class TStreamerElement;
28 
30 public:
31 
32  // these methods are registered in RegisterGenerator, and
33  // called to create the list of browsables. See e.g.
34  // TMethodBrowsable::Register
36  (TList &, const TBranch *branch, const TVirtualBranchBrowsable *parent);
37 
39 
40  void Browse(TBrowser *b) override;
41 
42  /** return icon shown when browsing a TVirtualBranchBrowsable */
43  const char* GetIconName() const override
44  {
45  if (IsFolder())
46  return "TBranchElement-folder";
47  else
48  return "TBranchElement-leaf";
49  }
50 
51  void GetScope(TString &scope) const;
52 
53  /** check whether we have sub-elements */
54  Bool_t IsFolder() const override { return (GetLeaves() && GetLeaves()->GetSize()); }
55 
56  static Int_t FillListOfBrowsables(TList &list, const TBranch *branch,
57  const TVirtualBranchBrowsable *parent = nullptr);
58 
59  /** return the parent branch (might be many levels up) */
60  const TBranch* GetBranch() const { return fBranch; }
61 
62  /** return the parent TVirtualBranchBrowsable */
63  const TVirtualBranchBrowsable* GetParent() const { return fParent; }
64 
65  /** return the type of this browsable object */
66  TClass *GetClassType() const { return fClass; }
67 
68  /** return whether the type of this browsable object is a pointer */
69  Bool_t TypeIsPointer() const { return fTypeIsPointer; }
70 
71  TList *GetLeaves() const;
72 
73  // static void Register() has to be implemented for all derived classes!
74  // static void Unregister() has to be implemented for all derived classes!
75 
76 protected:
77  TVirtualBranchBrowsable(const TBranch *b, TClass *type, Bool_t typeIsPointer,
78  const TVirtualBranchBrowsable *parent = nullptr);
80  const TVirtualBranchBrowsable *parent, TClass *&contained);
81  static std::list<MethodCreateListOfBrowsables_t>& GetRegisteredGenerators();
84  /** sets the type of this browsable object */
85  void SetType(TClass* type) { fClass = type; }
86 
87  /** sets whether the type of this browsable object is a pointer */
89 
90 private:
91  static void RegisterDefaultGenerators();
92  const TBranch *fBranch{nullptr}; ///< pointer to the branch element representing the top object
93  const TVirtualBranchBrowsable *fParent{nullptr}; ///< parent method if this method is member of a returned class
94  TList *fLeaves{nullptr}; ///< pointer to leaves
95  TClass *fClass{nullptr}; ///< pointer to TClass representing our type (i.e. return type for methods), 0 if basic type
96  Bool_t fTypeIsPointer{kFALSE}; ///< return type is pointer to class
97  static std::list<MethodCreateListOfBrowsables_t> fgGenerators; ///< list of MethodCreateListOfBrowsables_t called by CreateListOfBrowsables
98  static Bool_t fgGeneratorsSet; ///< have we set the generators yet? empty is not good enough - user might have removed them
99  ClassDefOverride(TVirtualBranchBrowsable, 0); ///< Base class for helper objects used for browsing
100 };
101 
102 
104 public:
106 
107  static Int_t GetBrowsables(TList &list, const TBranch *branch,
108  const TVirtualBranchBrowsable *parent = nullptr);
109 
110  /** return our special icons */
111  const char* GetIconName() const override
112  {
113  if (IsFolder())
114  return "TMethodBrowsable-branch";
115  return "TMethodBrowsable-leaf";
116  }
117  static Bool_t IsMethodBrowsable(const TMethod *m);
118  static void Register();
119  static void Unregister();
120 
121 protected:
122  static void GetBrowsableMethodsForClass(TClass *cl, TList &list);
123  TMethodBrowsable(const TBranch *branch, TMethod *m,
124  const TVirtualBranchBrowsable *parent = nullptr);
125 
126 private:
127  TMethod *fMethod{nullptr}; // pointer to a method
128  ClassDefOverride(TMethodBrowsable,0); // Helper object to browse methods
129 };
130 
131 
133 public:
135 
136  static Int_t GetBrowsables(TList &list, const TBranch *branch,
137  const TVirtualBranchBrowsable *parent = nullptr);
138  static void Register();
139  static void Unregister();
140 
141 protected:
142  TNonSplitBrowsable(const TStreamerElement *element, const TBranch *branch,
143  const TVirtualBranchBrowsable *parent = nullptr);
144 
145 private:
146  ClassDef(TNonSplitBrowsable, 0); // Helper object to browse unsplit objects
147 };
148 
149 
151 public:
153 
154  void Browse(TBrowser *b) override;
155  static Int_t GetBrowsables(TList &list, const TBranch *branch,
156  const TVirtualBranchBrowsable *parent = nullptr);
157  /** return the string passed to TTree::Draw */
158  const char *GetDraw() const { return fDraw.Data(); }
159  static void Register();
160  static void Unregister();
161 
162 protected:
163  /** constructor, which sets the name and title according to the parameters
164  * (and thus differently than our base class TVirtualBranchBrowsable) */
165  TCollectionPropertyBrowsable(const char *name, const char *title,
166  const char *draw, const TBranch *branch,
167  const TVirtualBranchBrowsable *parent = nullptr) :
168  TVirtualBranchBrowsable(branch, 0, kFALSE, parent), fDraw(draw)
169  {
170  SetNameTitle(name, title);
171  }
172 
173 private:
174  TString fDraw; // string to send to TTree::Draw(), NOT by GetScope()!
175  ClassDefOverride(TCollectionPropertyBrowsable, 0); // Helper object to add browsable collection properties
176 };
177 
179 public:
181 
182  static Int_t GetBrowsables(TList &list, const TBranch *branch,
183  const TVirtualBranchBrowsable *parent = nullptr);
184  static void Register();
185  static void Unregister();
186 
187 protected:
189  const TVirtualBranchBrowsable* parent = nullptr);
190 
191  ClassDef(TCollectionMethodBrowsable,0); // Helper object to browse a collection's methods
192 };
193 
194 #endif // defined ROOT_TBranchBrowsable
TCollectionMethodBrowsable::Unregister
static void Unregister()
Wrapper for the registration method.
Definition: TBranchBrowsable.cxx:970
m
auto * m
Definition: textangle.C:8
TCollectionMethodBrowsable::~TCollectionMethodBrowsable
~TCollectionMethodBrowsable()
Definition: TBranchBrowsable.h:180
TVirtualBranchBrowsable::fBranch
const TBranch * fBranch
pointer to the branch element representing the top object
Definition: TBranchBrowsable.h:92
TBrowser
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TVirtualBranchBrowsable::fLeaves
TList * fLeaves
pointer to leaves
Definition: TBranchBrowsable.h:94
TCollectionPropertyBrowsable::Unregister
static void Unregister()
Wrapper for the registration method.
Definition: TBranchBrowsable.cxx:881
TVirtualBranchBrowsable::GetRegisteredGenerators
static std::list< MethodCreateListOfBrowsables_t > & GetRegisteredGenerators()
returns the list of registered generator methods
Definition: TBranchBrowsable.cxx:285
TNamed::SetNameTitle
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TNamed.cxx:154
TNonSplitBrowsable::GetBrowsables
static Int_t GetBrowsables(TList &list, const TBranch *branch, const TVirtualBranchBrowsable *parent=nullptr)
Given either a branch "branch" or a "parent" TVirtualBranchBrowsable, we fill "list" with objects of ...
Definition: TBranchBrowsable.cxx:634
TBranchElement
A Branch for the case of an object.
Definition: TBranchElement.h:39
TCollectionMethodBrowsable::GetBrowsables
static Int_t GetBrowsables(TList &list, const TBranch *branch, const TVirtualBranchBrowsable *parent=nullptr)
This methods fills list with TMethodBrowsables for the branch's or parent's collection class and its ...
Definition: TBranchBrowsable.cxx:924
TMethodBrowsable::Unregister
static void Unregister()
Wrapper for the registration method.
Definition: TBranchBrowsable.cxx:594
TString::Data
const char * Data() const
Definition: TString.h:369
TCollectionPropertyBrowsable::~TCollectionPropertyBrowsable
~TCollectionPropertyBrowsable()
Definition: TBranchBrowsable.h:152
TVirtualBranchBrowsable
TVirtualBranchBrowsable is a base class (not really abstract, but useless by itself) for helper objec...
Definition: TBranchBrowsable.h:29
TVirtualBranchBrowsable::UnregisterGenerator
static void UnregisterGenerator(MethodCreateListOfBrowsables_t generator)
Removes a generator from the list of generators to be called when browsing branches.
Definition: TBranchBrowsable.cxx:372
TVirtualBranchBrowsable::GetScope
void GetScope(TString &scope) const
Returns the full name for TTree::Draw to draw *this.
Definition: TBranchBrowsable.cxx:296
TNamed.h
TVirtualBranchBrowsable::GetParent
const TVirtualBranchBrowsable * GetParent() const
return the parent TVirtualBranchBrowsable
Definition: TBranchBrowsable.h:63
TMethodBrowsable::TMethodBrowsable
TMethodBrowsable(const TBranch *branch, TMethod *m, const TVirtualBranchBrowsable *parent=nullptr)
Constructor.
Definition: TBranchBrowsable.cxx:409
Int_t
int Int_t
Definition: RtypesCore.h:45
TNonSplitBrowsable::TNonSplitBrowsable
TNonSplitBrowsable(const TStreamerElement *element, const TBranch *branch, const TVirtualBranchBrowsable *parent=nullptr)
Constructor.
Definition: TBranchBrowsable.cxx:621
TVirtualBranchBrowsable::TypeIsPointer
Bool_t TypeIsPointer() const
return whether the type of this browsable object is a pointer
Definition: TBranchBrowsable.h:69
TVirtualBranchBrowsable::IsFolder
Bool_t IsFolder() const override
check whether we have sub-elements
Definition: TBranchBrowsable.h:54
TMethodBrowsable
This helper object allows the browsing of methods of objects stored in branches.
Definition: TBranchBrowsable.h:103
TMethodBrowsable::fMethod
TMethod * fMethod
Definition: TBranchBrowsable.h:127
TCollectionPropertyBrowsable::Register
static void Register()
Wrapper for the registration method.
Definition: TBranchBrowsable.cxx:871
TList.h
TMethodBrowsable::GetBrowsables
static Int_t GetBrowsables(TList &list, const TBranch *branch, const TVirtualBranchBrowsable *parent=nullptr)
This methods fills list with TMethodBrowsables for the branch's or parent's class and its base classe...
Definition: TBranchBrowsable.cxx:501
TVirtualBranchBrowsable::ClassDefOverride
ClassDefOverride(TVirtualBranchBrowsable, 0)
Base class for helper objects used for browsing.
TVirtualBranchBrowsable::GetCollectionContainedType
static TClass * GetCollectionContainedType(const TBranch *b, const TVirtualBranchBrowsable *parent, TClass *&contained)
Check whether the branch (or the parent) contains a collection.
Definition: TBranchBrowsable.cxx:160
TString
Basic string class.
Definition: TString.h:136
TVirtualBranchBrowsable::fParent
const TVirtualBranchBrowsable * fParent
parent method if this method is member of a returned class
Definition: TBranchBrowsable.h:93
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TMethodBrowsable::Register
static void Register()
Wrapper for the registration method.
Definition: TBranchBrowsable.cxx:584
b
#define b(i)
Definition: RSha256.hxx:100
TMethodBrowsable::ClassDefOverride
ClassDefOverride(TMethodBrowsable, 0)
TVirtualBranchBrowsable::SetType
void SetType(TClass *type)
sets the type of this browsable object
Definition: TBranchBrowsable.h:85
bool
TCollectionMethodBrowsable::TCollectionMethodBrowsable
TCollectionMethodBrowsable(const TBranch *branch, TMethod *m, const TVirtualBranchBrowsable *parent=nullptr)
Constructor, see TMethodBrowsable's constructor.
Definition: TBranchBrowsable.cxx:910
TVirtualBranchBrowsable::MethodCreateListOfBrowsables_t
Int_t(* MethodCreateListOfBrowsables_t)(TList &, const TBranch *branch, const TVirtualBranchBrowsable *parent)
Definition: TBranchBrowsable.h:36
TVirtualBranchBrowsable::GetLeaves
TList * GetLeaves() const
Return list of leaves. If not set up yet we'll create them.
Definition: TBranchBrowsable.cxx:271
TBranch
A TTree is a list of TBranches.
Definition: TBranch.h:89
TMethodBrowsable::~TMethodBrowsable
~TMethodBrowsable()
Definition: TBranchBrowsable.h:105
TCollectionMethodBrowsable::Register
static void Register()
Wrapper for the registration method.
Definition: TBranchBrowsable.cxx:960
TNonSplitBrowsable::~TNonSplitBrowsable
~TNonSplitBrowsable()
Definition: TBranchBrowsable.h:134
TVirtualBranchBrowsable::SetTypeIsPointer
void SetTypeIsPointer(Bool_t set=kTRUE)
sets whether the type of this browsable object is a pointer
Definition: TBranchBrowsable.h:88
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TVirtualBranchBrowsable::GetClassType
TClass * GetClassType() const
return the type of this browsable object
Definition: TBranchBrowsable.h:66
TMethod
Each ROOT class (see TClass) has a linked list of methods.
Definition: TMethod.h:38
TVirtualBranchBrowsable::FillListOfBrowsables
static Int_t FillListOfBrowsables(TList &list, const TBranch *branch, const TVirtualBranchBrowsable *parent=nullptr)
Askes all registered generators to fill their browsables into the list.
Definition: TBranchBrowsable.cxx:138
TNonSplitBrowsable::Register
static void Register()
Wrapper for the registration method.
Definition: TBranchBrowsable.cxx:723
TMethodBrowsable::IsMethodBrowsable
static Bool_t IsMethodBrowsable(const TMethod *m)
A TMethod is browsable if it is const, public and not pure virtual, if does not have any parameter wi...
Definition: TBranchBrowsable.cxx:530
TVirtualBranchBrowsable::fClass
TClass * fClass
pointer to TClass representing our type (i.e. return type for methods), 0 if basic type
Definition: TBranchBrowsable.h:95
TMethodBrowsable::GetBrowsableMethodsForClass
static void GetBrowsableMethodsForClass(TClass *cl, TList &list)
Given a class, this methods fills list with TMethodBrowsables for the class and its base classes,...
Definition: TBranchBrowsable.cxx:444
TCollectionPropertyBrowsable::Browse
void Browse(TBrowser *b) override
Browses a TCollectionPropertyBrowsable.
Definition: TBranchBrowsable.cxx:761
TVirtualBranchBrowsable::RegisterGenerator
static void RegisterGenerator(MethodCreateListOfBrowsables_t generator)
Adds a generator to be called when browsing branches.
Definition: TBranchBrowsable.cxx:356
TCollectionPropertyBrowsable::GetDraw
const char * GetDraw() const
return the string passed to TTree::Draw
Definition: TBranchBrowsable.h:158
TCollectionPropertyBrowsable::fDraw
TString fDraw
Definition: TBranchBrowsable.h:174
TVirtualBranchBrowsable::fgGenerators
static std::list< MethodCreateListOfBrowsables_t > fgGenerators
list of MethodCreateListOfBrowsables_t called by CreateListOfBrowsables
Definition: TBranchBrowsable.h:97
TVirtualBranchBrowsable::GetBranch
const TBranch * GetBranch() const
return the parent branch (might be many levels up)
Definition: TBranchBrowsable.h:60
TMethodBrowsable::GetIconName
const char * GetIconName() const override
return our special icons
Definition: TBranchBrowsable.h:111
TCollectionPropertyBrowsable
A tiny browser helper object (and its generator) for adding a virtual (as in "not actually part of th...
Definition: TBranchBrowsable.h:150
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TVirtualBranchBrowsable::~TVirtualBranchBrowsable
~TVirtualBranchBrowsable()
Destructor. Delete our leaves.
Definition: TBranchBrowsable.cxx:97
TVirtualBranchBrowsable::fgGeneratorsSet
static Bool_t fgGeneratorsSet
have we set the generators yet? empty is not good enough - user might have removed them
Definition: TBranchBrowsable.h:98
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
TCollectionPropertyBrowsable::TCollectionPropertyBrowsable
TCollectionPropertyBrowsable(const char *name, const char *title, const char *draw, const TBranch *branch, const TVirtualBranchBrowsable *parent=nullptr)
constructor, which sets the name and title according to the parameters (and thus differently than our...
Definition: TBranchBrowsable.h:165
TVirtualBranchBrowsable::fTypeIsPointer
Bool_t fTypeIsPointer
return type is pointer to class
Definition: TBranchBrowsable.h:96
TVirtualBranchBrowsable::GetIconName
const char * GetIconName() const override
return icon shown when browsing a TVirtualBranchBrowsable
Definition: TBranchBrowsable.h:43
type
int type
Definition: TGX11.cxx:121
TVirtualBranchBrowsable::Browse
void Browse(TBrowser *b) override
Calls TTree::Draw on the method if return type is not a class; otherwise expands returned object's "f...
Definition: TBranchBrowsable.cxx:106
TVirtualBranchBrowsable::TVirtualBranchBrowsable
TVirtualBranchBrowsable(const TBranch *b, TClass *type, Bool_t typeIsPointer, const TVirtualBranchBrowsable *parent=nullptr)
Constructor setting all members according to parameters.
Definition: TBranchBrowsable.cxx:84
TVirtualBranchBrowsable::RegisterDefaultGenerators
static void RegisterDefaultGenerators()
Adds the default generators.
Definition: TBranchBrowsable.cxx:341
TCollectionPropertyBrowsable::ClassDefOverride
ClassDefOverride(TCollectionPropertyBrowsable, 0)
TNonSplitBrowsable::Unregister
static void Unregister()
Wrapper for the registration method.
Definition: TBranchBrowsable.cxx:733
TStreamerElement
Definition: TStreamerElement.h:33
TCollectionMethodBrowsable
TCollectionMethodBrowsable extends TCollectionPropertyBrowsable by showing all methods of the collect...
Definition: TBranchBrowsable.h:178
TNonSplitBrowsable
Allows a TBrowser to browse non-split branches as if they were split.
Definition: TBranchBrowsable.h:132
TList
A doubly linked list.
Definition: TList.h:44
TCollectionPropertyBrowsable::GetBrowsables
static Int_t GetBrowsables(TList &list, const TBranch *branch, const TVirtualBranchBrowsable *parent=nullptr)
If the element to browse (given by either parent of branch) contains a collection (TClonesArray or so...
Definition: TBranchBrowsable.cxx:776