Logo ROOT   6.12/07
Reference Guide
games.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_gui
3 /// This macro runs three "games" that each nicely illustrate the graphics capabilities of ROOT.
4 /// Thanks to the clever usage of TTimer objects it looks like they are all executing in parallel (emulation of multi-threading).
5 /// It uses the small classes generated in $ROOTSYS/test/Hello, Aclock, Tetris
6 ///
7 /// \macro_code
8 ///
9 /// \author Valeriy Onuchin
10 
11 #ifndef __RUN_GAMES__
12 
13 void games()
14 {
15  gSystem->Load("libGui");
16  Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0;
17  Int_t st1 = gSystem->Load("$(ROOTSYS)/test/Aclock");
18  if (st1 == -1) {
19  printf("===>The macro games will try to build the Aclock library\n");
20  if (UNIX)
21  gSystem->Exec("(cd $ROOTSYS/test; make Aclock)");
22  else
23  gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Aclock.dll)");
24 
25  st1 = gSystem->Load("$(ROOTSYS)/test/Aclock");
26  }
27  Int_t st2 = gSystem->Load("$(ROOTSYS)/test/Hello");
28  if (st2 == -1) {
29  printf("===>The macro games will try to build the Hello library\n");
30  if (UNIX)
31  gSystem->Exec("(cd $ROOTSYS/test; make Hello)");
32  else
33  gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Hello.dll)");
34 
35  st2 = gSystem->Load("$(ROOTSYS)/test/Hello");
36  }
37  Int_t st3 = gSystem->Load("$(ROOTSYS)/test/Tetris");
38  if (st3 == -1) {
39  if (UNIX) {
40  printf("===>The macro games will try to build the Tetris library\n");
41  gSystem->Exec("(cd $ROOTSYS/test; make Tetris)");
42  } else {
43  gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Tetris.dll)");
44  }
45  st3 = gSystem->Load("$(ROOTSYS)/test/Tetris");
46  }
47  if (st1 || st2 || st3) {
48  printf("ERROR: one of the shared libs in $ROOTSYS/test didn't load properly\n");
49  return;
50  }
51  gROOT->ProcessLine("#define __RUN_GAMES__ 1");
52  gROOT->ProcessLine("#include \"games.C\"");
53  gROOT->ProcessLine("rungames()");
54  gROOT->ProcessLine("#undef __RUN_GAMES__");
55 }
56 
57 #else
58 
59 class Hello;
60 class Aclock;
61 class Tetris;
62 
63 void rungames()
64 {
65  // run the dancing Hello World
66  Hello *hello = new Hello();
67 
68  // run the analog clock
69  Aclock *clock = new Aclock();
70 
71  // run the Tetris game
72  Tetris *tetris = new Tetris();
73 }
74 
75 #endif
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
std::string hello(std::string who, std::string msg)
Definition: FunModule.C:5
#define gROOT
Definition: TROOT.h:402
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1829
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:661