Logo ROOT  
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();
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  void OpenInBrowser(const TString & url);
109  void OpenReferenceGuideFor(const TString & strippedClass);
110  virtual void HandleException(Int_t sig);
111  virtual void HandleIdleTimer(); //*SIGNAL*
112  virtual Bool_t HandleTermInput() { return kFALSE; }
113  virtual void Init() { fAppImp->Init(); }
114  virtual Long_t ProcessLine(const char *line, Bool_t sync = kFALSE, Int_t *error = 0);
115  virtual Long_t ProcessFile(const char *file, Int_t *error = 0, Bool_t keep = kFALSE);
116  virtual void Run(Bool_t retrn = kFALSE);
117  virtual void SetIdleTimer(UInt_t idleTimeInSec, const char *command);
118  virtual void RemoveIdleTimer();
119  const char *GetIdleCommand() const { return fIdleCommand; }
120  virtual void StartIdleing();
121  virtual void StopIdleing();
123 
124  virtual const char *ApplicationName() const { return fAppImp->ApplicationName(); }
125  virtual void Show() { fAppImp->Show(); }
126  virtual void Hide() { fAppImp->Hide(); }
127  virtual void Iconify() { fAppImp->Iconify(); }
128  virtual void Open() { fAppImp->Open(); }
129  virtual void Raise() { fAppImp->Raise(); }
130  virtual void Lower() { fAppImp->Lower(); }
131  virtual Bool_t IsCmdThread() { return fAppImp ? fAppImp->IsCmdThread() : kTRUE; }
133 
134  virtual void ls(Option_t *option="") const;
135 
136  Int_t Argc() const { return fArgc; }
137  char **Argv() const { return fArgv; }
138  char *Argv(Int_t index) const;
139  Bool_t NoLogOpt() const { return fNoLog; }
140  Bool_t NoLogoOpt() const { return fNoLogo; }
141  Bool_t QuitOpt() const { return fQuit; }
142  TObjArray *InputFiles() const { return fFiles; }
143  const char *WorkingDirectory() const { return fWorkDir; }
144  void ClearInputFiles();
145 
146  TApplication *GetAppRemote() const { return fAppRemote; }
147 
148  Bool_t IsRunning() const { return fIsRunning; }
149  Bool_t ReturnFromRun() const { return fReturnFromRun; }
151 
152  virtual void LineProcessed(const char *line); //*SIGNAL*
153  virtual void Terminate(Int_t status = 0); //*SIGNAL*
154  virtual void KeyPressed(Int_t key); //*SIGNAL*
155  virtual void ReturnPressed(char *text ); //*SIGNAL*
156  virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream& out);
157 
158  static Long_t ExecuteFile(const char *file, Int_t *error = 0, Bool_t keep = kFALSE);
159  static TList *GetApplications();
160  static void CreateApplication();
161  static void NeedGraphicsLibs();
162 
163  ClassDef(TApplication,0) //GUI application singleton
164 };
165 
167 
168 #endif
TApplication::Close
static void Close(TApplication *app)
TApplication::NoLogOpt
Bool_t NoLogOpt() const
Definition: TApplication.h:139
TApplication::MakeBatch
virtual void MakeBatch()
Switch to batch mode.
Definition: TApplication.cxx:1159
TApplication::fAppImp
TApplicationImp * fAppImp
Definition: TApplication.h:60
TApplication::ApplicationName
virtual const char * ApplicationName() const
Definition: TApplication.h:124
TApplication::fAppRemote
TApplication * fAppRemote
Definition: TApplication.h:81
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TApplication::kDefaultApplication
@ kDefaultApplication
Definition: TApplication.h:45
TApplicationImp::Lower
virtual void Lower()
Definition: TApplicationImp.h:47
TObjArray
Definition: TObjArray.h:37
TApplication::ReturnPressed
virtual void ReturnPressed(char *text)
TApplicationImp::Hide
virtual void Hide()
Definition: TApplicationImp.h:41
TApplication::HandleTermInput
virtual Bool_t HandleTermInput()
Definition: TApplication.h:112
TApplication::fgApplications
static TList * fgApplications
Definition: TApplication.h:83
TApplication::OpenInBrowser
void OpenInBrowser(const TString &url)
The function generates and executes a command that loads the Doxygen URL in a browser.
Definition: TApplication.cxx:641
TApplication::fWorkDir
TString fWorkDir
Definition: TApplication.h:68
TApplication::SetSignalHandler
void SetSignalHandler(TSignalHandler *sh)
Definition: TApplication.h:91
TApplication::QuitOpt
Bool_t QuitOpt() const
Definition: TApplication.h:141
TSignalHandler
Definition: TSysEvtHandler.h:127
TApplication::GetIdleCommand
const char * GetIdleCommand() const
Definition: TApplication.h:119
TApplication::ParseRemoteLine
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.
Definition: TApplication.cxx:1183
TApplicationImp.h
TApplicationImp
Definition: TApplicationImp.h:29
TApplication::fNoLog
Bool_t fNoLog
Definition: TApplication.h:63
TApplication::InitializeGraphics
void InitializeGraphics()
Initialize the graphics environment.
Definition: TApplication.cxx:260
TApplicationImp::ApplicationName
virtual const char * ApplicationName() const
Definition: TApplicationImp.h:39
TApplication::kExpression
@ kExpression
Definition: TApplication.h:49
TApplication::ExitOnException
EExitOnException ExitOnException(EExitOnException opt=kExit)
Set the exit on exception option.
Definition: TApplication.cxx:626
TApplication::~TApplication
virtual ~TApplication()
TApplication dtor.
Definition: TApplication.cxx:221
TApplication::LoadGraphicsLibs
virtual void LoadGraphicsLibs()
Load shared libs necessary for graphics.
Definition: TApplication.cxx:1098
TApplication::operator=
TApplication & operator=(const TApplication &)
Int_t
int Int_t
Definition: RtypesCore.h:45
TApplication::GetOptions
virtual void GetOptions(Int_t *argc, char **argv)
Get and handle command line options.
Definition: TApplication.cxx:355
TApplication::OpenReferenceGuideFor
void OpenReferenceGuideFor(const TString &strippedClass)
It opens the online reference guide, generated with Doxygen, for the chosen scope (class/namespace/st...
Definition: TApplication.cxx:960
TApplication::fArgv
char ** fArgv
Definition: TApplication.h:59
TApplication::ClearInputFiles
void ClearInputFiles()
Clear list containing macro files passed as program arguments.
Definition: TApplication.cxx:328
TApplication::HandleIdleTimer
virtual void HandleIdleTimer()
Handle idle timeout.
Definition: TApplication.cxx:589
TString
Definition: TString.h:136
TApplication::fIdleCommand
TString fIdleCommand
Definition: TApplication.h:69
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
text
TText * text
Definition: entrylist_figure1.C:10
TApplicationImp::Init
virtual void Init()
Definition: TApplicationImp.h:44
bool
TApplication::fgGraphNeeded
static Bool_t fgGraphNeeded
Definition: TApplication.h:74
TApplication::IsRunning
Bool_t IsRunning() const
Definition: TApplication.h:148
TApplication::ExecuteFile
static Long_t ExecuteFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
TApplication::Iconify
virtual void Iconify()
Definition: TApplication.h:127
TApplication::LineProcessed
virtual void LineProcessed(const char *line)
TApplication::fSigHandler
TSignalHandler * fSigHandler
Definition: TApplication.h:71
TQObject.h
TApplication::SetReturnFromRun
void SetReturnFromRun(Bool_t ret)
Definition: TApplication.h:150
TQObject
Definition: TQObject.h:48
TTimer
Definition: TTimer.h:51
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TApplication::ReturnFromRun
Bool_t ReturnFromRun() const
Definition: TApplication.h:149
TApplication::fQuit
Bool_t fQuit
Definition: TApplication.h:65
TApplication::kProcessRemotely
@ kProcessRemotely
Definition: TApplication.h:44
TApplication::TApplication
TApplication()
Default ctor. Can be used by classes deriving from TApplication.
Definition: TApplication.cxx:97
TApplication::ProcessLine
virtual Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=0)
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TApplication::GetSignalHandler
TSignalHandler * GetSignalHandler() const
Definition: TApplication.h:106
Long_t
long Long_t
Definition: RtypesCore.h:54
TApplication::KeyPressed
virtual void KeyPressed(Int_t key)
TApplication::kExit
@ kExit
Definition: TApplication.h:53
TApplication::StartIdleing
virtual void StartIdleing()
gApplication
R__EXTERN TApplication * gApplication
Definition: TApplication.h:166
TApplication::fReturnFromRun
Bool_t fReturnFromRun
Definition: TApplication.h:62
BIT
#define BIT(n)
Definition: Rtypes.h:85
TApplication::Lower
virtual void Lower()
Definition: TApplication.h:130
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TApplication::ls
virtual void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
TApplication::Terminate
virtual void Terminate(Int_t status=0)
TApplication::Raise
virtual void Raise()
Definition: TApplication.h:129
TApplication::RemoveIdleTimer
virtual void RemoveIdleTimer()
line
TLine * line
Definition: entrylistblock_figure1.C:235
TApplication::Run
virtual void Run(Bool_t retrn=kFALSE)
TApplication::fgGraphInit
static Bool_t fgGraphInit
Definition: TApplication.h:75
TApplication::WorkingDirectory
const char * WorkingDirectory() const
Definition: TApplication.h:143
TApplication::HandleException
virtual void HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
Definition: TApplication.cxx:602
TApplication::Open
virtual void Open()
Definition: TApplication.h:128
TApplicationImp::Raise
virtual void Raise()
Definition: TApplicationImp.h:46
TApplication::fIsRunning
Bool_t fIsRunning
Window system specific application implementation.
Definition: TApplication.h:61
TApplication::fFiles
TObjArray * fFiles
Definition: TApplication.h:67
TApplication::kAbort
@ kAbort
Definition: TApplication.h:54
TApplication::ProcessRemote
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.
Definition: TApplication.cxx:1249
TApplication::GetApplicationImp
virtual TApplicationImp * GetApplicationImp()
Definition: TApplication.h:132
TApplication::EFileBits
EFileBits
Definition: TApplication.h:48
TApplication::fExitOnException
EExitOnException fExitOnException
Definition: TApplication.h:72
TApplicationImp::Show
virtual void Show()
Definition: TApplicationImp.h:40
TApplication::fArgc
Int_t fArgc
Definition: TApplication.h:58
TApplication::NeedGraphicsLibs
static void NeedGraphicsLibs()
Static method.
Definition: TApplication.cxx:252
TApplication::Hide
virtual void Hide()
Definition: TApplication.h:126
TObject.h
TApplication::fNoLogo
Bool_t fNoLogo
Definition: TApplication.h:64
TApplication::fUseMemstat
Bool_t fUseMemstat
Definition: TApplication.h:66
file
Definition: file.py:1
TObject
Definition: TObject.h:37
TApplication::StopIdleing
virtual void StopIdleing()
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TApplicationImp::IsCmdThread
virtual Bool_t IsCmdThread()
Definition: TApplicationImp.h:43
TApplication::Help
virtual void Help(const char *line)
The function lists useful commands (".help") or opens the online reference guide, generated with Doxy...
Definition: TApplication.cxx:1060
TApplication::Init
virtual void Init()
Definition: TApplication.h:113
TApplication::CreateApplication
static void CreateApplication()
TApplication::SetIdleTimer
virtual void SetIdleTimer(UInt_t idleTimeInSec, const char *command)
R__EXTERN
#define R__EXTERN
Definition: DllImport.h:27
TApplication::kDontExit
@ kDontExit
Definition: TApplication.h:52
TApplication::SetEchoMode
virtual void SetEchoMode(Bool_t mode)
TApplication
Definition: TApplication.h:39
TApplication::EStatusBits
EStatusBits
Definition: TApplication.h:43
TApplicationImp::Open
virtual void Open()
Definition: TApplicationImp.h:45
TApplication::Show
virtual void Show()
Definition: TApplication.h:125
TApplicationImp::Iconify
virtual void Iconify()
Definition: TApplicationImp.h:42
TApplication::IsCmdThread
virtual Bool_t IsCmdThread()
Definition: TApplication.h:131
TApplication::Argc
Int_t Argc() const
Definition: TApplication.h:136
TApplication::fIdleTimer
TTimer * fIdleTimer
Definition: TApplication.h:70
TApplication::NoLogoOpt
Bool_t NoLogoOpt() const
Definition: TApplication.h:140
TApplication::TabCompletionHook
virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out)
TApplication::Argv
char ** Argv() const
Definition: TApplication.h:137
TApplication::EExitOnException
EExitOnException
Definition: TApplication.h:51
TApplication::ProcessFile
virtual Long_t ProcessFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
TList
Definition: TList.h:44
TApplication::GetApplications
static TList * GetApplications()
TApplication::InputFiles
TObjArray * InputFiles() const
Definition: TApplication.h:142
TApplication::GetAppRemote
TApplication * GetAppRemote() const
Definition: TApplication.h:146
int