Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4GUI/TGo4MonitoredListStatus.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 "TGo4MonitoredListStatus.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TNamed.h"
00021 #include "TObjArray.h"
00022 
00023 #include "TGo4MonitoredObject.h"
00024 #include "Go4LockGuard/TGo4LockGuard.h"
00025 
00026 TGo4MonitoredListStatus::TGo4MonitoredListStatus(const char* name, const char* title)
00027                 :TGo4Status(name, title)
00028 {
00029    TGo4LockGuard globalguard;
00030    MonitoredObjectList=new TObjArray(10);
00031    MonitoredObjectListIterator= MonitoredObjectList->MakeIterator();
00032 }
00033 
00034 void TGo4MonitoredListStatus::AddToMonitoredObjectList(TObject *fxObject, QWidget *Panel, TCanvas *Canvas, TPad *pad)
00035 {
00036    TGo4LockGuard globalguard;
00037    TGo4MonitoredObject *OldObject=0;
00038    if(fxObject!=0){
00039       OldObject = GetMonitoredObject(fxObject);
00040       if (OldObject==0){
00041          MonitoredObjectList->Add(new TGo4MonitoredObject(fxObject->GetName(), fxObject, Panel, Canvas, pad));
00042       }else{
00043          RemoveMonitoredObject(OldObject);
00044          MonitoredObjectList->Add(new TGo4MonitoredObject(fxObject->GetName(), fxObject, Panel, Canvas, pad));
00045       }
00046    }
00047 }
00048 
00049 void TGo4MonitoredListStatus::AddToMonitoredObjectList(TObject *fxObject)
00050 {
00051    TGo4LockGuard globalguard;
00052    if(fxObject!=0){
00053       MonitoredObjectList->Add(new TGo4MonitoredObject(fxObject->GetName(), fxObject, 0, 0,0));
00054       //cout << "AddToMonitoredObjectList " << fxObject->GetName() << endl;
00055    }else{
00056       //cout << "AddToMonitoredObjectList " << fxObject << endl;
00057    }
00058 }
00059 
00060 
00061 TGo4MonitoredObject* TGo4MonitoredListStatus::GetMonitoredObject(TObject *fxObject)
00062 {
00063    // TGo4LockGuard globalguard;
00064    TObject *entry=0;
00065    TGo4MonitoredObject *Monitored=0;
00066    TGo4MonitoredObject *ReturnObject=0;
00067 
00068    MonitoredObjectListIterator->Reset();
00069 
00070    while((entry=MonitoredObjectListIterator->Next())!=0){
00071       Monitored = dynamic_cast <TGo4MonitoredObject *> (entry);
00072       if (Monitored->GetMonitoredObject() == fxObject)ReturnObject= Monitored;
00073    }
00074    return ReturnObject;
00075 }
00076 
00077 TGo4MonitoredObject* TGo4MonitoredListStatus::GetMonitoredObject(const char *fxName)
00078 {
00079    // TGo4LockGuard globalguard;
00080    TObject *entry=0;
00081    TGo4MonitoredObject *ReturnObject=0;
00082    if(!MonitoredObjectList->IsEmpty()){
00083       MonitoredObjectListIterator->Reset();
00084       while((entry=MonitoredObjectListIterator->Next())!=0){
00085          if(!strcmp(entry->GetName(),fxName)) {
00086             ReturnObject= dynamic_cast <TGo4MonitoredObject *> (entry);
00087             break;
00088          }
00089       }
00090    }
00091    return ReturnObject;
00092 }
00093 
00094 void TGo4MonitoredListStatus::RemoveMonitoredObject(TObject *fxObject)
00095 {
00096    TGo4LockGuard globalguard;
00097    TObject *entry=0;
00098    TGo4MonitoredObject *Monitored=0;
00099    MonitoredObjectListIterator->Reset();
00100    while((entry=MonitoredObjectListIterator->Next())!=0){
00101       Monitored = dynamic_cast <TGo4MonitoredObject *> (entry);
00102       if (Monitored->GetMonitoredObject() == fxObject){
00103          MonitoredObjectList->Remove(entry);
00104          MonitoredObjectList->Compress();
00105          MonitoredObjectList->Expand(MonitoredObjectList->GetLast()+1);
00106          delete entry;
00107       }
00108    }
00109 
00110 }
00111 
00112 TObjArray *TGo4MonitoredListStatus::GetAllMonitored()
00113 {
00114    return MonitoredObjectList;
00115 }
00116 
00117 
00118 
00119 
00120 TGo4MonitoredListStatus::~TGo4MonitoredListStatus()
00121 {
00122    MonitoredObjectList->Delete();
00123    delete MonitoredObjectList;
00124    delete MonitoredObjectListIterator;
00125 
00126 }
00127 
00128 
00129 
00130 
00131 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:01 2005 for Go4-v2.10-5 by doxygen1.2.15