Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TBranchBrowsable.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/tree:$Id$
0002 // Author: Axel Naumann   14/10/2004
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TBranchBrowsable
0013 #define ROOT_TBranchBrowsable
0014 
0015 #include "TNamed.h"
0016 
0017 #include "TList.h"
0018 
0019 #include <list>
0020 
0021 class TMethod;
0022 class TBowser;
0023 class TClass;
0024 class TBranch;
0025 class TBranchElement;
0026 class TString;
0027 class TStreamerElement;
0028 
0029 class TVirtualBranchBrowsable: public TNamed {
0030 public:
0031 
0032    // these methods are registered in RegisterGenerator, and
0033    // called to create the list of browsables. See e.g.
0034    // TMethodBrowsable::Register
0035    typedef Int_t (*MethodCreateListOfBrowsables_t)
0036       (TList &, const TBranch *branch, const TVirtualBranchBrowsable *parent);
0037 
0038    ~TVirtualBranchBrowsable() override;
0039 
0040    void Browse(TBrowser *b) override;
0041 
0042    /** return icon shown when browsing a TVirtualBranchBrowsable */
0043    const char* GetIconName() const override
0044    {
0045       if (IsFolder())
0046          return "TBranchElement-folder";
0047       else
0048          return "TBranchElement-leaf";
0049    }
0050 
0051    void GetScope(TString &scope) const;
0052 
0053    /** check whether we have sub-elements */
0054    bool IsFolder() const override { return (GetLeaves() && GetLeaves()->GetSize()); }
0055 
0056    static Int_t FillListOfBrowsables(TList &list, const TBranch *branch,
0057          const TVirtualBranchBrowsable *parent = nullptr);
0058 
0059    /** return the parent branch (might be many levels up) */
0060    const TBranch* GetBranch() const { return fBranch; }
0061 
0062    /** return the parent TVirtualBranchBrowsable */
0063    const TVirtualBranchBrowsable* GetParent() const { return fParent; }
0064 
0065    /** return the type of this browsable object */
0066    TClass *GetClassType() const { return fClass; }
0067 
0068    /** return whether the type of this browsable object is a pointer */
0069    bool TypeIsPointer() const { return fTypeIsPointer; }
0070 
0071    TList *GetLeaves() const;
0072 
0073    // static void Register()   has to be implemented for all derived classes!
0074    // static void Unregister() has to be implemented for all derived classes!
0075 
0076 protected:
0077    TVirtualBranchBrowsable(const TBranch *b, TClass *type, bool typeIsPointer,
0078          const TVirtualBranchBrowsable *parent = nullptr);
0079    static TClass* GetCollectionContainedType(const TBranch *b,
0080          const TVirtualBranchBrowsable *parent, TClass *&contained);
0081    static std::list<MethodCreateListOfBrowsables_t>& GetRegisteredGenerators();
0082    static void RegisterGenerator(MethodCreateListOfBrowsables_t generator);
0083    static void UnregisterGenerator(MethodCreateListOfBrowsables_t generator);
0084    /** sets the type of this browsable object */
0085    void SetType(TClass* type) { fClass = type; }
0086 
0087    /** sets whether the type of this browsable object is a pointer */
0088    void SetTypeIsPointer(bool set=true) { fTypeIsPointer = set; }
0089 
0090 private:
0091    static void RegisterDefaultGenerators();
0092    const TBranch    *fBranch{nullptr}; ///< pointer to the branch element representing the top object
0093    const TVirtualBranchBrowsable *fParent{nullptr}; ///< parent method if this method is member of a returned class
0094    TList            *fLeaves{nullptr}; ///< pointer to leaves
0095    TClass           *fClass{nullptr};  ///< pointer to TClass representing our type (i.e. return type for methods), 0 if basic type
0096    bool              fTypeIsPointer{false}; ///< return type is pointer to class
0097    static std::list<MethodCreateListOfBrowsables_t> fgGenerators; ///< list of MethodCreateListOfBrowsables_t called by CreateListOfBrowsables
0098    static bool       fgGeneratorsSet; ///< have we set the generators yet? empty is not good enough - user might have removed them
0099    ClassDefOverride(TVirtualBranchBrowsable, 0); ///< Base class for helper objects used for browsing
0100 };
0101 
0102 
0103 class TMethodBrowsable: public TVirtualBranchBrowsable {
0104 public:
0105    ~TMethodBrowsable() override {};
0106 
0107    static Int_t GetBrowsables(TList &list, const TBranch *branch,
0108          const TVirtualBranchBrowsable *parent = nullptr);
0109 
0110    /** return our special icons */
0111    const char* GetIconName() const override
0112    {
0113       if (IsFolder())
0114          return "TMethodBrowsable-branch";
0115       return "TMethodBrowsable-leaf";
0116    }
0117    static bool IsMethodBrowsable(const TMethod *m);
0118    static void Register();
0119    static void Unregister();
0120 
0121 protected:
0122    static void GetBrowsableMethodsForClass(TClass *cl, TList &list);
0123    TMethodBrowsable(const TBranch *branch, TMethod *m,
0124          const TVirtualBranchBrowsable *parent = nullptr);
0125 
0126 private:
0127    TMethod         *fMethod{nullptr}; // pointer to a method
0128    ClassDefOverride(TMethodBrowsable,0); // Helper object to browse methods
0129 };
0130 
0131 
0132 class TNonSplitBrowsable: public TVirtualBranchBrowsable {
0133 public:
0134    ~TNonSplitBrowsable() override {}
0135 
0136    static Int_t GetBrowsables(TList &list, const TBranch *branch,
0137          const TVirtualBranchBrowsable *parent = nullptr);
0138    static void Register();
0139    static void Unregister();
0140 
0141 protected:
0142    TNonSplitBrowsable(const TStreamerElement *element, const TBranch *branch,
0143          const TVirtualBranchBrowsable *parent = nullptr);
0144 
0145 private:
0146    ClassDefOverride(TNonSplitBrowsable, 0); // Helper object to browse unsplit objects
0147 };
0148 
0149 
0150 class TCollectionPropertyBrowsable: public TVirtualBranchBrowsable {
0151 public:
0152    ~TCollectionPropertyBrowsable() override {}
0153 
0154    void Browse(TBrowser *b) override;
0155    static Int_t GetBrowsables(TList &list, const TBranch *branch,
0156          const TVirtualBranchBrowsable *parent = nullptr);
0157    /** return the string passed to TTree::Draw */
0158    const char *GetDraw() const { return fDraw.Data(); }
0159    static void Register();
0160    static void Unregister();
0161 
0162 protected:
0163    /** constructor, which sets the name and title according to the parameters
0164      * (and thus differently than our base class TVirtualBranchBrowsable) */
0165    TCollectionPropertyBrowsable(const char *name, const char *title,
0166          const char *draw, const TBranch *branch,
0167          const TVirtualBranchBrowsable *parent = nullptr) :
0168          TVirtualBranchBrowsable(branch, nullptr, false, parent), fDraw(draw)
0169    {
0170       SetNameTitle(name, title);
0171    }
0172 
0173 private:
0174    TString fDraw; // string to send to TTree::Draw(), NOT by GetScope()!
0175    ClassDefOverride(TCollectionPropertyBrowsable, 0); // Helper object to add browsable collection properties
0176 };
0177 
0178 class TCollectionMethodBrowsable: public TMethodBrowsable {
0179 public:
0180    ~TCollectionMethodBrowsable() override {};
0181 
0182    static Int_t GetBrowsables(TList &list, const TBranch *branch,
0183          const TVirtualBranchBrowsable *parent = nullptr);
0184    static void Register();
0185    static void Unregister();
0186 
0187 protected:
0188    TCollectionMethodBrowsable(const TBranch* branch, TMethod* m,
0189       const TVirtualBranchBrowsable* parent = nullptr);
0190 
0191    ClassDefOverride(TCollectionMethodBrowsable,0); // Helper object to browse a collection's methods
0192 };
0193 
0194 #endif // defined ROOT_TBranchBrowsable