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

example class for a server task that fits to the example application More...

#include <TGo4ExampleServer.h>

+ Inheritance diagram for TGo4ExampleServer:

Public Member Functions

 TGo4ExampleServer (const char *name, UInt_t negotiationport=0, Bool_t blockingmode=kFALSE)
 
virtual ~TGo4ExampleServer ()
 
TGo4TaskHandlerCommandListCreateCommandList () override
 factory method for command list; overridden by implementation
 
TGo4ExampleControllerGetController ()
 
Int_t StartWorkThreads () override
 start the working threads of the task implementation; this method is used after the current connection has changed, to continue reading/writing the queues.
 
Int_t StopWorkThreads () override
 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.
 
- Public Member Functions inherited from TGo4ServerTask
 TGo4ServerTask (const char *name, UInt_t negotiationport=0, Bool_t blockingmode=kFALSE, Bool_t standalone=kFALSE, Bool_t autostart=kTRUE, Bool_t autocreate=kTRUE, Bool_t ismaster=kTRUE)
 
virtual ~TGo4ServerTask ()
 
Bool_t ConnectorThreadIsStopped ()
 Returns the waiting state fbIsWaiting of the Connector Thread;.
 
TGo4BufferQueueGetCommandQueue (const char *task=nullptr) override
 
const char * GetConnectHost () const
 
const char * GetConnectorName () const
 
TGo4SocketGetConnectTransport ()
 
TGo4TaskHandlerGetCurrentTaskHandler ()
 Get task handler of the currently activated client connection.
 
TGo4BufferQueueGetDataQueue (const char *task=nullptr) override
 
TGo4BufferQueueGetStatusQueue (const char *task=nullptr) override
 
TGo4TaskHandlerGetTaskHandler () override
 Get task handler for client specified by name.
 
TGo4TaskHandlerGetTaskHandler (const char *name)
 Get task handler for client specified by name.
 
TGo4TaskManagerGetTaskManager ()
 
TGo4CommandNextCommand () override
 Delivers next command.
 
void Quit () override
 Quit method used by quit command; may be overridden in special application.
 
virtual Int_t RemoveAllClients (Bool_t force=false)
 Remove all connected client task from this server.
 
virtual Bool_t RemoveClient (const char *name, Bool_t clientwait=kTRUE, Bool_t isterminating=kFALSE)
 Remove the client task specified by name from this server.
 
Bool_t RemoveCurrentClient ()
 removes the currently active client from server (disconnect)
 
void SendStatus (TGo4Status *stat, const char *receiver=nullptr) override
 Send status object via status channel to the master.
 
void SendStatusBuffer () override
 Send internal status buffer to the master(s).
 
void SetConnect (TGo4Socket *trans, const char *host, UInt_t port, Bool_t keepserv=kFALSE)
 
void SetCurrentTask (const char *name)
 sets current client task (i.e.
 
void SetDisConnect (TGo4Socket *trans)
 
void Shutdown ()
 Fast Quit() without waiting for proper disconnection.
 
virtual Bool_t StartConnectorThread ()
 starts the thread that listens to the connector port for a client negotiation request; used after launching an rsh client from server
 
virtual Bool_t StopConnectorThread ()
 stops the thread that listens to the connector port for a client negotiation request; used before launching an rsh client from server.
 
virtual Int_t TimerConnect ()
 this method is used by the connectortimer Notify to connect or disconnect a transportchannel (TSocket) on demand; the connection process itself is handled by the connector runnable which uses services of the TaskManager class
 
Int_t WaitForClose ()
 
Int_t WaitForConnection ()
 
Int_t WaitForOpen ()
 
- 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 TGo4TaskStatusCreateStatus ()
 create a status object with information on the current (slave) task.
 
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.
 
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.
 
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 void Stop ()
 General stop method of client application to be called from remote command; should be re-implemented by application.
 
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 ()
 

Static Public Attributes

static const char * fgcCONTROLTHREAD ="CONTROL-"
 suffix for controller thread name
 
static const char * fgcLOGGINGTHREAD ="LOGGER-"
 suffix for logging thread name
 
- Static Public Attributes inherited from TGo4ThreadManager
static const Long_t fglTIMERPERIOD = 200
 Period in ms for the application control timer.
 

Private Member Functions

 TGo4ExampleServer ()
 

Private Attributes

TString fcControlName
 remember name of controller thread
 
TString fcLoggingName
 remember name of logging thread
 
TGo4ExampleControllerfxController {nullptr}
 aggregationByValue 1 0..1
 

Additional Inherited Members

- Public Types inherited from TGo4ServerTask
enum  ELaunchmodes { kSecureShell = BIT(0) , kGuiEmbed = BIT(1) }
 
- Public Types inherited from TGo4ThreadManager
enum  { fguTEXTLENGTH = 256 }
 Default textlength for char arrays. More...
 
- Static Public Member Functions inherited from TGo4ServerTask
static const char * Get_fgcLAUNCHPREFSFILE ()
 
- Static Public Member Functions inherited from TGo4Task
static Int_t Get_fgiTERMID ()
 
- Protected Member Functions inherited from TGo4Task
TGo4ObjectQueueGetLocalCommandQueue ()
 
TGo4TaskHandlerCommandListGetPrototype ()
 get pointer to currently valid command list
 
void SetMaster (Bool_t on=kTRUE)
 
void SetWorkIsStopped (Bool_t on)
 
virtual void UpdateStatus (TGo4TaskStatus *state)
 method needed by method CreateStatus of any status subclasses to set the values of the clienttask specific part of the status object.
 
- 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.
 
- Static Protected Attributes inherited from TGo4ServerTask
static const char * fgcLAUNCHPREFSFILE = "etc/Go4LaunchPrefs.txt"
 Name of the Preferences file for the client startup.
 
static const Int_t fgiCLOSEWAITCYCLES =100
 maximum cycles to wait until transport is closed
 
static const Int_t fgiCONNECTWAITCYCLES =20
 maximum cycles to wait until transport is connected
 
static const Int_t fgiOPENWAITCYCLES =100
 maximum cycles to wait until transport is open
 
static const UInt_t fguCLOSEWAITCYCLETIME =100
 time for each close wait cycle
 
static const UInt_t fguCONNECTTIMERPERIOD =100
 period of task connector timer
 
static const UInt_t fguCONNECTWAITCYCLETIME =200
 time for each connect wait cycle
 
static const UInt_t fguOPENWAITCYCLETIME =100
 time for each open wait cycle
 

Detailed Description

example class for a server task that fits to the example application

Definition at line 25 of file TGo4ExampleServer.h.

Constructor & Destructor Documentation

◆ TGo4ExampleServer() [1/2]

TGo4ExampleServer::TGo4ExampleServer ( const char * name,
UInt_t negotiationport = 0,
Bool_t blockingmode = kFALSE )

◆ ~TGo4ExampleServer()

TGo4ExampleServer::~TGo4ExampleServer ( )
virtual

Definition at line 34 of file TGo4ExampleServer.cxx.

References fxController, TGo4ThreadManager::fxWorkHandler, and GO4TRACE.

◆ TGo4ExampleServer() [2/2]

TGo4ExampleServer::TGo4ExampleServer ( )
private

Member Function Documentation

◆ CreateCommandList()

TGo4TaskHandlerCommandList * TGo4ExampleServer::CreateCommandList ( )
overridevirtual

factory method for command list; overridden by implementation

Reimplemented from TGo4Task.

Definition at line 68 of file TGo4ExampleServer.cxx.

◆ GetController()

TGo4ExampleController * TGo4ExampleServer::GetController ( )

◆ StartWorkThreads()

Int_t TGo4ExampleServer::StartWorkThreads ( )
overridevirtual

start the working threads of the task implementation; this method is used after the current connection has changed, to continue reading/writing the queues.

To be overridden by the derived task.

Reimplemented from TGo4Task.

Definition at line 93 of file TGo4ExampleServer.cxx.

References TGo4Log::Debug(), fcControlName, fcLoggingName, TGo4ThreadManager::GetWorkHandler(), TGo4ThreadHandler::Start(), and TGo4Task::StartWorkThreads().

◆ StopWorkThreads()

Int_t TGo4ExampleServer::StopWorkThreads ( )
overridevirtual

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.

To be overridden by the derived task.

Reimplemented from TGo4Task.

Definition at line 73 of file TGo4ExampleServer.cxx.

References TGo4BufferQueue::AddBufferFromObject(), TGo4Log::Debug(), fcControlName, fcLoggingName, TGo4ServerTask::GetDataQueue(), TGo4ServerTask::GetStatusQueue(), TGo4ThreadManager::GetWorkHandler(), TGo4ThreadHandler::Stop(), and TGo4Task::StopWorkThreads().

Field Documentation

◆ fcControlName

TString TGo4ExampleServer::fcControlName
private

remember name of controller thread

Definition at line 59 of file TGo4ExampleServer.h.

Referenced by TGo4ExampleServer(), StartWorkThreads(), and StopWorkThreads().

◆ fcLoggingName

TString TGo4ExampleServer::fcLoggingName
private

remember name of logging thread

Definition at line 62 of file TGo4ExampleServer.h.

Referenced by TGo4ExampleServer(), StartWorkThreads(), and StopWorkThreads().

◆ fgcCONTROLTHREAD

const char * TGo4ExampleServer::fgcCONTROLTHREAD ="CONTROL-"
static

suffix for controller thread name

Definition at line 44 of file TGo4ExampleServer.h.

Referenced by TGo4ExampleServer().

◆ fgcLOGGINGTHREAD

const char * TGo4ExampleServer::fgcLOGGINGTHREAD ="LOGGER-"
static

suffix for logging thread name

Definition at line 47 of file TGo4ExampleServer.h.

Referenced by TGo4ExampleServer().

◆ fxController

TGo4ExampleController* TGo4ExampleServer::fxController {nullptr}
private

aggregationByValue 1 0..1

Definition at line 56 of file TGo4ExampleServer.h.

Referenced by TGo4ExampleServer(), ~TGo4ExampleServer(), and GetController().


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