Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
34class TObjArray;
35class TTimer;
36class TSignalHandler;
37
38
39class TApplication : public TObject, public TQObject {
40
41public:
42 // TApplication specific bits
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 };
54 kAbort
55 };
56
57private:
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 std::atomic<bool> 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 TObjArray *fFiles; //Array of input files or C++ expression (TObjString's) specified via argv
67 TString fWorkDir; //Working directory specified via argv
68 TString fIdleCommand; //Command to execute while application is idle
69 TTimer *fIdleTimer; //Idle timer
70 TSignalHandler *fSigHandler; //Interrupt handler
71 EExitOnException fExitOnException; //Exit on exception option
72
73 static Bool_t fgGraphNeeded; // True if graphics libs need to be initialized
74 static Bool_t fgGraphInit; // True if graphics libs initialized
75
76 TApplication(const TApplication&) = delete;
78
79protected:
80 TApplication *fAppRemote; //Current remote application, if defined
81
82 static TList *fgApplications; //List of available applications
83
85
86 virtual Longptr_t ProcessRemote(const char *line, Int_t *error = nullptr);
87 virtual void Forum(const char *line);
88 virtual void GitHub(const char *line);
89 virtual void Help(const char *line);
90 virtual void LoadGraphicsLibs();
91 virtual void MakeBatch();
93
94 static Int_t ParseRemoteLine(const char *ln,
95 TString &hostdir, TString &user,
96 Int_t &dbg, TString &script);
97 static TApplication *Open(const char *url, Int_t debug, const char *script);
98 static void Close(TApplication *app);
99
100public:
101 TApplication(const char *appClassName, Int_t *argc, char **argv,
102 void *options = nullptr, Int_t numOptions = 0);
103 virtual ~TApplication();
104
105 void InitializeGraphics(Bool_t only_web = kFALSE);
106 virtual void GetOptions(Int_t *argc, char **argv);
108 virtual void SetEchoMode(Bool_t mode);
110 void OpenForumTopic(const TString & type);
111 void OpenGitHubIssue(const TString & type);
112 void OpenInBrowser(const TString & url);
113 void OpenReferenceGuideFor(const TString & strippedClass);
114 virtual void HandleException(Int_t sig);
115 virtual void HandleIdleTimer(); //*SIGNAL*
116 virtual Bool_t HandleTermInput() { return kFALSE; }
117 virtual void Init() { fAppImp->Init(); }
118 virtual Longptr_t ProcessLine(const char *line, Bool_t sync = kFALSE, Int_t *error = nullptr);
119 virtual Longptr_t ProcessFile(const char *file, Int_t *error = nullptr, Bool_t keep = kFALSE);
120 virtual void Run(Bool_t retrn = kFALSE);
121 virtual void SetIdleTimer(UInt_t idleTimeInSec, const char *command);
122 virtual void RemoveIdleTimer();
123 const char *GetIdleCommand() const { return fIdleCommand; }
124 virtual void StartIdleing();
125 virtual void StopIdleing();
127
128 virtual const char *ApplicationName() const { return fAppImp->ApplicationName(); }
129 virtual void Show() { fAppImp->Show(); }
130 virtual void Hide() { fAppImp->Hide(); }
131 virtual void Iconify() { fAppImp->Iconify(); }
132 virtual void Open() { fAppImp->Open(); }
133 virtual void Raise() { fAppImp->Raise(); }
134 virtual void Lower() { fAppImp->Lower(); }
135 virtual Bool_t IsCmdThread() { return fAppImp ? fAppImp->IsCmdThread() : kTRUE; }
137
138 void ls(Option_t *option="") const override;
139
140 Int_t Argc() const { return fArgc; }
141 char **Argv() const { return fArgv; }
142 char *Argv(Int_t index) const;
143 Bool_t NoLogOpt() const { return fNoLog; }
144 Bool_t NoLogoOpt() const { return fNoLogo; }
145 Bool_t QuitOpt() const { return fQuit; }
146 TObjArray *InputFiles() const { return fFiles; }
147 const char *WorkingDirectory() const { return fWorkDir; }
148 void ClearInputFiles();
149
151
152 Bool_t IsRunning() const { return fIsRunning; }
155
156 virtual void LineProcessed(const char *line); //*SIGNAL*
157 virtual void Terminate(Int_t status = 0); //*SIGNAL*
158 virtual void KeyPressed(Int_t key); //*SIGNAL*
159 virtual void ReturnPressed(char *text ); //*SIGNAL*
160 virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream& out);
161
162 static Longptr_t ExecuteFile(const char *file, Int_t *error = nullptr, Bool_t keep = kFALSE);
163 static TList *GetApplications();
164 static void CreateApplication();
165 static void NeedGraphicsLibs();
166
167 ClassDefOverride(TApplication,0) //GUI application singleton
168};
169
171
172#endif
#define R__EXTERN
Definition DllImport.h:27
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
R__EXTERN TApplication * gApplication
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char text
ABC describing GUI independent application implementation protocol.
virtual void Show()
virtual const char * ApplicationName() const
virtual void Raise()
virtual void Hide()
virtual void Init()
virtual void Iconify()
virtual void Lower()
virtual Bool_t IsCmdThread()
virtual void Open()
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
EExitOnException ExitOnException(EExitOnException opt=kExit)
Set the exit on exception option.
virtual void KeyPressed(Int_t key)
Emit signal when console keyboard key was pressed.
virtual Longptr_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr)
Process a single command line, either a C++ statement or an interpreter command starting with a "....
static TList * fgApplications
static void Close(TApplication *app)
Static function used to close a remote application.
virtual Bool_t HandleTermInput()
Bool_t IsRunning() const
virtual void SetEchoMode(Bool_t mode)
Set console echo mode:
TObjArray * InputFiles() const
virtual void Help(const char *line)
The function lists useful commands (".help") or opens the online reference guide, generated with Doxy...
virtual void LineProcessed(const char *line)
Emit signal when a line has been processed.
void ClearInputFiles()
Clear list containing macro files passed as program arguments.
TApplicationImp * fAppImp
TApplication(const TApplication &)=delete
static Longptr_t ExecuteFile(const char *file, Int_t *error=nullptr, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
TSignalHandler * GetSignalHandler() const
void InitializeGraphics(Bool_t only_web=kFALSE)
Initialize the graphics environment.
virtual void Open()
virtual void LoadGraphicsLibs()
Load shared libs necessary for graphics.
virtual void StopIdleing()
Called when system stops idleing.
virtual void Iconify()
Bool_t ReturnFromRun() const
virtual void StartIdleing()
Called when system starts idleing.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
virtual ~TApplication()
TApplication dtor.
virtual void Lower()
void OpenReferenceGuideFor(const TString &strippedClass)
It opens the online reference guide, generated with Doxygen, for the chosen scope (class/namespace/st...
virtual void HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
virtual void MakeBatch()
Switch to batch mode.
void OpenGitHubIssue(const TString &type)
It opens a GitHub issue in a web browser with prefilled ROOT version.
virtual void Hide()
Bool_t fReturnFromRun
virtual void Init()
TString fIdleCommand
char ** Argv() const
static Bool_t fgGraphNeeded
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
TApplication * GetAppRemote() const
void OpenInBrowser(const TString &url)
The function generates and executes a command that loads the Doxygen URL in a browser.
virtual const char * ApplicationName() const
virtual void Forum(const char *line)
The function (".forum <type>") submits a new post on the ROOT forum via web browser.
void SetReturnFromRun(Bool_t ret)
virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out)
What to do when tab is pressed.
EExitOnException fExitOnException
virtual TApplicationImp * GetApplicationImp()
TObjArray * fFiles
const char * GetIdleCommand() const
TApplication()
Default ctor. Can be used by classes deriving from TApplication.
virtual Longptr_t ProcessFile(const char *file, Int_t *error=nullptr, Bool_t keep=kFALSE)
Process a file containing a C++ macro.
void OpenForumTopic(const TString &type)
It opens a Forum topic in a web browser with prefilled ROOT version.
TString fWorkDir
virtual void ReturnPressed(char *text)
Emit signal when return key was pressed.
static Bool_t fgGraphInit
virtual void RemoveIdleTimer()
Remove idle timer. Normally called via TROOT::Idle(0).
Bool_t NoLogOpt() const
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 GitHub(const char *line)
The function (".gh <type>") submits a new issue on GitHub via web browser.
static void CreateApplication()
Static function used to create a default application environment.
virtual void GetOptions(Int_t *argc, char **argv)
Get and handle command line options.
Bool_t NoLogoOpt() const
static TList * GetApplications()
Static method returning the list of available applications.
std::atomic< bool > fIsRunning
Window system specific application implementation.
TApplication & operator=(const TApplication &)=delete
static void NeedGraphicsLibs()
Static method.
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.
TTimer * fIdleTimer
virtual Bool_t IsCmdThread()
void ls(Option_t *option="") const override
Show available sessions.
virtual void Raise()
TString GetSetup()
It gets the ROOT installation setup as TString.
virtual void HandleIdleTimer()
Handle idle timeout.
const char * WorkingDirectory() const
Bool_t QuitOpt() const
TSignalHandler * fSigHandler
Int_t Argc() const
virtual Longptr_t ProcessRemote(const char *line, Int_t *error=nullptr)
Process the content of a line starting with ".R" (already stripped-off) The format is.
TApplication * fAppRemote
virtual void Show()
void SetSignalHandler(TSignalHandler *sh)
char ** fArgv
A doubly linked list.
Definition TList.h:38
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition TQObject.h:48
Basic string class.
Definition TString.h:139
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
TLine * line
Definition file.py:1