GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Iter.cxx
Go to the documentation of this file.
1 // $Id: TGo4Iter.cxx 2740 2020-04-15 21:02:30Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4Iter.h"
15 
16 #include "TGo4Slot.h"
17 
20  fSlot(0),
21  fLevels(),
22  fStatus(-1),
23  fFullName(),
24  fLevelChange(0)
25 {
26 }
27 
28 TGo4Iter::TGo4Iter(TGo4Slot* slot, Bool_t onlyslots) :
30  fSlot(slot),
31  fOnlySlots(onlyslots),
32  fLevels(),
33  fStatus(-1),
34  fFullName(),
35  fLevelChange(0)
36 {
37 }
38 
40 {
41  fLevels.Delete();
42 }
43 
44 Bool_t TGo4Iter::next(Bool_t goesinto)
45 {
46  fLevelChange = 0;
47 
48  if (fStatus==1) return kFALSE;
49 
50  Int_t lastlevel = level();
51 
52  TGo4LevelIter* iter = 0;
53 
54  Bool_t wasfolder = kFALSE;
55 
56  if (fStatus==-1) {
57  iter = (fSlot==0) ? 0 : fSlot->MakeLevelIter();
58  if (iter!=0) fLevels.Add(iter);
59  } else {
60  iter = (TGo4LevelIter*) fLevels.Last();
61 
62  wasfolder = fOnlySlots ? iter->isslotsfolder() : iter->isfolder();
63 
64  if ((iter!=0) && wasfolder && goesinto) {
65  TGo4LevelIter* subiter = iter->subiterator();
66  if (subiter!=0) {
67  fLevels.Add(subiter);
68  iter = subiter;
69  }
70  }
71  }
72 
73  while ((iter!=0) && !iter->next()) {
74  fLevels.Remove(iter);
75  delete iter;
76  iter = (TGo4LevelIter*) fLevels.Last();
77  }
78 
79  fFullName = "";
80 
81  if (iter!=0)
82  for(int n=0;n<=fLevels.GetLast();n++) {
83  TGo4LevelIter* it = (TGo4LevelIter*) fLevels.At(n);
84  if (n>0) fFullName.Append("/");
85  fFullName.Append(it->name());
86  }
87 
88  fStatus = (iter!=0) ? 0 : 1;
89 
90  fLevelChange = level() - lastlevel;
91 
92  // Bool_t isfolder = kFALSE;
93  // if (iter!=0) isfolder = fOnlySlots ? iter->isslotsfolder() : iter->isfolder();
94  // if (isfolder && wasfolder) fLevelChange--;
95 
96  if (wasfolder) fLevelChange--;
97 
98  return (fStatus==0);
99 }
100 
102 {
103  while (next())
104  if (!isfolder()) return kTRUE;
105  return kFALSE;
106 }
107 
109 {
110  TGo4LevelIter* iter = currentiter();
111  return (iter==0) ? kFALSE : (fOnlySlots ? iter->isslotsfolder() : iter->isfolder());
112 }
113 
114 const char* TGo4Iter::getname()
115 {
116  TGo4LevelIter* iter = currentiter();
117  return iter==0 ? 0 : iter->name();
118 }
119 
120 const char* TGo4Iter::getinfo()
121 {
122  TGo4LevelIter* iter = currentiter();
123  return iter==0 ? 0 : iter->info();
124 }
125 
127 {
128  TGo4LevelIter* iter = currentiter();
129  return iter==0 ? 0 : iter->sizeinfo();
130 }
131 
132 Int_t TGo4Iter::getflag(const char* flagname)
133 {
134  TGo4LevelIter* iter = currentiter();
135  return ((iter==0) || (flagname==0)) ? -1 : iter->getflag(flagname);
136 }
137 
139 {
140  TGo4LevelIter* iter = currentiter();
141  return iter==0 ? -1 : iter->GetKind();
142 }
143 
145 {
146  TGo4LevelIter* iter = currentiter();
147  return iter==0 ? 0 : iter->GetClassName();
148 }
149 
150 
152 {
153  return (fStatus!=0) ? 0 : fFullName.Data();
154 }
155 
156 Int_t TGo4Iter::level() const
157 {
158  return (fStatus!=0) ? -1 : fLevels.GetLast();
159 }
160 
162 {
163  return (fStatus!=0) ? 0 : fSlot->ProvideSlotAccess(fFullName.Data());
164 }
165 
167 {
168  if (fStatus!=0) return 0;
169  TGo4LevelIter* iter = (TGo4LevelIter*) fLevels.Last();
170  return iter==0 ? 0 : iter->getslot();
171 }
virtual const char * GetClassName()
Definition: TGo4Proxy.h:88
virtual Int_t sizeinfo()
Definition: TGo4Proxy.h:85
const char * getinfo()
Definition: TGo4Iter.cxx:120
virtual Bool_t isslotsfolder()
Definition: TGo4Proxy.h:79
Int_t level() const
Definition: TGo4Iter.cxx:156
Bool_t nextobj()
Definition: TGo4Iter.cxx:101
TObjArray fLevels
Definition: TGo4Iter.h:55
virtual ~TGo4Iter()
Definition: TGo4Iter.cxx:39
TGo4Slot * fSlot
Definition: TGo4Iter.h:53
Bool_t isfolder()
Definition: TGo4Iter.cxx:108
TGo4LevelIter * MakeLevelIter() const
Definition: TGo4Slot.cxx:397
virtual Bool_t next()
Definition: TGo4Proxy.h:77
TGo4Slot * getslot() const
Definition: TGo4Iter.cxx:166
virtual Int_t getflag(const char *)
Definition: TGo4Proxy.h:80
virtual const char * name()
Definition: TGo4Proxy.h:83
TGo4Iter()
Definition: TGo4Iter.cxx:18
const char * getclassname()
Definition: TGo4Iter.cxx:144
Int_t getflag(const char *flagname)
Definition: TGo4Iter.cxx:132
virtual TGo4Access * ProvideAccess(const char *name=0)
Definition: TGo4Iter.cxx:161
const char * getfullname()
Definition: TGo4Iter.cxx:151
Int_t fStatus
Definition: TGo4Iter.h:56
Int_t getkindofitem()
Definition: TGo4Iter.cxx:138
virtual TGo4LevelIter * subiterator()
Definition: TGo4Proxy.h:81
Bool_t fOnlySlots
Definition: TGo4Iter.h:54
const char * getname()
Definition: TGo4Iter.cxx:114
virtual const char * info()
Definition: TGo4Proxy.h:84
virtual Int_t GetKind()
Definition: TGo4Proxy.h:87
virtual Bool_t isfolder()
Definition: TGo4Proxy.h:78
virtual TGo4Slot * getslot()
Definition: TGo4Proxy.h:82
TString fFullName
-1 start, 0 continue, 1 end
Definition: TGo4Iter.h:57
Int_t fLevelChange
Definition: TGo4Iter.h:58
TGo4Access * ProvideSlotAccess(const char *name)
Definition: TGo4Slot.cxx:409
TGo4LevelIter * currentiter() const
Definition: TGo4Iter.h:50
Bool_t next(Bool_t goesinto=kTRUE)
Definition: TGo4Iter.cxx:44
Int_t getsizeinfo()
Definition: TGo4Iter.cxx:126