GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4Slot.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 TGO4SLOT_H
15 #define TGO4SLOT_H
16 
17 #include "TNamed.h"
18 #include "TObjArray.h"
19 #include "TGo4Proxy.h"
20 
21 class TClass;
22 class TDirectory;
23 class TGo4ObjectManager;
24 
25 class TGo4Slot : public TNamed {
26  protected:
27 
28  enum ESlotBits {
29  kStartDelete = BIT(23)
30  };
31 
32  void CleanProxy();
33 
34  void AddChild(TGo4Slot *child);
35  void RemoveChild(TGo4Slot *child);
36 
37  TGo4Slot *fParent{nullptr};
38  TObjArray *fChilds{nullptr};
39  TObjArray fPars;
40  TGo4Proxy *fProxy{nullptr};
41  Int_t fAssignFlag{-1};
42  Int_t fAssignCnt{0};
43 
44  public:
45  enum { evDelete = 0,
46  evCreate = 1,
51  evObjDeleted = 6 };
52 
53  TGo4Slot();
54  TGo4Slot(TGo4Slot *parent);
55  TGo4Slot(TGo4Slot *parent, const char *name, const char *title);
56  virtual ~TGo4Slot();
57 
58  TGo4Slot *GetParent() const { return fParent; }
59  void SetParent(TGo4Slot *parent) { fParent = parent; }
60  Bool_t IsParent(const TGo4Slot *slot) const;
61 
62  virtual void ProduceFullName(TString &name, TGo4Slot *toparent = nullptr);
63  TString GetFullName(TGo4Slot *toparent = nullptr);
64  virtual TGo4ObjectManager *GetOM() const;
65 
66  const char *GetInfo();
67  Int_t GetSizeInfo();
68 
69  void SetPar(const char *name, const char *value);
70  const char *GetPar(const char *name) const;
71  void RemovePar(const char *name);
72  void SetIntPar(const char *name, Int_t value);
73  Bool_t GetIntPar(const char *name, Int_t &value) const;
74  void PrintPars(Int_t level = 3);
75 
76  Int_t NumChilds() const { return fChilds ? fChilds->GetLast()+1 : 0; }
77  TGo4Slot *GetChild(Int_t n) const { return fChilds ? (TGo4Slot *) fChilds->At(n) : nullptr; }
78  TGo4Slot *FindChild(const char *name) const;
79  Int_t GetIndexOf(const TGo4Slot *child) const;
80  TGo4Slot *GetNextChild(const TGo4Slot *child) const;
81  TGo4Slot *GetNext() const;
82  void DeleteChild(const char *name);
83  void DeleteChilds(const char *startedwith = nullptr);
84  void Delete(Option_t *opt = "") override;
85 
86  TGo4Slot *DefineSubSlot(const char *name, const char *&subname) const;
87  TGo4Slot *GetSlot(const char *name, Bool_t force = kFALSE);
88  TGo4Slot *FindSlot(const char *fullpath, const char **subname = nullptr);
89  Bool_t ShiftSlotBefore(TGo4Slot *slot, TGo4Slot *before);
90  Bool_t ShiftSlotAfter(TGo4Slot *slot, TGo4Slot *after);
91 
92  void SetProxy(TGo4Proxy* cont);
93  TGo4Proxy* GetProxy() const { return fProxy; }
94 
95  Int_t GetSlotKind() const;
96  const char *GetSlotClassName() const;
97 
98  Bool_t IsAcceptObject(TClass *cl) const;
99  Bool_t AssignObject(TObject *obj, Bool_t owner);
100  TObject *GetAssignedObject();
101  virtual void Update(Bool_t strong = kFALSE);
102  Int_t GetAssignFlag() const { return fAssignFlag; }
103  void ResetAssignFlag() { fAssignFlag = -1; }
104  Int_t GetAssignCnt() const { return fAssignCnt; }
105 
106  Bool_t HasSubLevels() const;
107  Bool_t HasSlotsSubLevels() const;
108  TGo4LevelIter *MakeLevelIter() const;
109  std::unique_ptr<TGo4Access> ProvideSlotAccess(const char *name);
110 
111  void SaveData(TDirectory *dir, Bool_t onlyobjs = kFALSE);
112  void ReadData(TDirectory *dir);
113 
114  // method required to be virtual for object manager
115  virtual void Event(TGo4Slot *source, Int_t id, void *param = nullptr);
116  void ForwardEvent(TGo4Slot *source, Int_t id, void *param = nullptr);
117 
118  void RecursiveRemove(TObject *obj) override;
119 
120  void Print(Option_t *opt = "") const override;
121 
122  static const char *FindFolderSeparator(const char *name);
123  static void ProduceFolderAndName(const char *fullname, TString &foldername, TString &objectname);
124 
125  Bool_t DoingDelete() const { return TestBit(kStartDelete); }
126 
128 };
129 
130 #endif
131 
void CleanProxy()
Definition: TGo4Slot.cxx:287
ClassDefOverride(TGo4Slot, 1)
TGo4Slot * GetChild(Int_t n) const
Definition: TGo4Slot.h:77
Bool_t GetIntPar(const char *name, Int_t &value) const
Definition: TGo4Slot.cxx:624
TGo4Proxy * fProxy
!
Definition: TGo4Slot.h:40
Bool_t IsAcceptObject(TClass *cl) const
Definition: TGo4Slot.cxx:339
void SetParent(TGo4Slot *parent)
Definition: TGo4Slot.h:59
static const char * FindFolderSeparator(const char *name)
Definition: TGo4Slot.cxx:641
Bool_t IsParent(const TGo4Slot *slot) const
Definition: TGo4Slot.cxx:178
Int_t NumChilds() const
Definition: TGo4Slot.h:76
void SaveData(TDirectory *dir, Bool_t onlyobjs=kFALSE)
Definition: TGo4Slot.cxx:410
void SetIntPar(const char *name, Int_t value)
Definition: TGo4Slot.cxx:617
void DeleteChild(const char *name)
Definition: TGo4Slot.cxx:188
void SetProxy(TGo4Proxy *cont)
Definition: TGo4Slot.cxx:296
TGo4LevelIter * MakeLevelIter() const
Definition: TGo4Slot.cxx:382
TGo4Slot * FindChild(const char *name) const
Definition: TGo4Slot.cxx:245
TGo4Slot * GetNextChild(const TGo4Slot *child) const
Definition: TGo4Slot.cxx:236
void PrintPars(Int_t level=3)
Definition: TGo4Slot.cxx:632
TGo4Proxy * GetProxy() const
Definition: TGo4Slot.h:93
void ResetAssignFlag()
Definition: TGo4Slot.h:103
TGo4Slot()
Definition: TGo4Slot.cxx:61
Int_t GetIndexOf(const TGo4Slot *child) const
Definition: TGo4Slot.cxx:226
TGo4Slot * FindSlot(const char *fullpath, const char **subname=nullptr)
Definition: TGo4Slot.cxx:469
void RemoveChild(TGo4Slot *child)
Definition: TGo4Slot.cxx:544
Int_t GetAssignCnt() const
Definition: TGo4Slot.h:104
TString GetFullName(TGo4Slot *toparent=nullptr)
Definition: TGo4Slot.cxx:274
Bool_t ShiftSlotBefore(TGo4Slot *slot, TGo4Slot *before)
Definition: TGo4Slot.cxx:505
void AddChild(TGo4Slot *child)
Definition: TGo4Slot.cxx:537
TObject * GetAssignedObject()
Definition: TGo4Slot.cxx:356
virtual void Event(TGo4Slot *source, Int_t id, void *param=nullptr)
Definition: TGo4Slot.cxx:555
TObjArray * fChilds
Definition: TGo4Slot.h:38
Int_t GetAssignFlag() const
Definition: TGo4Slot.h:102
TObjArray fPars
Definition: TGo4Slot.h:39
Bool_t DoingDelete() const
Definition: TGo4Slot.h:125
TGo4Slot * GetNext() const
Definition: TGo4Slot.cxx:258
TGo4Slot * GetParent() const
Definition: TGo4Slot.h:58
TGo4Slot * DefineSubSlot(const char *name, const char *&subname) const
Definition: TGo4Slot.cxx:431
virtual void Update(Bool_t strong=kFALSE)
Definition: TGo4Slot.cxx:361
TGo4Slot * GetSlot(const char *name, Bool_t force=kFALSE)
Definition: TGo4Slot.cxx:451
Bool_t ShiftSlotAfter(TGo4Slot *slot, TGo4Slot *after)
Definition: TGo4Slot.cxx:521
Int_t fAssignCnt
! counts number of object assignment
Definition: TGo4Slot.h:42
void Print(Option_t *opt="") const override
Definition: TGo4Slot.cxx:578
void RemovePar(const char *name)
Definition: TGo4Slot.cxx:606
void RecursiveRemove(TObject *obj) override
Definition: TGo4Slot.cxx:571
const char * GetInfo()
Definition: TGo4Slot.cxx:312
virtual ~TGo4Slot()
Definition: TGo4Slot.cxx:91
void ReadData(TDirectory *dir)
Definition: TGo4Slot.cxx:416
const char * GetPar(const char *name) const
Definition: TGo4Slot.cxx:598
TGo4Slot * fParent
Definition: TGo4Slot.h:37
Bool_t HasSubLevels() const
Definition: TGo4Slot.cxx:370
static void ProduceFolderAndName(const char *fullname, TString &foldername, TString &objectname)
Definition: TGo4Slot.cxx:646
std::unique_ptr< TGo4Access > ProvideSlotAccess(const char *name)
Definition: TGo4Slot.cxx:395
Int_t fAssignFlag
! use in object manager to poll until object is assigned
Definition: TGo4Slot.h:41
Bool_t HasSlotsSubLevels() const
Definition: TGo4Slot.cxx:377
Bool_t AssignObject(TObject *obj, Bool_t owner)
Definition: TGo4Slot.cxx:344
void ForwardEvent(TGo4Slot *source, Int_t id, void *param=nullptr)
Definition: TGo4Slot.cxx:565
void DeleteChilds(const char *startedwith=nullptr)
Definition: TGo4Slot.cxx:202
const char * GetSlotClassName() const
Definition: TGo4Slot.cxx:334
Int_t GetSizeInfo()
Definition: TGo4Slot.cxx:321
virtual TGo4ObjectManager * GetOM() const
Definition: TGo4Slot.cxx:282
void Delete(Option_t *opt="") override
Definition: TGo4Slot.cxx:171
void SetPar(const char *name, const char *value)
Definition: TGo4Slot.cxx:586
Int_t GetSlotKind() const
Definition: TGo4Slot.cxx:329
virtual void ProduceFullName(TString &name, TGo4Slot *toparent=nullptr)
Definition: TGo4Slot.cxx:264