GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4ClientTask Class Reference

This class controls a client application running in a task which is controlled by another server task via transport channels which are held by a task handler object. More...

#include <TGo4ClientTask.h>

+ Inheritance diagram for TGo4ClientTask:

Public Member Functions

 TGo4ClientTask (const char *name, const char *serverhost="localhost", UInt_t negotiationport=0, Bool_t blockingmode=kTRUE, Bool_t standalone=kFALSE, Bool_t autostart=kFALSE, Bool_t autocreate=kTRUE, Bool_t ismaster=kFALSE, Bool_t autoconnect=kTRUE)
 
virtual ~TGo4ClientTask ()
 
void AddLocalCommand (TGo4Command *com)
 Put command into the command queue for local execution in main thread.
 
Bool_t ConnectServer (const char *node, UInt_t negport, Go4CommandMode_t role=kGo4ComModeRefused, const char *passwd=nullptr)
 Connect this client to a waiting server task on node with negotiation channel negport.
 
TGo4TaskStatusCreateStatus () override
 create a status object with information on the current client state.
 
Bool_t DisconnectServer (Bool_t isterminating=kFALSE)
 Disconnect the current server task, but do not terminate the client.
 
TGo4BufferQueueGetCommandQueue (const char *task=nullptr) override
 
TGo4BufferQueueGetDataQueue (const char *task=nullptr) override
 
const char * GetServerHostName () const
 
TGo4BufferQueueGetStatusQueue (const char *task=nullptr) override
 
TGo4TaskHandlerGetTaskHandler () override
 
Int_t Initialization () override
 override the ThreadManager Initialization used by AppControlTimer to let this thing initialize the client transport connection
 
Bool_t IsConnected () const
 
void Quit () override
 Quit the client; method to be called from command object, may be overridden in user implementation.
 
- Public Member Functions inherited from TGo4Task
 TGo4Task (const char *name, Bool_t blockingmode, Bool_t autostart=kFALSE, Bool_t autocreate=kTRUE, Bool_t ismaster=kFALSE)
 
virtual ~TGo4Task ()
 
void AddUserCommand (TGo4Command *com)
 Add a user command object to the existing command list.
 
void AddUserCommandList (TGo4CommandProtoList *comlist)
 Add a user command list to the existing command list.
 
virtual void ExecuteString (const char *command)
 Execute string command.
 
TBuffer * GetAbortBuffer ()
 Use preallocated abort buffer to stop remote socket wait from taskhandler itself.
 
const char * GetCommanderName () const
 
TGo4MasterGetMaster () const
 
TGo4SlaveGetSlave () const
 
virtual void GetStatus ()
 Send current status information of the task to the master; may be re-implemented by application subclass of TGo4Task.
 
TMutex * GetStatusBufferMutex ()
 Access to the mutex of status buffer.
 
Int_t Initialization () override
 Overrides the ThreadManager Initialization; is used to setup the client connections on demand; checks for fbConnectRequest flag.
 
Bool_t IsMaster () const
 
Bool_t IsWorkStopped () const
 
virtual void KillMain ()
 Kill the main thread; method to be called from command, should be overridden in user implementation.
 
TGo4CommandMakeCommand (const char *name)
 Method using internal command prototype list to produce a clone of the specified command.
 
virtual TGo4CommandNextCommand ()
 Delivers next command from command queue.
 
TObject * NextObject (Bool_t wait=kTRUE)
 Delivers next object from data queue.
 
TGo4StatusNextStatus (Bool_t wait=kTRUE)
 Delivers next status object from status queue.
 
virtual void RestartMain ()
 Restart the main thread; method to be called from command, should be overridden in user implementation.
 
void SendObject (TObject *obj, const char *receiver=nullptr)
 Send object via data channel to the master.
 
virtual void SendStatus (TGo4Status *stat, const char *receiver=nullptr)
 Send status object via status channel to the master.
 
virtual void SendStatusBuffer ()
 Send internal status buffer to the master(s).
 
void SendStatusMessage (Int_t level, Bool_t printout, const char *text,...)
 Send message string in a status object to the gui.
 
void SendStopBuffers (const char *taskname=nullptr)
 Send message buffers with stop values into queues and via socket connections.
 
void SetOwner (TGo4TaskOwner *owner)
 Set owner object and switch automatically in master or slave mode, depending on owner type.
 
virtual void Start ()
 General start method of client application to be called from remote command; should be re-implemented by application.
 
virtual Int_t StartWorkThreads ()
 start the working threads of the task implementation; this method is used after the current connection has changed, to continue reading/writing the queues.
 
virtual void Stop ()
 General stop method of client application to be called from remote command; should be re-implemented by application.
 
virtual Int_t StopWorkThreads ()
 stop the working threads of the task implementation; this method is used before the current connection is changed to prevent reading/writing and waiting for the wrong queues.
 
Bool_t SubmitCommand (const char *name)
 send command specified by name to the current client task
 
Bool_t SubmitCommand (TGo4Command *com)
 send given command to the current client task.
 
Bool_t SubmitEmergencyCommand (Go4EmergencyCommand_t val)
 send emergency quit command to the current client task
 
Bool_t SubmitEmergencyData (Go4EmergencyCommand_t val, const char *receiver=nullptr)
 Send emergency command via data channel.
 
Bool_t SubmitLocalCommand (TGo4Command *com)
 Send given command to the current client task.
 
void Terminate (Bool_t termapp=kTRUE) override
 deletes the Manager instance via Control timer.
 
void TerminateFast () override
 Overwrites the Threadmanager TerminateFast to shutdown the objectserver properly.
 
void UpdateStatusBuffer ()
 Create status object and stream it into the status send buffer.
 
void WakeCommandQueue (Int_t id=0)
 Put dummy object into command queue to wake up user threads which might wait for a command.
 
- Public Member Functions inherited from TGo4ThreadManager
 TGo4ThreadManager (const char *name, Bool_t blockingmode=kTRUE, Bool_t autostart=kTRUE, Bool_t autocreate=kTRUE)
 Normal constructor.
 
 TGo4ThreadManager (const TGo4ThreadManager &right)
 
virtual ~TGo4ThreadManager ()
 
Bool_t BlockApp ()
 Blocks gSystem by means of the blocking timer.
 
TGo4ThreadHandlerGetWorkHandler () const
 Access to ThreadHandler for working threads.
 
Bool_t IsAppBlocking () const
 Returns true if threadmanager works in root system blocking mode.
 
Bool_t IsBeingQuit () const
 Returns true if threadmanager works in root system blocking mode.
 
Bool_t IsInitDone () const
 
Bool_t IsTerminateApp () const
 
Bool_t IsTerminating () const
 returns termination status of Threadmanager
 
void Launch ()
 This Method has to be called to create the startup threads and to turn on the application control timer.
 
void SetBeingQuit (Bool_t on)
 
void SetTimer (TGo4AppControlTimer *ctrltimer)
 user can exchange the standard control timer by an own derived one by this method
 
Bool_t UnBlockApp (Int_t mode=0)
 Wakes up the control timer waiting for his condition; parameter mode specifies whether timer will block again at next turn (mode = 0), timer will block when all threads are up (mode = 1), or timer will not block again unless the next Block call, i.e.
 
- Public Member Functions inherited from TGo4CommandReceiver
 TGo4CommandReceiver ()
 
virtual ~TGo4CommandReceiver ()
 

Protected Member Functions

void UpdateStatus (TGo4TaskStatus *state) override
 method needed by method CreateStatus of any status subclasses to set the values of the clienttask specific part of the status object.
 
- Protected Member Functions inherited from TGo4Task
virtual TGo4TaskHandlerCommandListCreateCommandList ()
 factory method for command list; overridden by implementation
 
TGo4ObjectQueueGetLocalCommandQueue ()
 
TGo4TaskHandlerCommandListGetPrototype ()
 get pointer to currently valid command list
 
void SetMaster (Bool_t on=kTRUE)
 
void SetWorkIsStopped (Bool_t on)
 

Private Attributes

Bool_t fbAutoConnect {kFALSE}
 !True if client task shall try to connect automatically at Initialization.
 
Bool_t fbServerConnected {kFALSE}
 true if connection to server is established, otherwise false
 
TGo4BufferQueuefxCommandQ {nullptr}
 
TGo4BufferQueuefxDataQ {nullptr}
 
TString fxServerHostname
 hostname of server machine
 
TGo4BufferQueuefxStatusQ {nullptr}
 
TGo4TaskHandlerfxTaskHandler {nullptr}
 aggregationByValue
 

Additional Inherited Members

- Public Types inherited from TGo4ThreadManager
enum  { fguTEXTLENGTH = 256 }
 Default textlength for char arrays. More...
 
- Static Public Member Functions inherited from TGo4Task
static Int_t Get_fgiTERMID ()
 
- Static Public Attributes inherited from TGo4ThreadManager
static const Long_t fglTIMERPERIOD = 200
 Period in ms for the application control timer.
 
- Protected Attributes inherited from TGo4Task
TBuffer * fxStatusBuffer {nullptr}
 Buffer containing the analysis status which is updated by the main thread.
 
TMutex * fxStatusMutex {nullptr}
 Mutex protecting status buffer between main and watch thread.
 
- Protected Attributes inherited from TGo4ThreadManager
Bool_t fbAppBlocking {kFALSE}
 true if threadmanager shall block root gSystem using the AppControlTimer; false if gSystem shall never be blocked (necessary for gui)
 
Bool_t fbAutoCreate {kFALSE}
 If true, TThreads of all go4threads in list shall be created automatically on calling Launch().
 
Bool_t fbAutoStart {kFALSE}
 If true, workfunctions (runnable Run()) of all go4threads in list shall be started automatically on Initialization.
 
Int_t fbBeingQuit {0}
 
Bool_t fbInitDone {kFALSE}
 is set kTRUE after first Initialize is done
 
Bool_t fbTerminateApplication {kFALSE}
 If true, terminate complete application.
 
Bool_t fbTerminating {kFALSE}
 flag showing termination status
 
TGo4AppControlTimerfxBlocker {nullptr}
 Composition of Application control timer.
 
TGo4ThreadHandlerfxWorkHandler {nullptr}
 Thread handler aggregate (threadsafe list of go4 threads) aggregationByValue 1 1.
 

Detailed Description

This class controls a client application running in a task which is controlled by another server task via transport channels which are held by a task handler object.

Apart from the transport threads, the application class which inherits from client task may provide working threads to serve the data queues and do the actual work

Definition at line 34 of file TGo4ClientTask.h.

Constructor & Destructor Documentation

◆ TGo4ClientTask()

TGo4ClientTask::TGo4ClientTask ( const char * name,
const char * serverhost = "localhost",
UInt_t negotiationport = 0,
Bool_t blockingmode = kTRUE,
Bool_t standalone = kFALSE,
Bool_t autostart = kFALSE,
Bool_t autocreate = kTRUE,
Bool_t ismaster = kFALSE,
Bool_t autoconnect = kTRUE )

◆ ~TGo4ClientTask()

TGo4ClientTask::~TGo4ClientTask ( )
virtual

Definition at line 51 of file TGo4ClientTask.cxx.

References DisconnectServer(), and fxTaskHandler.

Member Function Documentation

◆ AddLocalCommand()

void TGo4ClientTask::AddLocalCommand ( TGo4Command * com)

Put command into the command queue for local execution in main thread.

Definition at line 169 of file TGo4ClientTask.cxx.

References TGo4Log::Debug(), and fxCommandQ.

◆ ConnectServer()

Bool_t TGo4ClientTask::ConnectServer ( const char * node,
UInt_t negport,
Go4CommandMode_t role = kGo4ComModeRefused,
const char * passwd = nullptr )

◆ CreateStatus()

TGo4TaskStatus * TGo4ClientTask::CreateStatus ( )
overridevirtual

create a status object with information on the current client state.

this object may be sent to the server or may be used to restore current status by memento mechanism

Reimplemented from TGo4Task.

Reimplemented in TGo4ExampleClient.

Definition at line 154 of file TGo4ClientTask.cxx.

References UpdateStatus().

◆ DisconnectServer()

Bool_t TGo4ClientTask::DisconnectServer ( Bool_t isterminating = kFALSE)

Disconnect the current server task, but do not terminate the client.

Return value indicates success state: true if disconnected, false if connection is still existing. If isterminating=true, work threads are not restarted again.

Definition at line 119 of file TGo4ClientTask.cxx.

References TGo4Queue::Clear(), fbServerConnected, fxTaskHandler, TGo4Task::Get_fgiTERMID(), GetCommandQueue(), TGo4Task::IsMaster(), TGo4Task::SendStopBuffers(), TGo4Task::StartWorkThreads(), TGo4Task::StopWorkThreads(), and TGo4Task::WakeCommandQueue().

Referenced by ~TGo4ClientTask(), TGo4Master::DisconnectSlave(), and Quit().

◆ GetCommandQueue()

TGo4BufferQueue * TGo4ClientTask::GetCommandQueue ( const char * task = nullptr)
overridevirtual

Reimplemented from TGo4Task.

Definition at line 180 of file TGo4ClientTask.cxx.

References fxCommandQ.

Referenced by DisconnectServer().

◆ GetDataQueue()

TGo4BufferQueue * TGo4ClientTask::GetDataQueue ( const char * task = nullptr)
overridevirtual

Reimplemented from TGo4Task.

Definition at line 189 of file TGo4ClientTask.cxx.

References fxDataQ.

Referenced by TGo4ExampleClient::TGo4ExampleClient().

◆ GetServerHostName()

const char * TGo4ClientTask::GetServerHostName ( ) const
inline

Definition at line 101 of file TGo4ClientTask.h.

References fxServerHostname.

Referenced by Initialization(), and UpdateStatus().

◆ GetStatusQueue()

TGo4BufferQueue * TGo4ClientTask::GetStatusQueue ( const char * task = nullptr)
overridevirtual

Reimplemented from TGo4Task.

Definition at line 185 of file TGo4ClientTask.cxx.

References fxStatusQ.

◆ GetTaskHandler()

TGo4TaskHandler * TGo4ClientTask::GetTaskHandler ( )
overridevirtual

Reimplemented from TGo4Task.

Definition at line 57 of file TGo4ClientTask.cxx.

References fxTaskHandler.

Referenced by TGo4ClientTask(), and TGo4ExampleClient::TGo4ExampleClient().

◆ Initialization()

Int_t TGo4ClientTask::Initialization ( )
overridevirtual

override the ThreadManager Initialization used by AppControlTimer to let this thing initialize the client transport connection

Reimplemented from TGo4ThreadManager.

Definition at line 62 of file TGo4ClientTask.cxx.

References ConnectServer(), fbAutoConnect, TGo4ThreadManager::fbInitDone, GetServerHostName(), TGo4Task::Initialization(), and TGo4Task::Terminate().

◆ IsConnected()

Bool_t TGo4ClientTask::IsConnected ( ) const
inline

Definition at line 103 of file TGo4ClientTask.h.

References fbServerConnected.

Referenced by TGo4TaskOwner::IsConnected().

◆ Quit()

void TGo4ClientTask::Quit ( )
overridevirtual

Quit the client; method to be called from command object, may be overridden in user implementation.

Reimplemented from TGo4Task.

Definition at line 144 of file TGo4ClientTask.cxx.

References TGo4Log::Debug(), DisconnectServer(), TGo4Task::IsMaster(), TGo4Task::Quit(), TGo4Task::SendStatusMessage(), and TGo4Task::Terminate().

◆ UpdateStatus()

void TGo4ClientTask::UpdateStatus ( TGo4TaskStatus * state)
overrideprotectedvirtual

method needed by method CreateStatus of any status subclasses to set the values of the clienttask specific part of the status object.

Reimplemented from TGo4Task.

Reimplemented in TGo4ExampleClient.

Definition at line 161 of file TGo4ClientTask.cxx.

References GetServerHostName(), TGo4ClientStatus::SetNames(), and TGo4Task::UpdateStatus().

Referenced by CreateStatus(), and TGo4ExampleClient::UpdateStatus().

Field Documentation

◆ fbAutoConnect

Bool_t TGo4ClientTask::fbAutoConnect {kFALSE}
private

!True if client task shall try to connect automatically at Initialization.

This is the previous behaviour with standalone client. If false, connection will be done on ConnectServer method.

Definition at line 133 of file TGo4ClientTask.h.

Referenced by TGo4ClientTask(), and Initialization().

◆ fbServerConnected

Bool_t TGo4ClientTask::fbServerConnected {kFALSE}
private

true if connection to server is established, otherwise false

Definition at line 138 of file TGo4ClientTask.h.

Referenced by TGo4ClientTask(), ConnectServer(), DisconnectServer(), and IsConnected().

◆ fxCommandQ

TGo4BufferQueue* TGo4ClientTask::fxCommandQ {nullptr}
private

Definition at line 118 of file TGo4ClientTask.h.

Referenced by TGo4ClientTask(), AddLocalCommand(), and GetCommandQueue().

◆ fxDataQ

TGo4BufferQueue* TGo4ClientTask::fxDataQ {nullptr}
private

Definition at line 117 of file TGo4ClientTask.h.

Referenced by TGo4ClientTask(), and GetDataQueue().

◆ fxServerHostname

TString TGo4ClientTask::fxServerHostname
private

hostname of server machine

Definition at line 127 of file TGo4ClientTask.h.

Referenced by TGo4ClientTask(), and GetServerHostName().

◆ fxStatusQ

TGo4BufferQueue* TGo4ClientTask::fxStatusQ {nullptr}
private

Definition at line 116 of file TGo4ClientTask.h.

Referenced by TGo4ClientTask(), and GetStatusQueue().

◆ fxTaskHandler

TGo4TaskHandler* TGo4ClientTask::fxTaskHandler {nullptr}
private

aggregationByValue

1 1

Definition at line 124 of file TGo4ClientTask.h.

Referenced by TGo4ClientTask(), ~TGo4ClientTask(), ConnectServer(), DisconnectServer(), and GetTaskHandler().


The documentation for this class was generated from the following files: