Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4LinkProxy.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4LinkProxy.h"
00017 
00018 #include "TH1.h"
00019 #include "TString.h"
00020 
00021 #include "TGo4Slot.h"
00022 #include "TGo4ObjectManager.h"
00023 
00024 TGo4LinkProxy::TGo4LinkProxy() :
00025    TGo4Proxy(),
00026    fLink(0)
00027 {
00028 }
00029 
00030 TGo4LinkProxy::TGo4LinkProxy(TGo4Slot* linkedslot) :
00031    TGo4Proxy(),
00032    fLink(linkedslot)
00033 {
00034 }
00035 
00036 TGo4LinkProxy::~TGo4LinkProxy()
00037 {
00038 }
00039 
00040 void TGo4LinkProxy::Initialize(TGo4Slot* slot)
00041 {
00042    TGo4ObjectManager* om = slot->GetOM();
00043    if (om!=0)
00044      om->RegisterLink(fLink, slot);
00045 }
00046 
00047 void TGo4LinkProxy::Finalize(TGo4Slot* slot)
00048 {
00049    TGo4ObjectManager* om = slot->GetOM();
00050    if (om!=0) {
00051       // this is workaround a problem, that in TGo4Slot destructor CleanProxy
00052       // called before Event(this, evDelete)
00053       // For that situation we retranslate evDelete message before link will dissaper from OM
00054       if (slot->DoingDelete())
00055          om->RetranslateEvent(slot, TGo4Slot::evDelete);
00056 
00057       om->UnregisterLink(slot);
00058    }
00059 }
00060 
00061 TGo4Access* TGo4LinkProxy::MakeProxy(const char* name)
00062 {
00063    return (fLink!=0)  ? fLink->ProvideSlotAccess(name) : 0;
00064 }
00065 
00066 TGo4LevelIter* TGo4LinkProxy::MakeIter()
00067 {
00068    return (fLink!=0)  ? fLink->MakeLevelIter() : 0;
00069 }
00070 
00071 void TGo4LinkProxy::WriteData(TGo4Slot* slot, TDirectory* dir, Bool_t onlyobjs)
00072 {
00073    if (!onlyobjs) {
00074       TString linkname;
00075       if (fLink!=0)
00076         fLink->ProduceFullName(linkname);
00077 
00078       slot->SetPar("LinkProxy::LinkName", linkname.Length()>0 ? linkname.Data() : 0);
00079    }
00080 }
00081 
00082 void TGo4LinkProxy::ReadData(TGo4Slot* slot, TDirectory* dir)
00083 {
00084    const char* linkname = slot->GetPar("LinkProxy::LinkName");
00085    if (linkname!=0)
00086      fLink = slot->GetOM()->GetSlot(linkname);
00087 
00088 }
00089 
00090 Int_t TGo4LinkProxy::GetObjectKind()
00091 {
00092    return (fLink!=0) ? fLink->GetSlotKind() : TGo4Access::kndNone;
00093 }
00094 
00095 const char* TGo4LinkProxy::GetContainedClassName()
00096 {
00097    return (fLink!=0) ? fLink->GetSlotClassName() : 0;
00098 }
00099 
00100 Bool_t TGo4LinkProxy::IsAcceptObject(TClass* cl)
00101 {
00102    return (fLink!=0) ? fLink->IsAcceptObject(cl) : kFALSE;
00103 }
00104 
00105 Bool_t TGo4LinkProxy::AssignObject(TGo4Slot* slot, TObject* obj, Bool_t owner)
00106 {
00107    return fLink==0 ? kFALSE : fLink->AssignObject(obj, owner);
00108 }
00109 
00110 TObject* TGo4LinkProxy::GetAssignedObject()
00111 {
00112    return fLink==0 ? 0 : fLink->GetAssignedObject();
00113 }
00114 
00115 Bool_t TGo4LinkProxy::ProcessEvent(TGo4Slot* slot, TGo4Slot* source, Int_t id, void* param)
00116 {
00117     if ((id == TGo4Slot::evDelete) && (source == fLink)) {
00118        // next line very important.
00119        // If master slot says that it will be deleted, we just
00120        // brake dependency from it and "forgot" that it is existing
00121        // As a result, access to master object will be canceled
00122        // After we delete slot with our link proxy.
00123        // For instance, if marker is assigned to histogram, and histogram
00124        // is deleted (file closed), marker cannot access histogram pointer
00125        // and will be reassigned to null histogram even when master slot is
00126        // able to provide histogram pointer.
00127        fLink = 0;
00128        slot->Delete();
00129 //       delete slot;
00130        // we delete slot with timer afterwards
00131 
00132 //       TGo4ObjectManager* om = slot->GetOM();
00133        // om->UnregisterLink(slot);
00134 //       om->DeleteObject(slot);
00135 
00136 //       slot->ForwardEvent(slot, TGo4Slot::evObjDeleted);
00137 
00138        return kFALSE;
00139     }
00140 
00141     // emulate that message come from this slot, not from master link
00142     slot->ForwardEvent(slot, id, param);
00143 
00144     return kFALSE;
00145 }
00146 
00147 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:27 2008 for Go4-v3.04-1 by  doxygen 1.4.2