GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Iter.cxx
Go to the documentation of this file.
1 // $Id: TGo4Iter.cxx 1037 2013-11-06 13:39:24Z 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 für 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 #include "TGo4Proxy.h"
18 
21  fSlot(0),
22  fLevels(),
23  fStatus(-1),
24  fFullName(),
25  fLevelChange(0)
26 {
27 }
28 
29 TGo4Iter::TGo4Iter(TGo4Slot* slot, Bool_t onlyslots) :
31  fSlot(slot),
32  fOnlySlots(onlyslots),
33  fLevels(),
34  fStatus(-1),
35  fFullName(),
36  fLevelChange(0)
37 {
38 }
39 
41 {
42  fLevels.Delete();
43 }
44 
45 Bool_t TGo4Iter::next(Bool_t goesinto)
46 {
47  fLevelChange = 0;
48 
49  if (fStatus==1) return kFALSE;
50 
51  Int_t lastlevel = level();
52 
53  TGo4LevelIter* iter = 0;
54 
55  Bool_t wasfolder = kFALSE;
56 
57  if (fStatus==-1) {
58  iter = (fSlot==0) ? 0 : fSlot->MakeLevelIter();
59  if (iter!=0) fLevels.Add(iter);
60  } else {
61  iter = (TGo4LevelIter*) fLevels.Last();
62 
63  wasfolder = fOnlySlots ? iter->isslotsfolder() : iter->isfolder();
64 
65  if ((iter!=0) && wasfolder && goesinto) {
66  TGo4LevelIter* subiter = iter->subiterator();
67  if (subiter!=0) {
68  fLevels.Add(subiter);
69  iter = subiter;
70  }
71  }
72  }
73 
74  while ((iter!=0) && !iter->next()) {
75  fLevels.Remove(iter);
76  delete iter;
77  iter = (TGo4LevelIter*) fLevels.Last();
78  }
79 
80  fFullName = "";
81 
82  if (iter!=0)
83  for(int n=0;n<=fLevels.GetLast();n++) {
84  TGo4LevelIter* it = (TGo4LevelIter*) fLevels.At(n);
85  if (n>0) fFullName.Append("/");
86  fFullName.Append(it->name());
87  }
88 
89  fStatus = (iter!=0) ? 0 : 1;
90 
91  fLevelChange = level() - lastlevel;
92 
93  // Bool_t isfolder = kFALSE;
94  // if (iter!=0) isfolder = fOnlySlots ? iter->isslotsfolder() : iter->isfolder();
95  // if (isfolder && wasfolder) fLevelChange--;
96 
97  if (wasfolder) fLevelChange--;
98 
99  return (fStatus==0);
100 }
101 
103 {
104  while (next())
105  if (!isfolder()) return kTRUE;
106  return kFALSE;
107 }
108 
110 {
111  TGo4LevelIter* iter = currentiter();
112  return (iter==0) ? kFALSE : (fOnlySlots ? iter->isslotsfolder() : iter->isfolder());
113 }
114 
115 const char* TGo4Iter::getname()
116 {
117  TGo4LevelIter* iter = currentiter();
118  return iter==0 ? 0 : iter->name();
119 }
120 
121 const char* TGo4Iter::getinfo()
122 {
123  TGo4LevelIter* iter = currentiter();
124  return iter==0 ? 0 : iter->info();
125 }
126 
128 {
129  TGo4LevelIter* iter = currentiter();
130  return iter==0 ? 0 : iter->sizeinfo();
131 }
132 
133 Int_t TGo4Iter::getflag(const char* flagname)
134 {
135  TGo4LevelIter* iter = currentiter();
136  return ((iter==0) || (flagname==0)) ? -1 : iter->getflag(flagname);
137 }
138 
140 {
141  TGo4LevelIter* iter = currentiter();
142  return iter==0 ? -1 : iter->GetKind();
143 }
144 
146 {
147  TGo4LevelIter* iter = currentiter();
148  return iter==0 ? 0 : iter->GetClassName();
149 }
150 
151 
153 {
154  return (fStatus!=0) ? 0 : fFullName.Data();
155 }
156 
157 Int_t TGo4Iter::level() const
158 {
159  return (fStatus!=0) ? -1 : fLevels.GetLast();
160 }
161 
163 {
164  return (fStatus!=0) ? 0 : fSlot->ProvideSlotAccess(fFullName.Data());
165 }
166 
168 {
169  if (fStatus!=0) return 0;
170  TGo4LevelIter* iter = (TGo4LevelIter*) fLevels.Last();
171  return iter==0 ? 0 : iter->getslot();
172 }
virtual const char * GetClassName()
Definition: TGo4Proxy.h:88
virtual Int_t sizeinfo()
Definition: TGo4Proxy.h:85
const char * getinfo()
Definition: TGo4Iter.cxx:121
virtual Bool_t isslotsfolder()
Definition: TGo4Proxy.h:79
Int_t level() const
Definition: TGo4Iter.cxx:157
Bool_t nextobj()
Definition: TGo4Iter.cxx:102
TObjArray fLevels
Definition: TGo4Iter.h:56
virtual ~TGo4Iter()
Definition: TGo4Iter.cxx:40
TGo4Slot * fSlot
Definition: TGo4Iter.h:54
Bool_t isfolder()
Definition: TGo4Iter.cxx:109
TGo4LevelIter * MakeLevelIter() const
Definition: TGo4Slot.cxx:401
virtual Bool_t next()
Definition: TGo4Proxy.h:77
TGo4Slot * getslot() const
Definition: TGo4Iter.cxx:167
virtual Int_t getflag(const char *)
Definition: TGo4Proxy.h:80
virtual const char * name()
Definition: TGo4Proxy.h:83
TGo4Iter()
Definition: TGo4Iter.cxx:19
const char * getclassname()
Definition: TGo4Iter.cxx:145
Int_t getflag(const char *flagname)
Definition: TGo4Iter.cxx:133
virtual TGo4Access * ProvideAccess(const char *name=0)
Definition: TGo4Iter.cxx:162
const char * getfullname()
Definition: TGo4Iter.cxx:152
Int_t fStatus
Definition: TGo4Iter.h:57
Int_t getkindofitem()
Definition: TGo4Iter.cxx:139
virtual TGo4LevelIter * subiterator()
Definition: TGo4Proxy.h:81
Bool_t fOnlySlots
Definition: TGo4Iter.h:55
const char * getname()
Definition: TGo4Iter.cxx:115
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:58
Int_t fLevelChange
Definition: TGo4Iter.h:59
TGo4Access * ProvideSlotAccess(const char *name)
Definition: TGo4Slot.cxx:413
TGo4LevelIter * currentiter() const
Definition: TGo4Iter.h:51
Bool_t next(Bool_t goesinto=kTRUE)
Definition: TGo4Iter.cxx:45
Int_t getsizeinfo()
Definition: TGo4Iter.cxx:127