Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBranchBrowseProvider.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
12
13#include "TTree.h"
14#include "TNtuple.h"
15#include "TBranch.h"
16#include "TBranchElement.h"
17#include "TBranchBrowsable.h"
18
19using namespace ROOT::Experimental::Browsable;
20
21
22////////////////////////////////////////////////////////////
23/// Representing TBranch in browsables
24
25class TBrElement : public TObjectElement {
26
27public:
28 TBrElement(std::unique_ptr<RHolder> &br) : TObjectElement(br) {}
29
30 Long64_t GetSize() const override
31 {
32 auto br = fObject->Get<TBranch>();
33 return br ? br->GetTotalSize() : -1;
34 }
35};
36
37////////////////////////////////////////////////////////////
38/// Representing TTree in browsables
39
41
42public:
43 TTreeElement(std::unique_ptr<RHolder> &br) : TObjectElement(br) {}
44
45 Long64_t GetSize() const override
46 {
47 auto tr = fObject->Get<TTree>();
48 printf("Return TTree size %ld\n", (long) (tr ? tr->GetTotBytes() : -1));
49 return tr ? tr->GetTotBytes() : -1;
50 }
51};
52
53
54////////////////////////////////////////////////////////////
55/// Representing TVirtualBranchBrowsable in browsables
56
58
59public:
60 TBrBrowsableElement(std::unique_ptr<RHolder> &br) : TObjectElement(br) {}
61
62 virtual ~TBrBrowsableElement() = default;
63
64 int GetNumChilds() override
65 {
66 auto br = fObject->Get<TVirtualBranchBrowsable>();
67 return br && br->GetLeaves() ? br->GetLeaves()->GetSize() : 0;
68 }
69
70 /** Create iterator for childs elements if any */
71 std::unique_ptr<RLevelIter> GetChildsIter() override
72 {
73 auto br = fObject->Get<TVirtualBranchBrowsable>();
74 if (br && br->GetLeaves())
75 return GetCollectionIter(br->GetLeaves());
76 return nullptr;
77 }
78};
79
80
81// ==============================================================================================
82
84
85public:
87 {
88 RegisterBrowse(TBranch::Class(), [](std::unique_ptr<RHolder> &object) -> std::shared_ptr<RElement> {
89 return std::make_shared<TBrElement>(object);
90 });
91 RegisterBrowse(TBranchElement::Class(), [](std::unique_ptr<RHolder> &object) -> std::shared_ptr<RElement> {
92 return std::make_shared<TBrElement>(object);
93 });
94 RegisterBrowse(TTree::Class(), [](std::unique_ptr<RHolder> &object) -> std::shared_ptr<RElement> {
95 return std::make_shared<TTreeElement>(object);
96 });
97 RegisterBrowse(TNtuple::Class(), [](std::unique_ptr<RHolder> &object) -> std::shared_ptr<RElement> {
98 return std::make_shared<TTreeElement>(object);
99 });
100 }
101
long long Long64_t
Definition RtypesCore.h:80
TBranchBrowseProvider newTBranchBrowseProvider
Provider of different browsing methods for supported classes.
Definition RProvider.hxx:36
void RegisterBrowse(const TClass *cl, BrowseFunc_t func)
Access to TObject basic properties for RBrowsable.
static std::unique_ptr< RLevelIter > GetCollectionIter(const TCollection *)
Creates iterator for TCollection object.
Representing TVirtualBranchBrowsable in browsables.
TBrBrowsableElement(std::unique_ptr< RHolder > &br)
std::unique_ptr< RLevelIter > GetChildsIter() override
Create iterator for childs elements if any.
int GetNumChilds() override
Returns number of childs By default creates iterator and iterates over all items.
virtual ~TBrBrowsableElement()=default
Representing TBranch in browsables.
Long64_t GetSize() const override
Size of TObject.
TBrElement(std::unique_ptr< RHolder > &br)
A TTree is a list of TBranches.
Definition TBranch.h:89
Long64_t GetTotalSize(Option_t *option="") const
Return total number of bytes in the branch (including current buffer)
Definition TBranch.cxx:2139
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Representing TTree in browsables.
Long64_t GetSize() const override
Size of TObject.
TTreeElement(std::unique_ptr< RHolder > &br)
A TTree represents a columnar dataset.
Definition TTree.h:79
TVirtualBranchBrowsable is a base class (not really abstract, but useless by itself) for helper objec...
TList * GetLeaves() const
Return list of leaves. If not set up yet we'll create them.