Logo ROOT   6.12/07
Reference Guide
TApplication.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 22/12/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TApplication
13 #define ROOT_TApplication
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TApplication //
19 // //
20 // This class creates the ROOT Application Environment that interfaces //
21 // to the windowing system eventloop and eventhandlers. //
22 // This class must be instantiated exactly once in any given //
23 // application. Normally the specific application class inherits from //
24 // TApplication (see TRint). //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #include "TObject.h"
29 
30 #include "TQObject.h"
31 
32 #include "TApplicationImp.h"
33 
34 class TObjArray;
35 class TTimer;
36 class TSignalHandler;
37 
38 
39 class TApplication : public TObject, public TQObject {
40 
41 public:
42  // TApplication specific bits
43  enum EStatusBits {
44  kProcessRemotely = BIT(15), // TRUE if this line has to be processed remotely
45  kDefaultApplication = BIT(16) // TRUE if created via CreateApplication()
46  };
47  // TApplication specific bits for fFiles
48  enum EFileBits {
49  kExpression = BIT(14) // If the arguments is an expression rather than a file.
50  };
55  };
56 
57 private:
58  Int_t fArgc; //Number of com mand line arguments
59  char **fArgv; //Command line arguments
60  TApplicationImp *fAppImp; //!Window system specific application implementation
61  Bool_t fIsRunning; //True when in event loop (Run() has been called)
62  Bool_t fReturnFromRun; //When true return from Run()
63  Bool_t fNoLog; //Do not process logon and logoff macros
64  Bool_t fNoLogo; //Do not show splash screen and welcome message
65  Bool_t fQuit; //Exit after having processed input files
66  Bool_t fUseMemstat; //Run with TMemStat enabled
67  TObjArray *fFiles; //Array of input files or C++ expression (TObjString's) specified via argv
68  TString fWorkDir; //Working directory specified via argv
69  TString fIdleCommand; //Command to execute while application is idle
70  TTimer *fIdleTimer; //Idle timer
71  TSignalHandler *fSigHandler; //Interrupt handler
72  EExitOnException fExitOnException; //Exit on exception option
73 
74  static Bool_t fgGraphNeeded; // True if graphics libs need to be initialized
75  static Bool_t fgGraphInit; // True if graphics libs initialized
76 
77  TApplication(const TApplication&); // not implemented
78  TApplication& operator=(const TApplication&); // not implemented
79 
80 protected:
81  TApplication *fAppRemote; //Current remote application, if defined
82 
83  static TList *fgApplications; //List of available applications
84 
85  TApplication();
86 
87  virtual Long_t ProcessRemote(const char *line, Int_t *error = 0);
88  virtual void Help(const char *line);
89  virtual void LoadGraphicsLibs();
90  virtual void MakeBatch();
91  void SetSignalHandler(TSignalHandler *sh) { fSigHandler = sh; }
92 
93  static Int_t ParseRemoteLine(const char *ln,
94  TString &hostdir, TString &user,
95  Int_t &dbg, TString &script);
96  static TApplication *Open(const char *url, Int_t debug, const char *script);
97  static void Close(TApplication *app);
98 
99 public:
100  TApplication(const char *appClassName, Int_t *argc, char **argv,
101  void *options = 0, Int_t numOptions = 0);
102  virtual ~TApplication();
103 
104  void InitializeGraphics();
105  virtual void GetOptions(Int_t *argc, char **argv);
107  virtual void SetEchoMode(Bool_t mode);
108 
109  virtual void HandleException(Int_t sig);
110  virtual void HandleIdleTimer(); //*SIGNAL*
111  virtual Bool_t HandleTermInput() { return kFALSE; }
112  virtual void Init() { fAppImp->Init(); }
113  virtual Long_t ProcessLine(const char *line, Bool_t sync = kFALSE, Int_t *error = 0);
114  virtual Long_t ProcessFile(const char *file, Int_t *error = 0, Bool_t keep = kFALSE);
115  virtual void Run(Bool_t retrn = kFALSE);
116  virtual void SetIdleTimer(UInt_t idleTimeInSec, const char *command);
117  virtual void RemoveIdleTimer();
118  const char *GetIdleCommand() const { return fIdleCommand; }
119  virtual void StartIdleing();
120  virtual void StopIdleing();
122 
123  virtual const char *ApplicationName() const { return fAppImp->ApplicationName(); }
124  virtual void Show() { fAppImp->Show(); }
125  virtual void Hide() { fAppImp->Hide(); }
126  virtual void Iconify() { fAppImp->Iconify(); }
127  virtual void Open() { fAppImp->Open(); }
128  virtual void Raise() { fAppImp->Raise(); }
129  virtual void Lower() { fAppImp->Lower(); }
130  virtual Bool_t IsCmdThread() { return fAppImp ? fAppImp->IsCmdThread() : kTRUE; }
132 
133  virtual void ls(Option_t *option="") const;
134 
135  Int_t Argc() const { return fArgc; }
136  char **Argv() const { return fArgv; }
137  char *Argv(Int_t index) const;
138  Bool_t NoLogOpt() const { return fNoLog; }
139  Bool_t NoLogoOpt() const { return fNoLogo; }
140  Bool_t QuitOpt() const { return fQuit; }
141  TObjArray *InputFiles() const { return fFiles; }
142  const char *WorkingDirectory() const { return fWorkDir; }
143  void ClearInputFiles();
144 
145  TApplication *GetAppRemote() const { return fAppRemote; }
146 
147  Bool_t IsRunning() const { return fIsRunning; }
148  Bool_t ReturnFromRun() const { return fReturnFromRun; }
149  void SetReturnFromRun(Bool_t ret) { fReturnFromRun = ret; }
150 
151  virtual void LineProcessed(const char *line); //*SIGNAL*
152  virtual void Terminate(Int_t status = 0); //*SIGNAL*
153  virtual void KeyPressed(Int_t key); //*SIGNAL*
154  virtual void ReturnPressed(char *text ); //*SIGNAL*
155  virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream& out);
156 
157  static Long_t ExecuteFile(const char *file, Int_t *error = 0, Bool_t keep = kFALSE);
158  static TList *GetApplications();
159  static void CreateApplication();
160  static void NeedGraphicsLibs();
161 
162  ClassDef(TApplication,0) //GUI application singleton
163 };
164 
166 
167 #endif
virtual void LoadGraphicsLibs()
Load shared libs necessary for graphics.
virtual void Raise()
virtual Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=0)
Process a single command line, either a C++ statement or an interpreter command starting with a "...
An array of TObjects.
Definition: TObjArray.h:37
virtual void ls(Option_t *option="") const
Show available sessions.
Bool_t fReturnFromRun
Definition: TApplication.h:62
static Bool_t fgGraphInit
Definition: TApplication.h:75
TLine * line
const char Option_t
Definition: RtypesCore.h:62
virtual void Open()
#define BIT(n)
Definition: Rtypes.h:78
Bool_t NoLogOpt() const
Definition: TApplication.h:138
const char * WorkingDirectory() const
Definition: TApplication.h:142
virtual void Hide()
Definition: TApplication.h:125
virtual void MakeBatch()
Switch to batch mode.
TString fIdleCommand
Definition: TApplication.h:69
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:49
Basic string class.
Definition: TString.h:125
TSignalHandler * fSigHandler
Definition: TApplication.h:71
virtual TApplicationImp * GetApplicationImp()
Definition: TApplication.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static Bool_t fgGraphNeeded
Definition: TApplication.h:74
virtual const char * ApplicationName() const
EExitOnException fExitOnException
Definition: TApplication.h:72
virtual void ReturnPressed(char *text)
Emit signal when return key was pressed.
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
virtual Long_t ProcessRemote(const char *line, Int_t *error=0)
Process the content of a line starting with ".R" (already stripped-off) The format is [user@]host[:di...
virtual void Iconify()
Bool_t fNoLogo
Definition: TApplication.h:64
virtual Bool_t HandleTermInput()
Definition: TApplication.h:111
ABC describing GUI independent application implementation protocol.
TString fWorkDir
Definition: TApplication.h:68
virtual void Show()
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void SetIdleTimer(UInt_t idleTimeInSec, const char *command)
Set the command to be executed after the system has been idle for idleTimeInSec seconds.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
static Int_t ParseRemoteLine(const char *ln, TString &hostdir, TString &user, Int_t &dbg, TString &script)
Parse the content of a line starting with ".R" (already stripped-off) The format is [user@]host[:dir]...
virtual ~TApplication()
TApplication dtor.
virtual void Init()
Definition: TApplication.h:112
virtual void Lower()
Definition: TApplication.h:129
virtual void Raise()
Definition: TApplication.h:128
virtual void Show()
Definition: TApplication.h:124
TApplication * GetAppRemote() const
Definition: TApplication.h:145
virtual void GetOptions(Int_t *argc, char **argv)
Get and handle command line options.
A doubly linked list.
Definition: TList.h:44
virtual Bool_t IsCmdThread()
Definition: TApplication.h:130
static TList * GetApplications()
Static method returning the list of available applications.
TObjArray * InputFiles() const
Definition: TApplication.h:141
virtual void Open()
Definition: TApplication.h:127
Bool_t fIsRunning
Window system specific application implementation.
Definition: TApplication.h:61
TObjArray * fFiles
Definition: TApplication.h:67
Bool_t NoLogoOpt() const
Definition: TApplication.h:139
void ClearInputFiles()
Clear list containing macro files passed as program arguments.
virtual const char * ApplicationName() const
Definition: TApplication.h:123
virtual void RemoveIdleTimer()
Remove idle timer. Normally called via TROOT::Idle(0).
static void NeedGraphicsLibs()
Static method.
void SetSignalHandler(TSignalHandler *sh)
Definition: TApplication.h:91
static Long_t ExecuteFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
virtual void Lower()
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t fUseMemstat
Definition: TApplication.h:66
TApplicationImp * fAppImp
Definition: TApplication.h:60
virtual void SetEchoMode(Bool_t mode)
Set console echo mode:
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
virtual void StopIdleing()
Called when system stops idleing.
TApplication * fAppRemote
Definition: TApplication.h:81
static void Close(TApplication *app)
Static function used to close a remote application.
virtual void Help(const char *line)
Print help on interpreter.
const Bool_t kFALSE
Definition: RtypesCore.h:88
static void CreateApplication()
Static function used to create a default application environment.
void InitializeGraphics()
Initialize the graphics environment.
long Long_t
Definition: RtypesCore.h:50
virtual void StartIdleing()
Called when system starts idleing.
Bool_t fNoLog
Definition: TApplication.h:63
Int_t Argc() const
Definition: TApplication.h:135
TSignalHandler * GetSignalHandler() const
Definition: TApplication.h:106
TText * text
virtual void KeyPressed(Int_t key)
Emit signal when console keyboard key was pressed.
const char * GetIdleCommand() const
Definition: TApplication.h:118
char ** Argv() const
Definition: TApplication.h:136
TApplication & operator=(const TApplication &)
virtual void Init()
TTimer * fIdleTimer
Definition: TApplication.h:70
virtual void LineProcessed(const char *line)
Emit signal when a line has been processed.
virtual void Hide()
char ** fArgv
Definition: TApplication.h:59
virtual Bool_t IsCmdThread()
virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out)
What to do when tab is pressed.
EExitOnException ExitOnException(EExitOnException opt=kExit)
Set the exit on exception option.
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void HandleIdleTimer()
Handle idle timeout.
#define R__EXTERN
Definition: DllImport.h:27
virtual void HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
Definition: file.py:1
Bool_t ReturnFromRun() const
Definition: TApplication.h:148
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
Definition: TApplication.h:39
Bool_t fQuit
Definition: TApplication.h:65
static TList * fgApplications
Definition: TApplication.h:83
Bool_t IsRunning() const
Definition: TApplication.h:147
void SetReturnFromRun(Bool_t ret)
Definition: TApplication.h:149
const Bool_t kTRUE
Definition: RtypesCore.h:87
Bool_t QuitOpt() const
Definition: TApplication.h:140
virtual void Iconify()
Definition: TApplication.h:126
virtual Long_t ProcessFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Process a file containing a C++ macro.
TApplication()
Default ctor. Can be used by classes deriving from TApplication.