GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4BrowserItem.cxx
Go to the documentation of this file.
1 // $Id: TGo4BrowserItem.cxx 2753 2020-04-16 11:04:26Z 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 "TGo4BrowserItem.h"
15 
16 #include "TGo4BrowserProxy.h"
17 #include "TGo4RootBrowserProxy.h"
18 #include "TGo4Iter.h"
19 #include "TGo4Slot.h"
20 #include "TGo4ServerProxy.h"
21 
22 #include "TGo4Interface.h"
23 
25  TFolder(),
26  fParent(0),
27  fIter(0),
28  fItemClass(),
29  fIsFolder(kFALSE),
30  fBrowser(0)
31 {
32 }
33 
34 TGo4BrowserItem::TGo4BrowserItem(const char* name, const char* title) :
35  TFolder(name, title),
36  fParent(0),
37  fIter(0),
38  fItemClass(),
39  fIsFolder(kTRUE),
40  fBrowser(0)
41 {
42  SetOwner(kTRUE);
43 }
44 
46  const char* name, const char* title) :
47  TFolder(name, title),
48  fParent(parent),
49  fIter(0),
50  fItemClass(),
51  fIsFolder(kTRUE),
52  fBrowser(0)
53 {
54  SetOwner(kTRUE);
55  if (parent!=0) {
56  TList* list = (TList*) parent->GetListOfFolders();
57  if (previtem==0) list->AddFirst(this);
58  else list->AddAfter(previtem, this);
59  }
60 }
61 
63 {
64  if (fIter!=0) delete fIter;
65 }
66 
68 {
69  fBrowser = br;
70  fRootBrowser = br2;
71 }
72 
73 
75 {
76  if (fIter!=0) delete fIter;
77  fIter = GetListOfFolders()->MakeIterator();
78  return (TGo4BrowserItem*) fIter->Next();
79 }
80 
82 {
83  if (fIter==0) return 0;
84  TGo4BrowserItem* res = dynamic_cast<TGo4BrowserItem*> (fIter->Next());
85  if (res==0) { delete fIter; fIter = 0; }
86  return res;
87 }
88 
90 {
91  if (item==0) return;
92  Remove(item);
93  delete item;
94 }
95 
97 {
98  if (fIter!=0) { delete fIter; fIter = 0; }
99  GetListOfFolders()->Delete();
100 }
101 
102 void TGo4BrowserItem::ProduceFullName(TString& fullname)
103 {
104  if (GetParent()!=0) {
105  GetParent()->ProduceFullName(fullname);
106  if (fullname.Length()>0) fullname+="/";
107  fullname += GetName();
108  } else
109  fullname = "";
110 }
111 
113 {
114  TString res;
115  ProduceFullName(res);
116  return res;
117 
118 }
119 
120 void TGo4BrowserItem::Browse(TBrowser* b)
121 {
122  if (IsFolder()) TFolder::Browse(b);
123 
124  DrawItem();
125 }
126 
128 {
129  TString itemname;
130 
131  ProduceFullName(itemname);
132 
133  fRootBrowser->DrawItem(itemname.Data());
134 }
135 
137 {
138  TString itemname;
139  ProduceFullName(itemname);
140  if ((itemname.Length()==0) || (fBrowser==0)) return;
141 
142  fBrowser->ProduceExplicitCopy(itemname.Data(), 0, kTRUE);
143 }
144 
146 {
147  if (GetParent()==0) {
149  return;
150  }
151 
152 
153  TString itemname;
154  ProduceFullName(itemname);
155  if ((itemname.Length()==0) || (fBrowser==0)) return;
156 
157  TGo4Slot* itemslot = fBrowser->ItemSlot(itemname.Data());
158  if (itemslot==0) return;
159 
160  TGo4Slot* memslot = fBrowser->BrowserMemorySlot();
161 
162  if (fBrowser->IsCanDelete(itemslot) || itemslot->IsParent(memslot))
163  fBrowser->DeleteDataSource(itemslot);
164 }
165 
167 {
168  SetMonitorFlag(kTRUE);
169 }
170 
172 {
173  SetMonitorFlag(kFALSE);
174 }
175 
177 {
178  TString itemname;
179  ProduceFullName(itemname);
180  if ((itemname.Length()==0) || (fBrowser==0)) return;
181 
182  TGo4Slot* itemslot = fBrowser->ItemSlot(itemname.Data());
183  if (itemslot==0) return;
184  int kind = fBrowser->ItemKind(itemslot);
185 
186  if (kind==TGo4Access::kndFolder) {
187  TGo4Iter iter(itemslot, kTRUE);
188  while (iter.next()) {
189  TGo4Slot* subslot = iter.getslot();
190  if (fBrowser->ItemKind(subslot)==TGo4Access::kndObject)
191  fBrowser->SetItemMonitored(subslot, on);
192  }
193  } else
194  fBrowser->SetItemMonitored(itemslot, on);
195 }
196 
197 
199 {
200  if (fBrowser!=0)
201  fBrowser->ToggleMonitoring(sec*1000);
202 }
203 
205 {
207  if (anal!=0)
208  anal->StartAnalysis();
209 }
210 
212 {
214  if (anal!=0)
215  anal->StopAnalysis();
216 }
217 
218 
219 void TGo4BrowserItem::Delete(Option_t* option)
220 {
221  DeleteItem();
222 }
223 
224 void TGo4BrowserItem::SetName(const char* name)
225 {
226  TFolder::SetName(name);
227 }
228 
229 void TGo4BrowserItem::SetTitle(const char* title)
230 {
231  TFolder::SetTitle(title);
232 }
233 
234 void TGo4BrowserItem::ls(Option_t* option) const
235 {
236  TFolder::ls(option);
237 }
238 
239 #if ROOT_VERSION_CODE < ROOT_VERSION(5,13,6)
240 void TGo4BrowserItem::SaveAs(const char* filename)
241 {
242  TFolder::SaveAs(filename);
243 }
244 #else
245 void TGo4BrowserItem::SaveAs(const char* filename, Option_t *option) const
246 {
247  TFolder::SaveAs(filename, option);
248 }
249 #endif
250 
252 {
253  TFolder::DrawClass();
254 }
255 
256 TObject* TGo4BrowserItem::DrawClone(Option_t* option) const
257 {
258  return TFolder::DrawClone(option);
259 }
260 
262 {
263  TFolder::Dump();
264 }
265 
267 {
268  TFolder::Inspect();
269 }
270 
271 void TGo4BrowserItem::SetDrawOption(Option_t* option)
272 {
273  TFolder::SetDrawOption(option);
274 }
275 
void deleteChild(TGo4BrowserItem *item)
TGo4BrowserItem * GetParent() const
virtual void DrawItem()
virtual void SetTitle(const char *title="")
TIterator * fIter
virtual void Browse(TBrowser *b)
virtual ~TGo4BrowserItem()
Int_t ItemKind(const char *name)
TGo4BrowserProxy * fBrowser
TGo4RootBrowserProxy * fRootBrowser
TGo4Slot * getslot() const
Definition: TGo4Iter.cxx:166
Bool_t DeleteDataSource(TGo4Slot *itemslot)
virtual void SetName(const char *name)
virtual void ls(Option_t *option="*") const
virtual void SaveAs(const char *filename="", Option_t *option="") const
TGo4ServerProxy * FindServer(const char *itemname=0, Bool_t asanalysis=kTRUE)
virtual void StartAnalysis()
virtual Bool_t IsFolder() const
virtual void StartAnalysis()
virtual void DrawClass() const
Bool_t IsCanDelete(TGo4Slot *slot)
virtual void Inspect() const
Bool_t IsParent(const TGo4Slot *slot) const
Definition: TGo4Slot.cxx:194
virtual void ToggleMonitoring(Int_t sec)
void SetMonitorFlag(Bool_t on)
virtual void StopAnalysis()
virtual void Delete(Option_t *option="")
virtual void SetMonitorOff()
void SetItemMonitored(TGo4Slot *slot, Bool_t on=kTRUE)
TGo4Slot * BrowserMemorySlot()
Bool_t ProduceExplicitCopy(const char *itemname, const char *tgtpath=0, Bool_t forcerequest=kFALSE)
TGo4BrowserItem * nextChild()
void DrawItem(const char *itemname)
virtual void SetMonitorOn()
virtual void Dump() const
virtual void StopAnalysis()
virtual void CopyToWorkspace()
virtual void SetDrawOption(Option_t *option="")
void SetBrowser(TGo4BrowserProxy *br, TGo4RootBrowserProxy *br2)
virtual TObject * DrawClone(Option_t *option="") const
virtual void DeleteItem()
TGo4Slot * ItemSlot(const char *itemname)
void ProduceFullName(TString &fullname)
void ToggleMonitoring(Int_t period)
Bool_t next(Bool_t goesinto=kTRUE)
Definition: TGo4Iter.cxx:44
TGo4BrowserItem * firstChild()