ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TObject
29 #include "TObject.h"
30 #endif
31 
32 #ifndef ROOT_TQObject
33 #include "TQObject.h"
34 #endif
35 
36 #ifndef ROOT_TApplicationImp
37 #include "TApplicationImp.h"
38 #endif
39 
40 class TObjArray;
41 class TTimer;
42 class TSignalHandler;
43 
44 
45 class TApplication : public TObject, public TQObject {
46 
47 public:
48  // TApplication specific bits
49  enum EStatusBits {
50  kProcessRemotely = BIT(15), // TRUE if this line has to be processed remotely
51  kDefaultApplication = BIT(16) // TRUE if created via CreateApplication()
52  };
53  // TApplication specific bits for fFiles
54  enum EFileBits {
55  kExpression = BIT(14) // If the arguments is an expression rather than a file.
56  };
61  };
62 
63 private:
64  Int_t fArgc; //Number of com mand line arguments
65  char **fArgv; //Command line arguments
66  TApplicationImp *fAppImp; //!Window system specific application implementation
67  Bool_t fIsRunning; //True when in event loop (Run() has been called)
68  Bool_t fReturnFromRun; //When true return from Run()
69  Bool_t fNoLog; //Do not process logon and logoff macros
70  Bool_t fNoLogo; //Do not show splash screen and welcome message
71  Bool_t fQuit; //Exit after having processed input files
72  Bool_t fUseMemstat; //Run with TMemStat enabled
73  TObjArray *fFiles; //Array of input files or C++ expression (TObjString's) specified via argv
74  TString fWorkDir; //Working directory specified via argv
75  TString fIdleCommand; //Command to execute while application is idle
76  TTimer *fIdleTimer; //Idle timer
77  TSignalHandler *fSigHandler; //Interrupt handler
78  EExitOnException fExitOnException; //Exit on exception option
79 
80  static Bool_t fgGraphNeeded; // True if graphics libs need to be initialized
81  static Bool_t fgGraphInit; // True if graphics libs initialized
82 
83  TApplication(const TApplication&); // not implemented
84  TApplication& operator=(const TApplication&); // not implemented
85 
86 protected:
87  TApplication *fAppRemote; //Current remote application, if defined
88 
89  static TList *fgApplications; //List of available applications
90 
91  TApplication();
92 
93  virtual Long_t ProcessRemote(const char *line, Int_t *error = 0);
94  virtual void Help(const char *line);
95  virtual void LoadGraphicsLibs();
96  virtual void MakeBatch();
98 
99  static Int_t ParseRemoteLine(const char *ln,
100  TString &hostdir, TString &user,
101  Int_t &dbg, TString &script);
102  static TApplication *Open(const char *url, Int_t debug, const char *script);
103  static void Close(TApplication *app);
104 
105 public:
106  TApplication(const char *appClassName, Int_t *argc, char **argv,
107  void *options = 0, Int_t numOptions = 0);
108  virtual ~TApplication();
109 
110  void InitializeGraphics();
111  virtual void GetOptions(Int_t *argc, char **argv);
113  virtual void SetEchoMode(Bool_t mode);
114 
115  virtual void HandleException(Int_t sig);
116  virtual void HandleIdleTimer(); //*SIGNAL*
117  virtual Bool_t HandleTermInput() { return kFALSE; }
118  virtual void Init() { fAppImp->Init(); }
119  virtual Long_t ProcessLine(const char *line, Bool_t sync = kFALSE, Int_t *error = 0);
120  virtual Long_t ProcessFile(const char *file, Int_t *error = 0, Bool_t keep = kFALSE);
121  virtual void Run(Bool_t retrn = kFALSE);
122  virtual void SetIdleTimer(UInt_t idleTimeInSec, const char *command);
123  virtual void RemoveIdleTimer();
124  const char *GetIdleCommand() const { return fIdleCommand; }
125  virtual void StartIdleing();
126  virtual void StopIdleing();
128 
129  virtual const char *ApplicationName() const { return fAppImp->ApplicationName(); }
130  virtual void Show() { fAppImp->Show(); }
131  virtual void Hide() { fAppImp->Hide(); }
132  virtual void Iconify() { fAppImp->Iconify(); }
133  virtual void Open() { fAppImp->Open(); }
134  virtual void Raise() { fAppImp->Raise(); }
135  virtual void Lower() { fAppImp->Lower(); }
136  virtual Bool_t IsCmdThread() { return fAppImp ? fAppImp->IsCmdThread() : kTRUE; }
138 
139  virtual void ls(Option_t *option="") const;
140 
141  Int_t Argc() const { return fArgc; }
142  char **Argv() const { return fArgv; }
143  char *Argv(Int_t index) const;
144  Bool_t NoLogOpt() const { return fNoLog; }
145  Bool_t NoLogoOpt() const { return fNoLogo; }
146  Bool_t QuitOpt() const { return fQuit; }
147  TObjArray *InputFiles() const { return fFiles; }
148  const char *WorkingDirectory() const { return fWorkDir; }
149  void ClearInputFiles();
150 
151  TApplication *GetAppRemote() const { return fAppRemote; }
152 
153  Bool_t IsRunning() const { return fIsRunning; }
154  Bool_t ReturnFromRun() const { return fReturnFromRun; }
156 
157  virtual void LineProcessed(const char *line); //*SIGNAL*
158  virtual void Terminate(Int_t status = 0); //*SIGNAL*
159  virtual void KeyPressed(Int_t key); //*SIGNAL*
160  virtual void ReturnPressed(char *text ); //*SIGNAL*
161  virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream& out);
162 
163  static Long_t ExecuteFile(const char *file, Int_t *error = 0, Bool_t keep = kFALSE);
164  static TList *GetApplications();
165  static void CreateApplication();
166  static void NeedGraphicsLibs();
167 
168  ClassDef(TApplication,0) //GUI application singleton
169 };
170 
172 
173 #endif
virtual void LoadGraphicsLibs()
Load shared libs necessary for graphics.
virtual void Raise()
TApplication * GetAppRemote() const
Definition: TApplication.h:151
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:39
const char * GetIdleCommand() const
Definition: TApplication.h:124
Bool_t fReturnFromRun
Definition: TApplication.h:68
static Bool_t fgGraphInit
Definition: TApplication.h:81
TLine * line
const char Option_t
Definition: RtypesCore.h:62
Int_t Argc() const
Definition: TApplication.h:141
virtual void Open()
#define BIT(n)
Definition: Rtypes.h:120
virtual void Hide()
Definition: TApplication.h:131
virtual void MakeBatch()
Switch to batch mode.
TString fIdleCommand
Definition: TApplication.h:75
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:53
Basic string class.
Definition: TString.h:137
TSignalHandler * fSigHandler
Definition: TApplication.h:77
virtual TApplicationImp * GetApplicationImp()
Definition: TApplication.h:137
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static Bool_t fgGraphNeeded
Definition: TApplication.h:80
const Bool_t kFALSE
Definition: Rtypes.h:92
EExitOnException fExitOnException
Definition: TApplication.h:78
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...
Bool_t IsRunning() const
Definition: TApplication.h:153
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
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[:...
virtual void Iconify()
TObjArray * InputFiles() const
Definition: TApplication.h:147
Bool_t fNoLogo
Definition: TApplication.h:70
Bool_t ReturnFromRun() const
Definition: TApplication.h:154
TSignalHandler * GetSignalHandler() const
Definition: TApplication.h:112
virtual Bool_t HandleTermInput()
Definition: TApplication.h:117
Bool_t QuitOpt() const
Definition: TApplication.h:146
ABC describing GUI independent application implementation protocol.
TString fWorkDir
Definition: TApplication.h:74
virtual void Show()
#define ClassDef(name, id)
Definition: Rtypes.h:254
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[:di...
virtual ~TApplication()
TApplication dtor.
virtual void Init()
Definition: TApplication.h:118
virtual void Lower()
Definition: TApplication.h:135
virtual void Raise()
Definition: TApplication.h:134
virtual void Show()
Definition: TApplication.h:130
char * out
Definition: TBase64.cxx:29
virtual void GetOptions(Int_t *argc, char **argv)
Get and handle command line options.
A doubly linked list.
Definition: TList.h:47
virtual Bool_t IsCmdThread()
Definition: TApplication.h:136
Bool_t NoLogoOpt() const
Definition: TApplication.h:145
char ** Argv() const
Definition: TApplication.h:142
static TList * GetApplications()
Static method returning the list of available applications.
virtual void Open()
Definition: TApplication.h:133
Bool_t fIsRunning
Window system specific application implementation.
Definition: TApplication.h:67
TObjArray * fFiles
Definition: TApplication.h:73
void ClearInputFiles()
Clear list containing macro files passed as program arguments.
virtual void RemoveIdleTimer()
Remove idle timer. Normally called via TROOT::Idle(0).
static void NeedGraphicsLibs()
Static method.
void SetSignalHandler(TSignalHandler *sh)
Definition: TApplication.h:97
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:72
TApplicationImp * fAppImp
Definition: TApplication.h:66
virtual void SetEchoMode(Bool_t mode)
Set console echo mode:
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
virtual void StopIdleing()
Called when system stops idleing.
TApplication * fAppRemote
Definition: TApplication.h:87
static void Close(TApplication *app)
Static function used to close a remote application.
virtual void Help(const char *line)
Print help on interpreter.
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:69
tuple file
Definition: fildir.py:20
TText * text
virtual void KeyPressed(Int_t key)
Emit signal when console keyboard key was pressed.
virtual const char * ApplicationName() const
TApplication & operator=(const TApplication &)
virtual void Init()
TTimer * fIdleTimer
Definition: TApplication.h:76
virtual void LineProcessed(const char *line)
Emit signal when a line has been processed.
virtual void Hide()
char ** fArgv
Definition: TApplication.h:65
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:58
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...
bool debug
const char * WorkingDirectory() const
Definition: TApplication.h:148
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
Definition: TApplication.h:45
Bool_t fQuit
Definition: TApplication.h:71
static TList * fgApplications
Definition: TApplication.h:89
void SetReturnFromRun(Bool_t ret)
Definition: TApplication.h:155
virtual const char * ApplicationName() const
Definition: TApplication.h:129
const Bool_t kTRUE
Definition: Rtypes.h:91
Bool_t NoLogOpt() const
Definition: TApplication.h:144
virtual void Iconify()
Definition: TApplication.h:132
virtual Long_t ProcessFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Process a file containing a C++ macro.
virtual void ls(Option_t *option="") const
Show available sessions.
TApplication()
Default ctor. Can be used by classes deriving from TApplication.