GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitSlot.h
Go to the documentation of this file.
1 // $Id$
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 #ifndef TGO4FITSLOT_H
15 #define TGO4FITSLOT_H
16 
17 #include "TGo4FitNamed.h"
18 
19 class TSeqCollection;
20 class TObjArray;
21 
27 class TGo4FitSlot : public TGo4FitNamed {
28  public:
29 
33  TGo4FitSlot();
34 
41  TGo4FitSlot(TNamed *iOwner, TClass *iClass);
42 
49  TGo4FitSlot(const char *iName, const char *iTitle,
50  TNamed *iOwner, TClass *iClass,
51  Bool_t iNeeded = kFALSE, TObject *iObject = nullptr, Bool_t iOwned = kFALSE);
52 
56  virtual ~TGo4FitSlot();
57 
61  TClass *GetClass() const { return fxClass; }
62 
67  void SetDefaults(TNamed *iOwner, TClass *iClass);
68 
75  void SetSaveFlag(Int_t iSaveFlag) { fiSaveFlag = iSaveFlag; }
76 
80  Int_t GetSaveFlag() const { return fiSaveFlag; }
81 
85  Bool_t IsSuitable(TObject *obj) const;
86 
90  Bool_t IsSuitableClass(TClass *cl) const;
91 
96  void ClearObject();
97 
105  Bool_t SetObject(TObject *iObject, Bool_t iOwned = kFALSE, Bool_t CheckClass = kTRUE);
106 
113  Bool_t ConnectToSlot(TGo4FitSlot *slot);
114 
118  Bool_t CanConnectToSlot(TGo4FitSlot *slot);
119 
123  TGo4FitSlot *GetConnectedSlot() const { return !fbOwned && fbConnected && fxObject ? dynamic_cast<TGo4FitSlot *>(fxObject) : nullptr; }
124 
128  Bool_t IsConnectedToSlot() const { return GetConnectedSlot() != nullptr; }
129 
133  void ClearConnectionToSlot();
134 
138  TObject *GetObject() const;
139 
143  const char *GetObjectName() const;
144 
149  TObject *CloneObject(const char *newname = nullptr);
150 
155  void Clear(Option_t * = "") override { SetObject(nullptr, kFALSE); }
156 
160  Bool_t GetOwned() const { return fbOwned; }
161 
166  void SetOwned(Bool_t iOwned = kTRUE) { fbOwned = iOwned; }
167 
172  Bool_t GetNeeded() const { return fbNeeded; }
173 
177  void SetNeeded(Bool_t iNeeded) { fbNeeded = iNeeded; }
178 
182  Bool_t IsEmpty() const { return GetObject() == nullptr; }
183 
187  Bool_t IsObject() const { return GetObject() != nullptr; }
188 
192  Bool_t IsRequired() const { return fbNeeded && IsEmpty(); }
193 
197  void Print(Option_t *option = "") const override;
198 
199  protected:
200 
201  friend class TGo4FitSlotList;
202 
203  void SetSaveSettings(Int_t save = -1, Int_t own = -1);
204 
205  Bool_t HasSaveSettings();
206 
207  Bool_t WillBeSaved();
208 
214  void CheckOwnership();
215 
219  TClass *fxClass{nullptr};
220 
224  Int_t fiSaveFlag{0};
225 
226 
230  Bool_t fbOwned{kFALSE};
231 
235  Bool_t fbConnected{kFALSE};
236 
240  Bool_t fbNeeded{kFALSE};
241 
245  TObject *fxObject{nullptr};
246 
247  Int_t fiSaveSlot{0};
248  Int_t fiSaveOwnership{0};
249 
250  ClassDefOverride(TGo4FitSlot,1)
251 };
252 
253 
254 //************************************************************************************************
255 
257  public:
258  TGo4FitSlotList();
259  virtual ~TGo4FitSlotList();
260 
265  virtual void FillSlotList(TSeqCollection *lst);
266 
270  void SetUpdateSlotList();
271 
277  const TObjArray *GetSlotList(Bool_t ForceUpdate = kFALSE);
278 
282  Int_t NumSlots();
283 
287  TGo4FitSlot *GetSlot(Int_t nslot);
288 
292  TGo4FitSlot *FindSlot(const char *FullSlotName);
293 
298  Bool_t ConnectSlots(TGo4FitSlot *slot1, TGo4FitSlot *slot2);
299 
304  Bool_t ConnectSlots(const char *Slot1FullName, const char *Slot2FullName);
305 
311  TGo4FitSlot *SetObject(TObject *obj, Bool_t iOwned = kFALSE);
312 
320  TGo4FitSlot *SetObject(const char *PlaceName, TObject *obj, Bool_t iOwned = kFALSE);
321 
326  TGo4FitSlot *IsObjectInSlots(TObject *obj);
327 
331  Bool_t CheckObjects(Bool_t MakeOut = kTRUE);
332 
336  Bool_t IsEmptySlots();
337 
344  void ClearObjects(const char *PlaceName = nullptr, Bool_t NonOwned = kTRUE);
345 
351  void ClearSlot(TGo4FitSlot *slot, Bool_t NonOwned);
352 
361  void SetSaveFlagForObjects(Int_t iSaveFlag, const char *PlaceName = nullptr);
362 
363  protected:
364 
368  void CheckDuplicatesOnSlot();
369 
370  void PrepareSlotsForWriting();
371 
372  TObjArray *fxSlotList{nullptr};
373  Bool_t fbUpdateSlotList{kFALSE};
374 
375 
376  ClassDef(TGo4FitSlotList,1);
377 
378 };
379 
380 #endif // TGO4FITSLOT_H
381 
void SetSaveSettings(Int_t save=-1, Int_t own=-1)
Bool_t fbOwned
0 - slot save if owned(default), 1 - saved always, 2 - saved never
Definition: TGo4FitSlot.h:230
void SetNeeded(Bool_t iNeeded)
Definition: TGo4FitSlot.h:177
void Print(Option_t *option="") const override
Bool_t GetNeeded() const
Definition: TGo4FitSlot.h:172
friend class TGo4FitSlotList
Definition: TGo4FitSlot.h:201
virtual ~TGo4FitSlot()
Definition: TGo4FitSlot.cxx:43
void ClearConnectionToSlot()
Definition: TGo4FitSlot.cxx:83
Bool_t IsObject() const
Definition: TGo4FitSlot.h:187
TObject * CloneObject(const char *newname=nullptr)
void SetSaveFlag(Int_t iSaveFlag)
Definition: TGo4FitSlot.h:75
Int_t fiSaveSlot
Definition: TGo4FitSlot.h:247
Bool_t HasSaveSettings()
TClass * fxClass
Definition: TGo4FitSlot.h:219
Int_t fiSaveFlag
Definition: TGo4FitSlot.h:224
Bool_t fbNeeded
Definition: TGo4FitSlot.h:240
const char * GetObjectName() const
TClass * GetClass() const
Definition: TGo4FitSlot.h:61
TGo4FitSlot * GetConnectedSlot() const
Definition: TGo4FitSlot.h:123
void CheckOwnership()
Bool_t IsEmpty() const
Definition: TGo4FitSlot.h:182
Bool_t SetObject(TObject *iObject, Bool_t iOwned=kFALSE, Bool_t CheckClass=kTRUE)
Bool_t IsSuitable(TObject *obj) const
Definition: TGo4FitSlot.cxx:92
TObject * fxObject
Definition: TGo4FitSlot.h:245
Bool_t fbConnected
Definition: TGo4FitSlot.h:235
Bool_t IsRequired() const
Definition: TGo4FitSlot.h:192
Bool_t ConnectToSlot(TGo4FitSlot *slot)
Definition: TGo4FitSlot.cxx:58
Bool_t IsConnectedToSlot() const
Definition: TGo4FitSlot.h:128
void SetDefaults(TNamed *iOwner, TClass *iClass)
Definition: TGo4FitSlot.cxx:52
Bool_t WillBeSaved()
TObject * GetObject() const
void Clear(Option_t *="") override
Definition: TGo4FitSlot.h:155
void ClearObject()
Bool_t GetOwned() const
Definition: TGo4FitSlot.h:160
Int_t fiSaveOwnership
Definition: TGo4FitSlot.h:248
Int_t GetSaveFlag() const
Definition: TGo4FitSlot.h:80
void SetOwned(Bool_t iOwned=kTRUE)
Definition: TGo4FitSlot.h:166
Bool_t IsSuitableClass(TClass *cl) const
Bool_t CanConnectToSlot(TGo4FitSlot *slot)
Definition: TGo4FitSlot.cxx:70