Logo ROOT   6.08/07
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 #ifndef ROOT_TNamed
16 #include "TNamed.h"
17 #endif
18 
19 #ifndef ROOT_TList
20 #include "TList.h"
21 #endif
22 
23 #include <list>
24 
25 class TMethod;
26 class TBowser;
27 class TClass;
28 class TBranch;
29 class TBranchElement;
30 class TString;
31 class TStreamerElement;
32 
34 public:
35 
36  // these methods are registered in RegisterGenerator, and
37  // called to create the list of browsables. See e.g.
38  // TMethodBrowsable::Register
40  (TList&, const TBranch* branch, const TVirtualBranchBrowsable* parent);
41 
43 
44  void Browse(TBrowser *b);
45  const char *GetIconName() const {
46  // return icon shown when browsing a TVirtualBranchBrowsable
47  if (IsFolder()) return "TBranchElement-folder";
48  else return "TBranchElement-leaf";
49  }
50  void GetScope(TString & scope) const;
51  Bool_t IsFolder() const {
52  // check whether we have sub-elements
53  return (GetLeaves() && GetLeaves()->GetSize()); }
54 
55  static Int_t FillListOfBrowsables(TList& list, const TBranch* branch,
56  const TVirtualBranchBrowsable* parent=0);
57 
58  const TBranch* GetBranch() const {
59  // return the parent branch (might be many levels up)
60  return fBranch; }
62  // return the parent TVirtualBranchBrowsable
63  return fParent; }
64  TClass* GetClassType() const {
65  // return the type of this browsable object
66  return fClass; }
68  // return whether the type of this browsable object is a pointer
69  return fTypeIsPointer; }
70  TList* GetLeaves() const;
71 
72  // static void Register() has to be implemented for all derived classes!
73  // static void Unregister() has to be implemented for all derived classes!
74 
75 protected:
76  TVirtualBranchBrowsable(const TBranch* b, TClass* type, Bool_t typeIsPointer,
77  const TVirtualBranchBrowsable* parent=0);
78  static TClass* GetCollectionContainedType(const TBranch* b,
79  const TVirtualBranchBrowsable* parent, TClass* &contained);
80  static std::list<MethodCreateListOfBrowsables_t>& GetRegisteredGenerators();
83  void SetType(TClass* type) {
84  // sets the type of this browsable object
85  fClass=type; }
87  // sets whether the type of this browsable object is a pointer
88  fTypeIsPointer=set; }
89 
90 private:
91  static void RegisterDefaultGenerators();
92  const TBranch *fBranch; ///< pointer to the branch element representing the top object
93  const TVirtualBranchBrowsable *fParent; ///< parent method if this method is member of a returned class
94  TList *fLeaves; ///< pointer to leaves
95  TClass *fClass; ///< pointer to TClass representing our type (i.e. return type for methods), 0 if basic type
96  Bool_t fTypeIsPointer; ///< 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  ClassDef(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=0);
109  const char *GetIconName() const {
110  // return our special icons
111  if (IsFolder()) return "TMethodBrowsable-branch";
112  return "TMethodBrowsable-leaf";}
113  static Bool_t IsMethodBrowsable(const TMethod* m);
114  static void Register();
115  static void Unregister();
116 
117 protected:
118  static void GetBrowsableMethodsForClass(TClass* cl, TList& list);
119  TMethodBrowsable(const TBranch* branch, TMethod* m,
120  const TVirtualBranchBrowsable* parent=0);
121 
122 private:
123  TMethod *fMethod; // pointer to a method
124  ClassDef(TMethodBrowsable,0); // Helper object to browse methods
125 };
126 
127 
129 public:
131 
132  static Int_t GetBrowsables(TList& list, const TBranch* branch,
133  const TVirtualBranchBrowsable* parent=0);
134  static void Register();
135  static void Unregister();
136 
137 protected:
138  TNonSplitBrowsable(const TStreamerElement* element, const TBranch* branch,
139  const TVirtualBranchBrowsable* parent=0);
140 
141 private:
142  ClassDef(TNonSplitBrowsable, 0); // Helper object to browse unsplit objects
143 };
144 
145 
147 public:
149 
150  void Browse(TBrowser *b);
151  static Int_t GetBrowsables(TList& list, const TBranch* branch,
152  const TVirtualBranchBrowsable* parent=0);
153  const char* GetDraw() const {
154  // return the string passed to TTree::Draw
155  return fDraw.Data(); }
156  static void Register();
157  static void Unregister();
158 
159 protected:
160  TCollectionPropertyBrowsable(const char* name, const char* title,
161  const char* draw, const TBranch* branch, const TVirtualBranchBrowsable* parent=0):
162  TVirtualBranchBrowsable(branch, 0, kFALSE, parent), fDraw(draw) {
163  // constructor, which sets the name and title according to the parameters
164  // (and thus differently than our base class TVirtualBranchBrowsable)
165  SetNameTitle(name, title);
166  }
167 
168 private:
169  TString fDraw; // string to send to TTree::Draw(), NOT by GetScope()!
170  ClassDef(TCollectionPropertyBrowsable, 0); // Helper object to add browsable collection properties
171 };
172 
174 public:
176 
177  static Int_t GetBrowsables(TList& list, const TBranch* branch,
178  const TVirtualBranchBrowsable* parent=0);
179  static void Register();
180  static void Unregister();
181 
182 protected:
184  const TVirtualBranchBrowsable* parent=0);
185 
186  ClassDef(TCollectionMethodBrowsable,0); // Helper object to browse a collection's methods
187 };
188 
189 #endif // defined ROOT_TBranchBrowsable
static void RegisterDefaultGenerators()
Adds the default generators.
const char * GetDraw() const
Bool_t TypeIsPointer() const
TList * fLeaves
pointer to leaves
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TNamed.cxx:145
const TVirtualBranchBrowsable * fParent
parent method if this method is member of a returned class
A tiny browser helper object (and its generator) for adding a virtual (as in "not actually part of th...
void SetType(TClass *type)
static Int_t FillListOfBrowsables(TList &list, const TBranch *branch, const TVirtualBranchBrowsable *parent=0)
Askes all registered generators to fill their browsables into the list.
void GetScope(TString &scope) const
Returns the full name for TTree::Draw to draw *this.
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t(* MethodCreateListOfBrowsables_t)(TList &, const TBranch *branch, const TVirtualBranchBrowsable *parent)
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TList * GetLeaves() const
Return list of leaves. If not set up yet we&#39;ll create them.
const TVirtualBranchBrowsable * GetParent() const
const char * GetIconName() const
Returns mime type name of object.
const char * GetIconName() const
Returns mime type name of object.
A doubly linked list.
Definition: TList.h:47
static TClass * GetCollectionContainedType(const TBranch *b, const TVirtualBranchBrowsable *parent, TClass *&contained)
Check whether the branch (or the parent) contains a collection.
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
TClass * fClass
pointer to TClass representing our type (i.e. return type for methods), 0 if basic type ...
static void RegisterGenerator(MethodCreateListOfBrowsables_t generator)
Adds a generator to be called when browsing branches.
TMarker * m
Definition: textangle.C:8
TCollectionMethodBrowsable extends TCollectionPropertyBrowsable by showing all methods of the collect...
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
static Bool_t fgGeneratorsSet
have we set the generators yet? empty is not good enough - user might have removed them ...
TVirtualBranchBrowsable is a base class (not really abstract, but useless by itself) for helper objec...
A Branch for the case of an object.
void SetTypeIsPointer(Bool_t set=kTRUE)
const TBranch * GetBranch() const
TClass * GetClassType() const
int type
Definition: TGX11.cxx:120
void Browse(TBrowser *b)
Calls TTree::Draw on the method if return type is not a class; otherwise expands returned object&#39;s "f...
TCollectionPropertyBrowsable(const char *name, const char *title, const char *draw, const TBranch *branch, const TVirtualBranchBrowsable *parent=0)
Each ROOT class (see TClass) has a linked list of methods.
Definition: TMethod.h:40
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
const TBranch * fBranch
pointer to the branch element representing the top object
static std::list< MethodCreateListOfBrowsables_t > fgGenerators
list of MethodCreateListOfBrowsables_t called by CreateListOfBrowsables
Bool_t fTypeIsPointer
return type is pointer to class
A TTree is a list of TBranches.
Definition: TBranch.h:58
static std::list< MethodCreateListOfBrowsables_t > & GetRegisteredGenerators()
returns the list of registered generator methods
const Bool_t kTRUE
Definition: Rtypes.h:91
~TVirtualBranchBrowsable()
Destructor. Delete our leaves.
char name[80]
Definition: TGX11.cxx:109
TVirtualBranchBrowsable(const TBranch *b, TClass *type, Bool_t typeIsPointer, const TVirtualBranchBrowsable *parent=0)
Constructor setting all members according to parameters.
Allows a TBrowser to browse non-split branches as if they were split.
static void UnregisterGenerator(MethodCreateListOfBrowsables_t generator)
Removes a generator from the list of generators to be called when browsing branches.
This helper object allows the browsing of methods of objects stored in branches.