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

TGo4Master.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 "TGo4Master.h"
00017 
00018 #include "TSystem.h"
00019 
00020 #include "TGo4Log.h"
00021 #include "TGo4Task.h"
00022 #include "TGo4ServerTask.h"
00023 #include "TGo4ClientTask.h"
00024 #include "TGo4CommandInvoker.h"
00025 #include "TGo4TaskHandlerCommandList.h"
00026 
00027 TGo4Master::TGo4Master() :
00028    TGo4TaskOwner()
00029 {
00030 }
00031 
00032 TGo4Master::TGo4Master(const char* name, Bool_t isserver, const char* serverhost, UInt_t negotport)
00033 : TGo4TaskOwner(isserver)
00034 {
00035    TGo4CommandInvoker::Instance(); // make sure a command invoker exists
00036    TGo4CommandInvoker::Register("MasterTask", this);
00037    TGo4Task* task=0;
00038    if(IsServer())
00039       {
00040          task=new TGo4ServerTask(name, negotport,
00041                kFALSE, //blockingmode
00042                kFALSE, //standalone
00043                kTRUE,  //autostart
00044                kTRUE,  //autocreate
00045                kTRUE   //ismaster
00046                );
00047       }
00048    else
00049       {
00050          task=new TGo4ClientTask(name, serverhost, negotport,
00051                      kFALSE, //blockingmode
00052                      kFALSE, //standalone
00053                      kFALSE, //autostart
00054                      kTRUE,  //autocreate
00055                      kTRUE, //ismaster
00056                      kFALSE); // autoconnect
00057       }
00058    SetTask(task);
00059 }
00060 
00061 TGo4Master::~TGo4Master()
00062 {
00063 TGo4CommandInvoker::UnRegister(this);
00064 }
00065 
00066 TGo4TaskHandlerCommandList* TGo4Master::CreateCommandList()
00067 {
00068    return new TGo4TaskHandlerCommandList("Go4ServerTaskDefaultCommandList");
00069 }
00070 
00071 Bool_t TGo4Master::SubmitCommand(const char* name)
00072 {
00073    if(GetTask()==0) return kFALSE;
00074    return (GetTask()->SubmitCommand(name));
00075 }
00076 
00077 Bool_t TGo4Master::SubmitEmergencyCommand(Go4EmergencyCommand_t val)
00078 {
00079    if(GetTask()==0) return kFALSE;
00080    return (GetTask()->SubmitEmergencyCommand(val));
00081 }
00082 
00083 Bool_t TGo4Master::SubmitCommand(TGo4Command* com)
00084 {
00085    if(GetTask()==0) return kFALSE;
00086    return (GetTask()->SubmitCommand(com));
00087 }
00088 
00089 Bool_t TGo4Master::DisconnectSlave(const char* name, Bool_t waitforslave)
00090 {
00091 Bool_t rev=kTRUE;
00092 if(IsServer())
00093    {
00094       TGo4ServerTask* server=dynamic_cast<TGo4ServerTask*> (GetTask());
00095       if(server)
00096          rev=server->RemoveClient(name, waitforslave); //waitforclient
00097       else
00098          rev=kFALSE;
00099    }
00100 else
00101    {
00102       TGo4ClientTask* client=dynamic_cast<TGo4ClientTask*> (GetTask());
00103       if(client)
00104          {
00105             rev=client->DisconnectServer();
00106             client->Terminate(kFALSE); // terminate taskowner (TGo4Display), but not application
00107          }
00108       else
00109          rev=kFALSE;
00110    }
00111 return rev;
00112 }
00113 
00114 //----------------------------END OF GO4 SOURCE FILE ---------------------

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