Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RLevelIter.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, 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
10
13
14using namespace ROOT::Experimental::Browsable;
15
16/////////////////////////////////////////////////////////////////////
17/// Find item with specified name
18/// Default implementation, should work for all
19/// If index specified, not only name but also index should match
20
21bool RLevelIter::Find(const std::string &name, int indx)
22{
23 int i = -1;
24
25 while (Next()) {
26 if (indx >= 0) {
27 i++;
28 if (i > indx) return false;
29 if (i < indx) continue;
30 }
31
32 std::string iname = GetItemName();
33 if (iname.empty())
34 iname = "<empty>";
35
36 if (iname == name)
37 return true;
38 }
39
40 return false;
41}
42
43/////////////////////////////////////////////////////////////////////
44/// Create generic description item for RBrowser
45
46std::unique_ptr<RItem> RLevelIter::CreateItem()
47{
48 std::string name = GetItemName();
49 if (name.empty())
50 name = "<empty>";
51
52 bool have_childs = CanItemHaveChilds();
53
54 return std::make_unique<RItem>(name, have_childs ? -1 : 0, have_childs ? "sap-icon://folder-blank" : "sap-icon://document");
55}
56
char name[80]
Definition TGX11.cxx:110
virtual bool Next()=0
Shift to next entry.
virtual std::unique_ptr< RItem > CreateItem()
Create generic description item for RBrowser.
virtual bool Find(const std::string &name, int indx=-1)
Find item with specified name Default implementation, should work for all If index specified,...
virtual std::string GetItemName() const =0
Returns current entry name
virtual bool CanItemHaveChilds() const
Returns true if current item can have childs.