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

TGo4TaskOwner.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 "TGo4TaskOwner.h"
00017 
00018 #include "Riostream.h"
00019 
00020 #include "TGo4Log.h"
00021 #include "TGo4Task.h"
00022 #include "TGo4ServerTask.h"
00023 #include "TGo4TaskManager.h"
00024 #include "TGo4ClientTask.h"
00025 
00026 
00027 TGo4TaskOwner::TGo4TaskOwner() :
00028    TGo4CommandReceiver(),
00029    fxTask(0),
00030    fbServerMode(kTRUE)
00031 {
00032 }
00033 
00034 TGo4TaskOwner::TGo4TaskOwner(Bool_t isserver) :
00035    TGo4CommandReceiver(),
00036    fxTask(0),
00037    fbServerMode(isserver)
00038 {
00039 }
00040 
00041 TGo4TaskOwner::~TGo4TaskOwner()
00042 {
00043    if(fxTask!=0)
00044       fxTask->SetOwner(0); // avoid the task to delete us again in dtor
00045    delete fxTask;
00046 }
00047 
00048 const char* TGo4TaskOwner::GetName() const
00049 {
00050    return (fxTask!=0) ? fxTask->GetName() : 0;
00051 }
00052 
00053 void TGo4TaskOwner::SetTask(TGo4Task* task, Bool_t delold)
00054 {
00055    if(delold) delete fxTask;
00056    fxTask=task;
00057    if(fxTask) fxTask->SetOwner(this);
00058 }
00059 
00060 void TGo4TaskOwner::Quit()
00061 {
00062    fxTask->Quit();
00063 }
00064 
00065 Int_t TGo4TaskOwner::StartWorkThreads()
00066 {
00067    TGo4Log::Debug(" Task Owner: default StartWorkThreads() ");
00068    fxTask->SetWorkIsStopped(kFALSE);
00069    return 0;
00070 }
00071 Int_t TGo4TaskOwner::StopWorkThreads()
00072 {
00073    TGo4Log::Debug(" Task Owner: default StopWorkThreads() ");
00074    fxTask->SetWorkIsStopped(kTRUE);
00075    return 0;
00076 }
00077 
00078 
00079 Bool_t TGo4TaskOwner::IsConnected()
00080 {
00081 if(IsServer())
00082    {
00083       TGo4ServerTask* server=dynamic_cast<TGo4ServerTask*>(GetTask());
00084       if(server==0)
00085          {
00086             cerr <<"NEVER COME HERE: servermode without servertask in taskowner "<< GetName() << endl;
00087             return kFALSE;
00088          }
00089       return (server->GetCurrentTaskHandler()!=0);
00090    }
00091 else
00092    {
00093       TGo4ClientTask* client=dynamic_cast<TGo4ClientTask*>(GetTask());
00094       if(client==0)
00095          {
00096             cerr <<"NEVER COME HERE: clientmode without clienttask in taskowner "<< GetName() << endl;
00097             return kFALSE;
00098          }
00099       return (client->IsConnected());
00100    }
00101 
00102 }
00103 
00104 TMutex* TGo4TaskOwner::GetTaskManagerMutex()
00105 {
00106 if(IsServer())
00107    {
00108    TGo4ServerTask* serv=dynamic_cast<TGo4ServerTask*>(GetTask());
00109    if(serv)
00110          return (serv->GetTaskManager()->GetMutex());
00111    else
00112          return 0;
00113    }
00114 else
00115 {
00116   return 0;
00117 }
00118 }
00119 
00120 
00121 //----------------------------END OF GO4 SOURCE FILE ---------------------

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