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