GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4LinkProxy.cxx
Go to the documentation of this file.
1 // $Id: TGo4LinkProxy.cxx 1893 2016-04-08 12:01:09Z 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 "TGo4LinkProxy.h"
15 
16 #include "TH1.h"
17 #include "TString.h"
18 
19 #include "TGo4Slot.h"
20 #include "TGo4ObjectManager.h"
21 
23  TGo4Proxy(),
24  fLink(0)
25 {
26 }
27 
29  TGo4Proxy(),
30  fLink(linkedslot)
31 {
32 }
33 
35 {
36 }
37 
39 {
40  TGo4ObjectManager* om = slot->GetOM();
41  if (om!=0)
42  om->RegisterLink(fLink, slot);
43 }
44 
46 {
47  TGo4ObjectManager* om = slot->GetOM();
48  if (om!=0) {
49  // this is workaround a problem, that in TGo4Slot destructor CleanProxy
50  // called before Event(this, evDelete)
51  // For that situation we retranslate evDelete message before link will dissaper from OM
52  if (slot->DoingDelete())
54 
55  om->UnregisterLink(slot);
56  }
57 }
58 
60 {
61  return (fLink!=0) ? fLink->ProvideSlotAccess(name) : 0;
62 }
63 
65 {
66  return (fLink!=0) ? fLink->MakeLevelIter() : 0;
67 }
68 
69 void TGo4LinkProxy::WriteData(TGo4Slot* slot, TDirectory* dir, Bool_t onlyobjs)
70 {
71  if (!onlyobjs) {
72  TString linkname;
73  if (fLink!=0)
74  fLink->ProduceFullName(linkname);
75 
76  slot->SetPar("LinkProxy::LinkName", linkname.Length()>0 ? linkname.Data() : 0);
77  }
78 }
79 
80 void TGo4LinkProxy::ReadData(TGo4Slot* slot, TDirectory* dir)
81 {
82  const char* linkname = slot->GetPar("LinkProxy::LinkName");
83  if (linkname!=0)
84  fLink = slot->GetOM()->GetSlot(linkname);
85 }
86 
88 {
89  return (fLink!=0) ? fLink->GetSlotKind() : TGo4Access::kndNone;
90 }
91 
93 {
94  return (fLink!=0) ? fLink->GetSlotClassName() : 0;
95 }
96 
98 {
99  return (fLink!=0) ? fLink->IsAcceptObject(cl) : kFALSE;
100 }
101 
102 Bool_t TGo4LinkProxy::AssignObject(TGo4Slot* slot, TObject* obj, Bool_t owner)
103 {
104  return fLink==0 ? kFALSE : fLink->AssignObject(obj, owner);
105 }
106 
108 {
109  return fLink==0 ? 0 : fLink->GetAssignedObject();
110 }
111 
112 Bool_t TGo4LinkProxy::ProcessEvent(TGo4Slot* slot, TGo4Slot* source, Int_t id, void* param)
113 {
114  if ((id == TGo4Slot::evDelete) && (source == fLink)) {
115  // next line very important.
116  // If master slot says that it will be deleted, we just
117  // brake dependency from it and "forgot" that it is existing
118  // As a result, access to master object will be canceled
119  // After we delete slot with our link proxy.
120  // For instance, if marker is assigned to histogram, and histogram
121  // is deleted (file closed), marker cannot access histogram pointer
122  // and will be reassigned to null histogram even when master slot is
123  // able to provide histogram pointer.
124  fLink = 0;
125  slot->Delete();
126 // delete slot;
127  // we delete slot with timer afterwards
128 
129 // TGo4ObjectManager* om = slot->GetOM();
130  // om->UnregisterLink(slot);
131 // om->DeleteObject(slot);
132 
133 // slot->ForwardEvent(slot, TGo4Slot::evObjDeleted);
134 
135  return kFALSE;
136  }
137 
138  // emulate that message come from this slot, not from master link
139  slot->ForwardEvent(slot, id, param);
140 
141  return kFALSE;
142 }
virtual const char * GetContainedClassName()
virtual void ReadData(TGo4Slot *slot, TDirectory *dir)
virtual Int_t GetObjectKind()
Int_t GetSlotKind() const
Definition: TGo4Slot.cxx:346
virtual Bool_t AssignObject(TGo4Slot *slot, TObject *obj, Bool_t owner)
TGo4Slot * fLink
Definition: TGo4LinkProxy.h:48
void UnregisterLink(TGo4Slot *target)
TGo4LevelIter * MakeLevelIter() const
Definition: TGo4Slot.cxx:401
virtual ~TGo4LinkProxy()
virtual void ProduceFullName(TString &name, TGo4Slot *toparent=0)
Definition: TGo4Slot.cxx:280
const char * GetSlotClassName() const
Definition: TGo4Slot.cxx:351
void RegisterLink(TGo4Slot *source, TGo4Slot *target, Bool_t exapndchilds=kFALSE)
const char * GetPar(const char *name) const
Definition: TGo4Slot.cxx:621
void RetranslateEvent(TGo4Slot *source, Int_t id, void *param=0)
virtual void WriteData(TGo4Slot *slot, TDirectory *dir, Bool_t onlyobjs)
TObject * GetAssignedObject()
Definition: TGo4Slot.cxx:373
virtual TObject * GetAssignedObject()
virtual void Finalize(TGo4Slot *slot)
virtual Bool_t IsAcceptObject(TClass *cl)
TGo4Slot * GetSlot(const char *name, Bool_t force=kFALSE)
Definition: TGo4Slot.cxx:471
Bool_t DoingDelete() const
Definition: TGo4Slot.h:125
virtual void Initialize(TGo4Slot *slot)
void ForwardEvent(TGo4Slot *source, Int_t id, void *param=0)
Definition: TGo4Slot.cxx:585
virtual Bool_t ProcessEvent(TGo4Slot *slot, TGo4Slot *source, Int_t id, void *param)
virtual void Delete(Option_t *opt="")
Definition: TGo4Slot.cxx:190
Bool_t AssignObject(TObject *obj, Bool_t owner)
Definition: TGo4Slot.cxx:361
virtual TGo4ObjectManager * GetOM() const
Definition: TGo4Slot.cxx:298
void SetPar(const char *name, const char *value)
Definition: TGo4Slot.cxx:609
TGo4Access * ProvideSlotAccess(const char *name)
Definition: TGo4Slot.cxx:413
virtual TGo4LevelIter * MakeIter()
virtual TGo4Access * ProvideAccess(const char *name)
Bool_t IsAcceptObject(TClass *cl)
Definition: TGo4Slot.cxx:356