GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4MainRunnable.cxx
Go to the documentation of this file.
1 // $Id: TGo4MainRunnable.cxx 2627 2019-10-01 08:02:45Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4MainRunnable.h"
15 
16 #include "TGo4Log.h"
17 #include "TGo4LockGuard.h"
18 #include "TGo4Thread.h"
19 
20 #include "TGo4CommandInvoker.h"
21 #include "TGo4LogicException.h"
22 
24 : TGo4Runnable(name,cli)
25 {
26  GO4TRACE((15,"TGo4MainRunnable::TGo4MainRunnable(const char*,TGo4ExampleClient*) constructor",__LINE__, __FILE__));
28 }
29 
31 {
32  GO4TRACE((15,"TGo4MainRunnable::~TGo4MainRunnable() destructor",__LINE__, __FILE__));
33 }
34 
36 {
37  GO4TRACE((12,"TGo4MainRunnable::Run()",__LINE__, __FILE__));
38  // first test: simply wait for command, then execute it and send back an object
39  TGo4Command* com=0;
40  TGo4ExampleClient* cli= dynamic_cast<TGo4ExampleClient*> (fxManager);
41  if(!cli)
42  throw TGo4LogicException();
43  com=cli->NextCommand();
44  if(com!=0)
45  {
46  TGo4LockGuard mainlock; // protect command invocation!
47  TGo4CommandInvoker::Instance()->Invoke(com); // execute command by invoker
48  delete com;
49  }
50  else
51  { }
52  // do "main event loop"...
55  return 0;
56 }
TGo4ThreadManager * fxManager
Definition: TGo4Runnable.h:71
TGo4ExampleApplication * fxApplication
virtual TGo4Command * NextCommand()
Definition: TGo4Task.cxx:339
static void Sleep(UInt_t millisecs)
Definition: TGo4Thread.cxx:335
virtual Int_t Run(void *)
static TGo4CommandInvoker * Instance()
virtual void Invoke(TGo4Command *com)
virtual ~TGo4MainRunnable()
#define GO4TRACE(X)
Definition: TGo4Log.h:26
TGo4ExampleApplication * GetApplication()