library: libTree #include "TBranchBrowsable.h"

# TVirtualBranchBrowsable

class description - source file - inheritance tree (.pdf)

## class TVirtualBranchBrowsable : public TNamed

| Inheritance Chart:

`TObject`

<-

`TNamed`

<-

`TVirtualBranchBrowsable`

<-

`TCollectionPropertyBrowsable` |

`TMethodBrowsable`

<-

`TCollectionMethodBrowsable` |

`TNonSplitBrowsable` |

        private:

          static void RegisterDefaultGenerators()

        protected:

                                                       TVirtualBranchBrowsable(const TBranch* b, TClass* type, Bool_t typeIsPointer, const TVirtualBranchBrowsable* parent = 0)
                                        static TClass* GetCollectionContainedType(const TBranch* b, const TVirtualBranchBrowsable* parent, TClass*& contained)
          static list<MethodCreateListOfBrowsables_t>& GetRegisteredGenerators()
                                           static void RegisterGenerator(TVirtualBranchBrowsable::MethodCreateListOfBrowsables_t generator)
                                                  void SetType(TClass* type)
                                                  void SetTypeIsPointer(Bool_t set = kTRUE)
                                           static void UnregisterGenerator(TVirtualBranchBrowsable::MethodCreateListOfBrowsables_t generator)

        public:

                                         TVirtualBranchBrowsable(const TVirtualBranchBrowsable&)
                                         ~TVirtualBranchBrowsable()
                            virtual void Browse(TBrowser* b)
                          static TClass* Class()
                            static Int_t FillListOfBrowsables(TList& list, const TBranch* branch, const TVirtualBranchBrowsable* parent = 0)
                          const TBranch* GetBranch() const
                                 TClass* GetClassType() const
                     virtual const char* GetIconName() const
                                  TList* GetLeaves() const
          const TVirtualBranchBrowsable* GetParent() const
                                    void GetScope(TString& scope) const
                         virtual TClass* IsA() const
                          virtual Bool_t IsFolder() const
                            virtual void ShowMembers(TMemberInspector& insp, char* parent)
                            virtual void Streamer(TBuffer& b)
                                    void StreamerNVirtual(TBuffer& b)
                                  Bool_t TypeIsPointer() const

### Data Members

        private:

                                       const TBranch* fBranch          pointer to the branch element representing the top object
                       const TVirtualBranchBrowsable* fParent          parent method if this method is member of a returned class
                                               TList* fLeaves          pointer to laves
                                              TClass* fClass           pointer to TClass representing our type (i.e. return type for methods), 0 if basic type
                                               Bool_t fTypeIsPointer   return type is pointer to class
          static list<MethodCreateListOfBrowsables_t> fgGenerators     list of MethodCreateListOfBrowsables_t called by CreateListOfBrowsables
                                        static Bool_t fgGeneratorsSet  have we set the generators yet? empty is not good enough - user might have removed them

## Class Description

     TVirtualBranchBrowsable is a base class (not really abstract, but useless
     by itself) for helper objects that extend TBranch's browsing support.
     Each registered derived class's generator method is called, which fills
     all created helper objects into a list which can then be browsed.
     For details of what these browser helper objects can do, see e.g.
     TMethodBrowsable, which allows methods to show up in the TBrowser.

     Only registered helper objects are created. By default, only
     TMethodBrowsable, TNonSplitBrowsable, and TCollectionPropertyBrowsable
     are registered (see RegisterDefaultGenerators). You can prevent any of
     their objects to show up in the browser by unregistering the generator:
       TMethodBrowsable::Unregister()
     will stop creating browsable method helper objects from that call on.
     Note that these helper objects are cached (in TBranch::fBrowsables);
     already created (and thus cached) browsables will still appear in the
     browser even after unregistering the corresponding generator.

     You can implement your own browsable objects and thier generator; see
     e.g. the simple TCollectionPropertyBrowsable. Note that you will have
     to register your generator just like any other, and that you should
     implement the following methods for your own class, mainly for
     consistency reasons:
       static void Register() {
         TVirtualBranchBrowsable::RegisterGenerator(GetBrowsables); }
       static void Unregister() {
         TVirtualBranchBrowsable::UnregisterGenerator(GetBrowsables); }
     where GetBrowsables is a static member function of your class, that
     creates the browsable helper objects, and has the signature
       static Int_t GetBrowsables(TList& list, const TBranch* branch,
                                  const TVirtualBranchBrowsable* parent=0);
     It has to return the number of browsable helper objects for parent
     (or, if NULL, for branch) which are added to the list.
    ______________________________________________________________________________

TVirtualBranchBrowsable(const TBranch* branch, TClass* type, Bool_t typeIsPointer, const TVirtualBranchBrowsable* parent /*=0*/): fBranch(branch), fParent(parent), fLeaves(0), fClass(type), fTypeIsPointer(typeIsPointer)

     constructor setting all members according to parameters.

~TVirtualBranchBrowsable()

     Destructor. Delete our leaves.

void Browse(TBrowser *b)

     Calls TTree::Draw on the method if return type is not a class;
     otherwise expands returned object's "folder"

Int_t FillListOfBrowsables(TList& li, const TBranch* branch, const TVirtualBranchBrowsable* parent /* =0 */)

     Askes all registered generators to fill their browsables into
     the list. The browsables are generated for a given parent,
     or (if 0), for a given branch. The branch is passed down to
     leaves of TVirtualBranchBrowsable, too, as we need to access
     the branch's TTree to be able to traw.

TClass* GetCollectionContainedType(const TBranch* branch, const TVirtualBranchBrowsable* parent, TClass* &contained)

     Check whether the branch (or the parent) contains a collection.
     If it does, set "contained" to the contained type (if we can
     retrieve it) and return the TClass for the collection. Set
     "contained" to the branch's (or parent's) contained object's
     class for non-collections, returning 0.

     Only one of "branch" or "parent" can ge given (depending on whether
     we are creating browsable objects for a branch or for another
     browsable object)

TList* GetLeaves() const

     Return list of leaves. If not set up yet we'll create them.

void GetScope(TString & scope) const

     Returns the full name for TTree::Draw to draw *this.
     Recursively appends, starting at the top TBranch,
     all method / object names with proper reference operators (->, .)
     depending on fTypeIsPointer.

void RegisterDefaultGenerators()

     Adds the default generators. The user can remove any of them as follows:
       TMethodBrowsable::Unregister();
     which will cause the browser not to show any methods.

void RegisterGenerator(MethodCreateListOfBrowsables_t generator)

     Adds a generator to be called when browsing branches.
     Called by the Register method, which should be implemented
     for all derived classes (see e.g. TMethodBrowsable::Register())

void UnregisterGenerator(MethodCreateListOfBrowsables_t generator)

     Removes a generator from the list of generators to be called when
     browsing branches. The user can remove any of the generators as follows:
       TMethodBrowsable::Unregister();
     which will cause the browser not to show any methods.

### Inline Functions

                                      const char* GetIconName() const
                                           Bool_t IsFolder() const
                                   const TBranch* GetBranch() const
                   const TVirtualBranchBrowsable* GetParent() const
                                          TClass* GetClassType() const
                                           Bool_t TypeIsPointer() const
            list<MethodCreateListOfBrowsables_t>& GetRegisteredGenerators()
                                             void SetType(TClass* type)
                                             void SetTypeIsPointer(Bool_t set = kTRUE)
                                          TClass* Class()
                                          TClass* IsA() const
                                             void ShowMembers(TMemberInspector& insp, char* parent)
                                             void Streamer(TBuffer& b)
                                             void StreamerNVirtual(TBuffer& b)
                          TVirtualBranchBrowsable TVirtualBranchBrowsable(const TVirtualBranchBrowsable&)

Author: Axel Naumann 14/10/2004
Last update: root/tree:$Name: $:$Id: TBranchBrowsable.cxx,v 1.5 2005/05/18 21:04:54 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *