Logo ROOT   6.18/05
Reference Guide
TApplication.cxx
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/** \class TApplication
13\ingroup Base
14
15This class creates the ROOT Application Environment that interfaces
16to the windowing system eventloop and eventhandlers.
17This class must be instantiated exactly once in any given
18application. Normally the specific application class inherits from
19TApplication (see TRint).
20*/
21
22#include "RConfigure.h"
23#include "Riostream.h"
24#include "TApplication.h"
25#include "TException.h"
26#include "TGuiFactory.h"
27#include "TVirtualX.h"
28#include "TROOT.h"
29#include "TSystem.h"
30#include "TString.h"
31#include "TError.h"
32#include "TObjArray.h"
33#include "TObjString.h"
34#include "TTimer.h"
35#include "TInterpreter.h"
36#include "TStyle.h"
37#include "TVirtualPad.h"
38#include "TEnv.h"
39#include "TColor.h"
40#include "TClassTable.h"
41#include "TPluginManager.h"
42#include "TClassTable.h"
43#include "TBrowser.h"
44#include "TUrl.h"
45#include "TVirtualMutex.h"
46
47#include "TApplicationCommandLineOptionsHelp.h"
48
49#include <stdlib.h>
50
54TList *TApplication::fgApplications = 0; // List of available applications
55
56////////////////////////////////////////////////////////////////////////////////
57
58class TIdleTimer : public TTimer {
59public:
60 TIdleTimer(Long_t ms) : TTimer(ms, kTRUE) { }
61 Bool_t Notify();
62};
63
64////////////////////////////////////////////////////////////////////////////////
65/// Notify handler.
66
67Bool_t TIdleTimer::Notify()
68{
70 Reset();
71 return kFALSE;
72}
73
74
76
78{
79 // Insure that the files, canvases and sockets are closed.
80
81 // If we get here, the tear down has started. We have no way to know what
82 // has or has not yet been done. In particular on Ubuntu, this was called
83 // after the function static in TSystem.cxx has been destructed. So we
84 // set gROOT in its end-of-life mode which prevents executing code, like
85 // autoloading libraries (!) that is pointless ...
86 if (gROOT) {
87 gROOT->SetBit(kInvalidObject);
88 gROOT->EndOfProcessCleanups();
89 }
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Default ctor. Can be used by classes deriving from TApplication.
94
96 fArgc(0), fArgv(0), fAppImp(0), fIsRunning(kFALSE), fReturnFromRun(kFALSE),
97 fNoLog(kFALSE), fNoLogo(kFALSE), fQuit(kFALSE), fUseMemstat(kFALSE),
98 fFiles(0), fIdleTimer(0), fSigHandler(0), fExitOnException(kDontExit),
99 fAppRemote(0)
100{
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// Create an application environment. The application environment
106/// provides an interface to the graphics system and eventloop
107/// (be it X, Windows, MacOS or BeOS). After creating the application
108/// object start the eventloop by calling its Run() method. The command
109/// line options recognized by TApplication are described in the GetOptions()
110/// method. The recognized options are removed from the argument array.
111/// The original list of argument options can be retrieved via the Argc()
112/// and Argv() methods. The appClassName "proofserv" is reserved for the
113/// PROOF system. The "options" and "numOptions" arguments are not used,
114/// except if you want to by-pass the argv processing by GetOptions()
115/// in which case you should specify numOptions<0. All options will
116/// still be available via the Argv() method for later use.
117
118TApplication::TApplication(const char *appClassName, Int_t *argc, char **argv,
119 void * /*options*/, Int_t numOptions) :
120 fArgc(0), fArgv(0), fAppImp(0), fIsRunning(kFALSE), fReturnFromRun(kFALSE),
121 fNoLog(kFALSE), fNoLogo(kFALSE), fQuit(kFALSE), fUseMemstat(kFALSE),
122 fFiles(0), fIdleTimer(0), fSigHandler(0), fExitOnException(kDontExit),
123 fAppRemote(0)
124{
126
127 // Create the list of applications the first time
128 if (!fgApplications)
129 fgApplications = new TList;
130
131 // Add the new TApplication early, so that the destructor of the
132 // default TApplication (if it is called in the block of code below)
133 // will not destroy the files, socket or TColor that have already been
134 // created.
135 fgApplications->Add(this);
136
138 // allow default TApplication to be replaced by a "real" TApplication
139 delete gApplication;
140 gApplication = 0;
141 gROOT->SetBatch(kFALSE);
143 }
144
145 if (gApplication) {
146 Error("TApplication", "only one instance of TApplication allowed");
147 fgApplications->Remove(this);
148 return;
149 }
150
151 if (!gROOT)
152 ::Fatal("TApplication::TApplication", "ROOT system not initialized");
153
154 if (!gSystem)
155 ::Fatal("TApplication::TApplication", "gSystem not initialized");
156
157 static Bool_t hasRegisterAtExit(kFALSE);
158 if (!hasRegisterAtExit) {
159 // If we are the first TApplication register the atexit)
161 hasRegisterAtExit = kTRUE;
162 }
163 gROOT->SetName(appClassName);
164
165 // copy command line arguments, can be later accessed via Argc() and Argv()
166 if (argc && *argc > 0) {
167 fArgc = *argc;
168 fArgv = (char **)new char*[fArgc];
169 }
170
171 for (int i = 0; i < fArgc; i++)
172 fArgv[i] = StrDup(argv[i]);
173
174 if (numOptions >= 0)
175 GetOptions(argc, argv);
176
177 if (fArgv)
179
180 // Tell TSystem the TApplication has been created
182
183 fAppImp = gGuiFactory->CreateApplicationImp(appClassName, argc, argv);
185
186 // Initialize the graphics environment
187 if (gClassTable->GetDict("TPad")) {
190 }
191
192 // Save current interpreter context
193 gInterpreter->SaveContext();
194 gInterpreter->SaveGlobalsContext();
195
196 // to allow user to interact with TCanvas's under WIN32
197 gROOT->SetLineHasBeenProcessed();
198
199 // activate TMemStat
200 if (fUseMemstat || gEnv->GetValue("Root.TMemStat", 0)) {
202 Int_t buffersize = gEnv->GetValue("Root.TMemStat.buffersize", 100000);
203 Int_t maxcalls = gEnv->GetValue("Root.TMemStat.maxcalls", 5000000);
204 const char *ssystem = gEnv->GetValue("Root.TMemStat.system","gnubuiltin");
205 if (maxcalls > 0) {
206 gROOT->ProcessLine(Form("new TMemStat(\"%s\",%d,%d);",ssystem,buffersize,maxcalls));
207 }
208 }
209
210 //Needs to be done last
211 gApplication = this;
212 gROOT->SetApplication(this);
213
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// TApplication dtor.
218
220{
221 for (int i = 0; i < fArgc; i++)
222 if (fArgv[i]) delete [] fArgv[i];
223 delete [] fArgv;
224
225 if (fgApplications)
226 fgApplications->Remove(this);
227
228 //close TMemStat
229 if (fUseMemstat) {
230 ProcessLine("TMemStat::Close()");
232 }
233
234 // Reduce the risk of the files or sockets being closed after the
235 // end of 'main' (or more exactly before the library start being
236 // unloaded).
237 if (fgApplications == 0 || fgApplications->FirstLink() == 0 ) {
239 }
240
241 // Now that all the canvases and files have been closed we can
242 // delete the implementation.
244}
245
246////////////////////////////////////////////////////////////////////////////////
247/// Static method. This method should be called from static library
248/// initializers if the library needs the low level graphics system.
249
251{
253}
254
255////////////////////////////////////////////////////////////////////////////////
256/// Initialize the graphics environment.
257
259{
260 if (fgGraphInit || !fgGraphNeeded) return;
261
262 // Load the graphics related libraries
264
265 // Try to load TrueType font renderer. Only try to load if not in batch
266 // mode and Root.UseTTFonts is true and Root.TTFontPath exists. Abort silently
267 // if libttf or libGX11TTF are not found in $ROOTSYS/lib or $ROOTSYS/ttf/lib.
268 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
270 char *ttfont = gSystem->Which(ttpath, "arialbd.ttf", kReadPermission);
271 // Check for use of DFSG - fonts
272 if (!ttfont)
273 ttfont = gSystem->Which(ttpath, "FreeSansBold.ttf", kReadPermission);
274
275#if !defined(R__WIN32)
276 if (!gROOT->IsBatch() && !strcmp(gVirtualX->GetName(), "X11") &&
277 ttfont && gEnv->GetValue("Root.UseTTFonts", 1)) {
278 if (gClassTable->GetDict("TGX11TTF")) {
279 // in principle we should not have linked anything against libGX11TTF
280 // but with ACLiC this can happen, initialize TGX11TTF by hand
281 // (normally this is done by the static library initializer)
282 ProcessLine("TGX11TTF::Activate();");
283 } else {
285 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualX", "x11ttf")))
286 if (h->LoadPlugin() == -1)
287 Info("InitializeGraphics", "no TTF support");
288 }
289 }
290#endif
291 delete [] ttfont;
292
293 // Create WM dependent application environment
294 if (fAppImp)
295 delete fAppImp;
297 if (!fAppImp) {
298 MakeBatch();
300 }
301
302 // Create the canvas colors early so they are allocated before
303 // any color table expensive bitmaps get allocated in GUI routines (like
304 // creation of XPM bitmaps).
306
307 // Hook for further initializing the WM dependent application environment
308 Init();
309
310 // Set default screen factor (if not disabled in rc file)
311 if (gEnv->GetValue("Canvas.UseScreenFactor", 1)) {
312 Int_t x, y;
313 UInt_t w, h;
314 if (gVirtualX) {
315 gVirtualX->GetGeometry(-1, x, y, w, h);
316 if (h > 0 && h < 1000) gStyle->SetScreenFactor(0.0011*h);
317 }
318 }
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Clear list containing macro files passed as program arguments.
323/// This method is called from TRint::Run() to ensure that the macro
324/// files are only executed the first time Run() is called.
325
327{
328 if (fFiles) {
329 fFiles->Delete();
331 }
332}
333
334////////////////////////////////////////////////////////////////////////////////
335/// Return specified argument.
336
337char *TApplication::Argv(Int_t index) const
338{
339 if (fArgv) {
340 if (index >= fArgc) {
341 Error("Argv", "index (%d) >= number of arguments (%d)", index, fArgc);
342 return 0;
343 }
344 return fArgv[index];
345 }
346 return 0;
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// Get and handle command line options. Arguments handled are removed
351/// from the argument array. See CommandLineOptionsHelp.h for options.
352
353void TApplication::GetOptions(Int_t *argc, char **argv)
354{
355 static char null[1] = { "" };
356
357 fNoLog = kFALSE;
358 fQuit = kFALSE;
359 fFiles = 0;
360
361 if (!argc)
362 return;
363
364 int i, j;
365 TString pwd;
366
367 for (i = 1; i < *argc; i++) {
368 if (!strcmp(argv[i], "-?") || !strncmp(argv[i], "-h", 2) ||
369 !strncmp(argv[i], "--help", 6)) {
370 fprintf(stderr, kCommandLineOptionsHelp);
371 Terminate(0);
372 } else if (!strncmp(argv[i], "--version", 9)) {
373 fprintf(stderr, "ROOT Version: %s\n", gROOT->GetVersion());
374 fprintf(stderr, "Built for %s on %s\n",
376 gROOT->GetGitDate());
377
378 fprintf(stderr, "From %s@%s\n",
379 gROOT->GetGitBranch(),
380 gROOT->GetGitCommit());
381
382 Terminate(0);
383 } else if (!strcmp(argv[i], "-config")) {
384 fprintf(stderr, "ROOT ./configure options:\n%s\n", gROOT->GetConfigOptions());
385 Terminate(0);
386 } else if (!strcmp(argv[i], "-memstat")) {
388 argv[i] = null;
389 } else if (!strcmp(argv[i], "-b")) {
390 MakeBatch();
391 argv[i] = null;
392 } else if (!strcmp(argv[i], "-n")) {
393 fNoLog = kTRUE;
394 argv[i] = null;
395 } else if (!strcmp(argv[i], "-t")) {
397 // EnableImplicitMT() only enables thread safety if IMT was configured;
398 // enable thread safety even with IMT off:
400 argv[i] = null;
401 } else if (!strcmp(argv[i], "-q")) {
402 fQuit = kTRUE;
403 argv[i] = null;
404 } else if (!strcmp(argv[i], "-l")) {
405 // used by front-end program to not display splash screen
406 fNoLogo = kTRUE;
407 argv[i] = null;
408 } else if (!strcmp(argv[i], "-x")) {
410 argv[i] = null;
411 } else if (!strcmp(argv[i], "-splash")) {
412 // used when started by front-end program to signal that
413 // splash screen can be popped down (TRint::PrintLogo())
414 argv[i] = null;
415 } else if (strncmp(argv[i], "--web", 5) == 0) {
416 // the web mode is requested
417 const char *opt = argv[i] + 5;
418 argv[i] = null;
419 TString argw;
420 if (gROOT->IsBatch()) argw = "batch";
421 if (*opt == '=') argw.Append(opt+1);
422 if (gSystem->Load("libROOTWebDisplay") >= 0) {
423 gROOT->SetWebDisplay(argw.Data());
424 gEnv->SetValue("Gui.Factory", "web");
425 } else {
426 Error("GetOptions", "--web option not supported, ROOT should be built with at least c++14 enabled");
427 }
428 } else if (!strcmp(argv[i], "-e")) {
429 argv[i] = null;
430 ++i;
431
432 if ( i < *argc ) {
433 if (!fFiles) fFiles = new TObjArray;
434 TObjString *expr = new TObjString(argv[i]);
435 expr->SetBit(kExpression);
436 fFiles->Add(expr);
437 argv[i] = null;
438 } else {
439 Warning("GetOptions", "-e must be followed by an expression.");
440 }
441 } else if (!strcmp(argv[i], "--")) {
442 TObjString* macro = nullptr;
443 bool warnShown = false;
444
445 if (fFiles) {
446 for (auto f: *fFiles) {
447 TObjString* file = dynamic_cast<TObjString*>(f);
448 if (!file) {
449 if (!dynamic_cast<TNamed*>(f)) {
450 Error("GetOptions()", "Inconsistent file entry (not a TObjString)!");
451 f->Dump();
452 } // else we did not find the file.
453 continue;
454 }
455
456 if (file->TestBit(kExpression))
457 continue;
458 if (file->String().EndsWith(".root"))
459 continue;
460 if (file->String().Contains('('))
461 continue;
462
463 if (macro && !warnShown && (warnShown = true))
464 Warning("GetOptions", "-- is used with several macros. "
465 "The arguments will be passed to the last one.");
466
467 macro = file;
468 }
469 }
470
471 if (macro) {
472 argv[i] = null;
473 ++i;
474 TString& str = macro->String();
475
476 str += '(';
477 for (; i < *argc; i++) {
478 str += argv[i];
479 str += ',';
480 argv[i] = null;
481 }
482 str.EndsWith(",") ? str[str.Length() - 1] = ')' : str += ')';
483 } else {
484 Warning("GetOptions", "no macro to pass arguments to was provided. "
485 "Everything after the -- will be ignored.");
486 for (; i < *argc; i++)
487 argv[i] = null;
488 }
489 } else if (argv[i][0] != '-' && argv[i][0] != '+') {
490 Long64_t size;
491 Long_t id, flags, modtime;
492 char *arg = strchr(argv[i], '(');
493 if (arg) *arg = '\0';
494 char *dir = gSystem->ExpandPathName(argv[i]);
495 // ROOT-9959: we do not continue if we could not expand the path
496 if (!dir) continue;
497 TUrl udir(dir, kTRUE);
498 // remove options and anchor to check the path
499 TString sfx = udir.GetFileAndOptions();
500 TString fln = udir.GetFile();
501 sfx.Replace(sfx.Index(fln), fln.Length(), "");
502 TString path = udir.GetFile();
503 if (strcmp(udir.GetProtocol(), "file")) {
504 path = udir.GetUrl();
505 path.Replace(path.Index(sfx), sfx.Length(), "");
506 }
507 // 'path' is the full URL without suffices (options and/or anchor)
508 if (arg) *arg = '(';
509 if (!arg && !gSystem->GetPathInfo(path.Data(), &id, &size, &flags, &modtime)) {
510 if ((flags & 2)) {
511 // if directory set it in fWorkDir
512 if (pwd == "") {
513 pwd = gSystem->WorkingDirectory();
514 fWorkDir = dir;
516 argv[i] = null;
517 } else if (!strcmp(gROOT->GetName(), "Rint")) {
518 Warning("GetOptions", "only one directory argument can be specified (%s)", dir);
519 }
520 } else if (size > 0) {
521 // if file add to list of files to be processed
522 if (!fFiles) fFiles = new TObjArray;
523 fFiles->Add(new TObjString(path.Data()));
524 argv[i] = null;
525 } else {
526 Warning("GetOptions", "file %s has size 0, skipping", dir);
527 }
528 } else {
529 if (TString(udir.GetFile()).EndsWith(".root")) {
530 if (!strcmp(udir.GetProtocol(), "file")) {
531 // file ending on .root but does not exist, likely a typo
532 // warn user if plain root...
533 if (!strcmp(gROOT->GetName(), "Rint"))
534 Warning("GetOptions", "file %s not found", dir);
535 } else {
536 // remote file, give it the benefit of the doubt and add it to list of files
537 if (!fFiles) fFiles = new TObjArray;
538 fFiles->Add(new TObjString(argv[i]));
539 argv[i] = null;
540 }
541 } else {
542 TString mode,fargs,io;
543 TString fname = gSystem->SplitAclicMode(dir,mode,fargs,io);
544 char *mac;
545 if (!fFiles) fFiles = new TObjArray;
546 if ((mac = gSystem->Which(TROOT::GetMacroPath(), fname,
547 kReadPermission))) {
548 // if file add to list of files to be processed
549 fFiles->Add(new TObjString(argv[i]));
550 argv[i] = null;
551 delete [] mac;
552 } else {
553 // if file add an invalid entry to list of files to be processed
554 fFiles->Add(new TNamed("NOT FOUND!", argv[i]));
555 // only warn if we're plain root,
556 // other progs might have their own params
557 if (!strcmp(gROOT->GetName(), "Rint"))
558 Warning("GetOptions", "macro %s not found", fname.Data());
559 }
560 }
561 }
562 delete [] dir;
563 }
564 // ignore unknown options
565 }
566
567 // go back to startup directory
568 if (pwd != "")
570
571 // remove handled arguments from argument array
572 j = 0;
573 for (i = 0; i < *argc; i++) {
574 if (strcmp(argv[i], "")) {
575 argv[j] = argv[i];
576 j++;
577 }
578 }
579
580 *argc = j;
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Handle idle timeout. When this timer expires the registered idle command
585/// will be executed by this routine and a signal will be emitted.
586
588{
589 if (!fIdleCommand.IsNull())
591
592 Emit("HandleIdleTimer()");
593}
594
595////////////////////////////////////////////////////////////////////////////////
596/// Handle exceptions (kSigBus, kSigSegmentationViolation,
597/// kSigIllegalInstruction and kSigFloatingException) trapped in TSystem.
598/// Specific TApplication implementations may want something different here.
599
601{
602 if (TROOT::Initialized()) {
603 if (gException) {
604 gInterpreter->RewindDictionary();
605 gInterpreter->ClearFileBusy();
606 }
607 if (fExitOnException == kExit)
608 gSystem->Exit(128 + sig);
609 else if (fExitOnException == kAbort)
610 gSystem->Abort();
611 else
612 Throw(sig);
613 }
614 gSystem->Exit(128 + sig);
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Set the exit on exception option. Setting this option determines what
619/// happens in HandleException() in case an exception (kSigBus,
620/// kSigSegmentationViolation, kSigIllegalInstruction or kSigFloatingException)
621/// is trapped. Choices are: kDontExit (default), kExit or kAbort.
622/// Returns the previous value.
623
625{
627 fExitOnException = opt;
628 return old;
629}
630
631////////////////////////////////////////////////////////////////////////////////
632/// Print help on interpreter.
633
634void TApplication::Help(const char *line)
635{
636 gInterpreter->ProcessLine(line);
637
638 Printf("\nROOT special commands.");
639 Printf("===========================================================================");
640 Printf(" pwd : show current directory, pad and style");
641 Printf(" ls : list contents of current directory");
642 Printf(" which [file] : shows path of macro file");
643}
644
645////////////////////////////////////////////////////////////////////////////////
646/// Load shared libs necessary for graphics. These libraries are only
647/// loaded when gROOT->IsBatch() is kFALSE.
648
650{
651 if (gROOT->IsBatch()) return;
652
654 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualPad")))
655 if (h->LoadPlugin() == -1)
656 return;
657
659 TString title1 = "ROOT interface to ";
660 TString nativex, title;
661 TString nativeg = "root";
662
663#ifdef R__WIN32
664 nativex = "win32gdk";
665 name = "Win32gdk";
666 title = title1 + "Win32gdk";
667#elif defined(R__HAS_COCOA)
668 nativex = "quartz";
669 name = "quartz";
670 title = title1 + "Quartz";
671#else
672 nativex = "x11";
673 name = "X11";
674 title = title1 + "X11";
675#endif
676
677 TString guiBackend(gEnv->GetValue("Gui.Backend", "native"));
678 guiBackend.ToLower();
679 if (guiBackend == "native") {
680 guiBackend = nativex;
681 } else {
682 name = guiBackend;
683 title = title1 + guiBackend;
684 }
685 TString guiFactory(gEnv->GetValue("Gui.Factory", "native"));
686 guiFactory.ToLower();
687 if (guiFactory == "native")
688 guiFactory = nativeg;
689
690 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualX", guiBackend))) {
691 if (h->LoadPlugin() == -1) {
692 gROOT->SetBatch(kTRUE);
693 return;
694 }
695 gVirtualX = (TVirtualX *) h->ExecPlugin(2, name.Data(), title.Data());
697 }
698 if ((h = gROOT->GetPluginManager()->FindHandler("TGuiFactory", guiFactory))) {
699 if (h->LoadPlugin() == -1) {
700 gROOT->SetBatch(kTRUE);
701 return;
702 }
703 gGuiFactory = (TGuiFactory *) h->ExecPlugin(0);
704 }
705}
706
707////////////////////////////////////////////////////////////////////////////////
708/// Switch to batch mode.
709
711{
712 gROOT->SetBatch();
715#ifndef R__WIN32
716 if (gVirtualX != gGXBatch) delete gVirtualX;
717#endif
719}
720
721////////////////////////////////////////////////////////////////////////////////
722/// Parse the content of a line starting with ".R" (already stripped-off)
723/// The format is
724/// ~~~ {.cpp}
725/// [user@]host[:dir] [-l user] [-d dbg] [script]
726/// ~~~
727/// The variable 'dir' is the remote directory to be used as working dir.
728/// The username can be specified in two ways, "-l" having the priority
729/// (as in ssh).
730/// A 'dbg' value > 0 gives increasing verbosity.
731/// The last argument 'script' allows to specify an alternative script to
732/// be executed remotely to startup the session.
733
735 TString &hostdir, TString &user,
736 Int_t &dbg, TString &script)
737{
738 if (!ln || strlen(ln) <= 0)
739 return 0;
740
741 Int_t rc = 0;
742 Bool_t isHostDir = kTRUE;
743 Bool_t isScript = kFALSE;
744 Bool_t isUser = kFALSE;
745 Bool_t isDbg = kFALSE;
746
747 TString line(ln);
748 TString tkn;
749 Int_t from = 0;
750 while (line.Tokenize(tkn, from, " ")) {
751 if (tkn == "-l") {
752 // Next is a user name
753 isUser = kTRUE;
754 } else if (tkn == "-d") {
755 isDbg = kTRUE;
756 } else if (tkn == "-close") {
757 rc = 1;
758 } else if (tkn.BeginsWith("-")) {
759 ::Warning("TApplication::ParseRemoteLine","unknown option: %s", tkn.Data());
760 } else {
761 if (isUser) {
762 user = tkn;
763 isUser = kFALSE;
764 } else if (isDbg) {
765 dbg = tkn.Atoi();
766 isDbg = kFALSE;
767 } else if (isHostDir) {
768 hostdir = tkn;
769 hostdir.ReplaceAll(":","/");
770 isHostDir = kFALSE;
771 isScript = kTRUE;
772 } else if (isScript) {
773 // Add everything left
774 script = tkn;
775 script.Insert(0, "\"");
776 script += "\"";
777 isScript = kFALSE;
778 break;
779 }
780 }
781 }
782
783 // Done
784 return rc;
785}
786
787////////////////////////////////////////////////////////////////////////////////
788/// Process the content of a line starting with ".R" (already stripped-off)
789/// The format is
790/// ~~~ {.cpp}
791/// [user@]host[:dir] [-l user] [-d dbg] [script] | [host] -close
792/// ~~~
793/// The variable 'dir' is the remote directory to be used as working dir.
794/// The username can be specified in two ways, "-l" having the priority
795/// (as in ssh).
796/// A 'dbg' value > 0 gives increasing verbosity.
797/// The last argument 'script' allows to specify an alternative script to
798/// be executed remotely to startup the session.
799
801{
802 if (!line) return 0;
803
804 if (!strncmp(line, "-?", 2) || !strncmp(line, "-h", 2) ||
805 !strncmp(line, "--help", 6)) {
806 Info("ProcessRemote", "remote session help:");
807 Printf(".R [user@]host[:dir] [-l user] [-d dbg] [[<]script] | [host] -close");
808 Printf("Create a ROOT session on the specified remote host.");
809 Printf("The variable \"dir\" is the remote directory to be used as working dir.");
810 Printf("The username can be specified in two ways, \"-l\" having the priority");
811 Printf("(as in ssh). A \"dbg\" value > 0 gives increasing verbosity.");
812 Printf("The last argument \"script\" allows to specify an alternative script to");
813 Printf("be executed remotely to startup the session, \"roots\" being");
814 Printf("the default. If the script is preceded by a \"<\" the script will be");
815 Printf("sourced, after which \"roots\" is executed. The sourced script can be ");
816 Printf("used to change the PATH and other variables, allowing an alternative");
817 Printf("\"roots\" script to be found.");
818 Printf("To close down a session do \".R host -close\".");
819 Printf("To switch between sessions do \".R host\", to switch to the local");
820 Printf("session do \".R\".");
821 Printf("To list all open sessions do \"gApplication->GetApplications()->Print()\".");
822 return 0;
823 }
824
825 TString hostdir, user, script;
826 Int_t dbg = 0;
827 Int_t rc = ParseRemoteLine(line, hostdir, user, dbg, script);
828 if (hostdir.Length() <= 0) {
829 // Close the remote application if required
830 if (rc == 1) {
832 delete fAppRemote;
833 }
834 // Return to local run
835 fAppRemote = 0;
836 // Done
837 return 1;
838 } else if (rc == 1) {
839 // close an existing remote application
840 TApplication *ap = TApplication::Open(hostdir, 0, 0);
841 if (ap) {
843 delete ap;
844 }
845 }
846 // Attach or start a remote application
847 if (user.Length() > 0)
848 hostdir.Insert(0,Form("%s@", user.Data()));
849 const char *sc = (script.Length() > 0) ? script.Data() : 0;
850 TApplication *ap = TApplication::Open(hostdir, dbg, sc);
851 if (ap) {
852 fAppRemote = ap;
853 }
854
855 // Done
856 return 1;
857}
858
859namespace {
860 static int PrintFile(const char* filename) {
861 TString sFileName(filename);
862 gSystem->ExpandPathName(sFileName);
863 if (gSystem->AccessPathName(sFileName)) {
864 Error("ProcessLine()", "Cannot find file %s", filename);
865 return 1;
866 }
867 std::ifstream instr(sFileName);
868 TString content;
869 content.ReadFile(instr);
870 Printf("%s", content.Data());
871 return 0;
872 }
873}
874
875////////////////////////////////////////////////////////////////////////////////
876/// Process a single command line, either a C++ statement or an interpreter
877/// command starting with a ".".
878/// Return the return value of the command cast to a long.
879
881{
882 if (!line || !*line) return 0;
883
884 // If we are asked to go remote do it
885 if (!strncmp(line, ".R", 2)) {
886 Int_t n = 2;
887 while (*(line+n) == ' ')
888 n++;
889 return ProcessRemote(line+n, err);
890 }
891
892 // Redirect, if requested
895 return fAppRemote->ProcessLine(line, err);
896 }
897
898 if (!strncasecmp(line, ".qqqqqqq", 7)) {
899 gSystem->Abort();
900 } else if (!strncasecmp(line, ".qqqqq", 5)) {
901 Info("ProcessLine", "Bye... (try '.qqqqqqq' if still running)");
902 gSystem->Exit(1);
903 } else if (!strncasecmp(line, ".exit", 4) || !strncasecmp(line, ".quit", 2)) {
904 Terminate(0);
905 return 0;
906 }
907
908 if (!strncmp(line, ".?", 2) || !strncmp(line, ".help", 5)) {
909 Help(line);
910 return 1;
911 }
912
913 if (!strncmp(line, ".demo", 5)) {
914 if (gROOT->IsBatch()) {
915 Error("ProcessLine", "Cannot show demos in batch mode!");
916 return 1;
917 }
918 ProcessLine(".x " + TROOT::GetTutorialDir() + "/demos.C");
919 return 0;
920 }
921
922 if (!strncmp(line, ".license", 8)) {
923 return PrintFile(TROOT::GetDocDir() + "/LICENSE");
924 }
925
926 if (!strncmp(line, ".credits", 8)) {
927 TString credits = TROOT::GetDocDir() + "/CREDITS";
929 credits = TROOT::GetDocDir() + "/README/CREDITS";
930 return PrintFile(credits);
931 }
932
933 if (!strncmp(line, ".pwd", 4)) {
934 if (gDirectory)
935 Printf("Current directory: %s", gDirectory->GetPath());
936 if (gPad)
937 Printf("Current pad: %s", gPad->GetName());
938 if (gStyle)
939 Printf("Current style: %s", gStyle->GetName());
940 return 1;
941 }
942
943 if (!strncmp(line, ".ls", 3)) {
944 const char *opt = 0;
945 if (line[3]) opt = &line[3];
946 if (gDirectory) gDirectory->ls(opt);
947 return 1;
948 }
949
950 if (!strncmp(line, ".which", 6)) {
951 char *fn = Strip(line+7);
952 char *s = strtok(fn, "+("); // this method does not need to be reentrant
954 if (!mac)
955 Printf("No macro %s in path %s", s, TROOT::GetMacroPath());
956 else
957 Printf("%s", mac);
958 delete [] fn;
959 delete [] mac;
960 return mac ? 1 : 0;
961 }
962
963 if (!strncmp(line, ".L", 2) || !strncmp(line, ".U", 2)) {
964 TString aclicMode;
965 TString arguments;
966 TString io;
967 TString fname = gSystem->SplitAclicMode(line+3, aclicMode, arguments, io);
968
969 char *mac = gSystem->Which(TROOT::GetMacroPath(), fname, kReadPermission);
970 if (arguments.Length()) {
971 Warning("ProcessLine", "argument(s) \"%s\" ignored with .%c", arguments.Data(),
972 line[1]);
973 }
974 Long_t retval = 0;
975 if (!mac)
976 Error("ProcessLine", "macro %s not found in path %s", fname.Data(),
978 else {
979 TString cmd(line+1);
980 Ssiz_t posSpace = cmd.Index(' ');
981 if (posSpace == -1) cmd.Remove(1);
982 else cmd.Remove(posSpace);
983 TString tempbuf;
984 if (sync) {
985 tempbuf.Form(".%s %s%s%s", cmd.Data(), mac, aclicMode.Data(),io.Data());
986 retval = gInterpreter->ProcessLineSynch(tempbuf,
988 } else {
989 tempbuf.Form(".%s %s%s%s", cmd.Data(), mac, aclicMode.Data(),io.Data());
990 retval = gInterpreter->ProcessLine(tempbuf,
992 }
993 }
994
995 delete [] mac;
996
998
999 return retval;
1000 }
1001
1002 if (!strncmp(line, ".X", 2) || !strncmp(line, ".x", 2)) {
1003 return ProcessFile(line+3, err, line[2] == 'k');
1004 }
1005
1006 if (!strcmp(line, ".reset")) {
1007 // Do nothing, .reset disabled in CINT because too many side effects
1008 Printf("*** .reset not allowed, please use gROOT->Reset() ***");
1009 return 0;
1010
1011#if 0
1012 // delete the ROOT dictionary since CINT will destroy all objects
1013 // referenced by the dictionary classes (TClass et. al.)
1014 gROOT->GetListOfClasses()->Delete();
1015 // fall through
1016#endif
1017 }
1018
1019 if (sync)
1020 return gInterpreter->ProcessLineSynch(line, (TInterpreter::EErrorCode*)err);
1021 else
1022 return gInterpreter->ProcessLine(line, (TInterpreter::EErrorCode*)err);
1023}
1024
1025////////////////////////////////////////////////////////////////////////////////
1026/// Process a file containing a C++ macro.
1027
1029{
1030 return ExecuteFile(file, error, keep);
1031}
1032
1033////////////////////////////////////////////////////////////////////////////////
1034/// Execute a file containing a C++ macro (static method). Can be used
1035/// while TApplication is not yet created.
1036
1038{
1039 static const Int_t kBufSize = 1024;
1040
1041 if (!file || !*file) return 0;
1042
1043 TString aclicMode;
1044 TString arguments;
1045 TString io;
1046 TString fname = gSystem->SplitAclicMode(file, aclicMode, arguments, io);
1047
1048 char *exnam = gSystem->Which(TROOT::GetMacroPath(), fname, kReadPermission);
1049 if (!exnam) {
1050 ::Error("TApplication::ExecuteFile", "macro %s not found in path %s", fname.Data(),
1052 delete [] exnam;
1053 if (error)
1055 return 0;
1056 }
1057
1058 ::std::ifstream macro(exnam, std::ios::in);
1059 if (!macro.good()) {
1060 ::Error("TApplication::ExecuteFile", "%s no such file", exnam);
1061 if (error)
1063 delete [] exnam;
1064 return 0;
1065 }
1066
1067 char currentline[kBufSize];
1068 char dummyline[kBufSize];
1069 int tempfile = 0;
1070 int comment = 0;
1071 int ifndefc = 0;
1072 int ifdef = 0;
1073 char *s = 0;
1074 Bool_t execute = kFALSE;
1075 Long_t retval = 0;
1076
1077 while (1) {
1078 bool res = (bool)macro.getline(currentline, kBufSize);
1079 if (macro.eof()) break;
1080 if (!res) {
1081 // Probably only read kBufSize, let's ignore the remainder of
1082 // the line.
1083 macro.clear();
1084 while (!macro.getline(dummyline, kBufSize) && !macro.eof()) {
1085 macro.clear();
1086 }
1087 }
1088 s = currentline;
1089 while (s && (*s == ' ' || *s == '\t')) s++; // strip-off leading blanks
1090
1091 // very simple minded pre-processor parsing, only works in case macro file
1092 // starts with "#ifndef __CINT__". In that case everything till next
1093 // "#else" or "#endif" will be skipped.
1094 if (*s == '#') {
1095 char *cs = Compress(currentline);
1096 if (strstr(cs, "#ifndef__CINT__") ||
1097 strstr(cs, "#if!defined(__CINT__)"))
1098 ifndefc = 1;
1099 else if (ifndefc && (strstr(cs, "#ifdef") || strstr(cs, "#ifndef") ||
1100 strstr(cs, "#ifdefined") || strstr(cs, "#if!defined")))
1101 ifdef++;
1102 else if (ifndefc && strstr(cs, "#endif")) {
1103 if (ifdef)
1104 ifdef--;
1105 else
1106 ifndefc = 0;
1107 } else if (ifndefc && !ifdef && strstr(cs, "#else"))
1108 ifndefc = 0;
1109 delete [] cs;
1110 }
1111 if (!*s || *s == '#' || ifndefc || !strncmp(s, "//", 2)) continue;
1112
1113 if (!comment && (!strncmp(s, ".X", 2) || !strncmp(s, ".x", 2))) {
1114 retval = ExecuteFile(s+3);
1115 execute = kTRUE;
1116 continue;
1117 }
1118
1119 if (!strncmp(s, "/*", 2)) comment = 1;
1120 if (comment) {
1121 // handle slightly more complex cases like: /* */ /*
1122again:
1123 s = strstr(s, "*/");
1124 if (s) {
1125 comment = 0;
1126 s += 2;
1127
1128 while (s && (*s == ' ' || *s == '\t')) s++; // strip-off leading blanks
1129 if (!*s) continue;
1130 if (!strncmp(s, "//", 2)) continue;
1131 if (!strncmp(s, "/*", 2)) {
1132 comment = 1;
1133 goto again;
1134 }
1135 }
1136 }
1137 if (!comment && *s == '{') tempfile = 1;
1138 if (!comment) break;
1139 }
1140 macro.close();
1141
1142 if (!execute) {
1143 TString exname = exnam;
1144 if (!tempfile) {
1145 // We have a script that does NOT contain an unnamed macro,
1146 // so we can call the script compiler on it.
1147 exname += aclicMode;
1148 }
1149 exname += arguments;
1150 exname += io;
1151
1152 TString tempbuf;
1153 if (tempfile) {
1154 tempbuf.Form(".x %s", exname.Data());
1155 } else {
1156 tempbuf.Form(".X%s %s", keep ? "k" : " ", exname.Data());
1157 }
1158 retval = gInterpreter->ProcessLineSynch(tempbuf,(TInterpreter::EErrorCode*)error);
1159 }
1160
1161 delete [] exnam;
1162 return retval;
1163}
1164
1165////////////////////////////////////////////////////////////////////////////////
1166/// Main application eventloop. Calls system dependent eventloop via gSystem.
1167
1169{
1170 SetReturnFromRun(retrn);
1171
1172 fIsRunning = kTRUE;
1173
1174 gSystem->Run();
1176}
1177
1178////////////////////////////////////////////////////////////////////////////////
1179/// Set the command to be executed after the system has been idle for
1180/// idleTimeInSec seconds. Normally called via TROOT::Idle(...).
1181
1182void TApplication::SetIdleTimer(UInt_t idleTimeInSec, const char *command)
1183{
1185 fIdleCommand = command;
1186 fIdleTimer = new TIdleTimer(idleTimeInSec*1000);
1188}
1189
1190////////////////////////////////////////////////////////////////////////////////
1191/// Remove idle timer. Normally called via TROOT::Idle(0).
1192
1194{
1195 if (fIdleTimer) {
1196 // timers are removed from the gSystem timer list by their dtor
1198 }
1199}
1200
1201////////////////////////////////////////////////////////////////////////////////
1202/// Called when system starts idleing.
1203
1205{
1206 if (fIdleTimer) {
1207 fIdleTimer->Reset();
1209 }
1210}
1211
1212////////////////////////////////////////////////////////////////////////////////
1213/// Called when system stops idleing.
1214
1216{
1217 if (fIdleTimer)
1219}
1220
1221////////////////////////////////////////////////////////////////////////////////
1222/// What to do when tab is pressed. Re-implemented by TRint.
1223/// See TTabCom::Hook() for meaning of return values.
1224
1225Int_t TApplication::TabCompletionHook(char* /*buf*/, int* /*pLoc*/, std::ostream& /*out*/)
1226{
1227 return -1;
1228}
1229
1230
1231////////////////////////////////////////////////////////////////////////////////
1232/// Terminate the application by call TSystem::Exit() unless application has
1233/// been told to return from Run(), by a call to SetReturnFromRun().
1234
1236{
1237 Emit("Terminate(Int_t)", status);
1238
1239 if (fReturnFromRun)
1240 gSystem->ExitLoop();
1241 else {
1242 //close TMemStat
1243 if (fUseMemstat) {
1244 ProcessLine("TMemStat::Close()");
1246 }
1247
1248 gSystem->Exit(status);
1249 }
1250}
1251
1252////////////////////////////////////////////////////////////////////////////////
1253/// Emit signal when a line has been processed.
1254
1256{
1257 Emit("LineProcessed(const char*)", line);
1258}
1259
1260////////////////////////////////////////////////////////////////////////////////
1261/// Emit signal when console keyboard key was pressed.
1262
1264{
1265 Emit("KeyPressed(Int_t)", key);
1266}
1267
1268////////////////////////////////////////////////////////////////////////////////
1269/// Emit signal when return key was pressed.
1270
1272{
1273 Emit("ReturnPressed(char*)", text);
1274}
1275
1276////////////////////////////////////////////////////////////////////////////////
1277/// Set console echo mode:
1278///
1279/// - mode = kTRUE - echo input symbols
1280/// - mode = kFALSE - noecho input symbols
1281
1283{
1284}
1285
1286////////////////////////////////////////////////////////////////////////////////
1287/// Static function used to create a default application environment.
1288
1290{
1292 // gApplication is set at the end of 'new TApplication.
1293 if (!gApplication) {
1294 char *a = StrDup("RootApp");
1295 char *b = StrDup("-b");
1296 char *argv[2];
1297 Int_t argc = 2;
1298 argv[0] = a;
1299 argv[1] = b;
1300 new TApplication("RootApp", &argc, argv, 0, 0);
1301 if (gDebug > 0)
1302 Printf("<TApplication::CreateApplication>: "
1303 "created default TApplication");
1304 delete [] a; delete [] b;
1306 }
1307}
1308
1309////////////////////////////////////////////////////////////////////////////////
1310/// Static function used to attach to an existing remote application
1311/// or to start one.
1312
1314 Int_t debug, const char *script)
1315{
1316 TApplication *ap = 0;
1317 TUrl nu(url);
1318 Int_t nnew = 0;
1319
1320 // Look among the existing ones
1321 if (fgApplications) {
1322 TIter nxa(fgApplications);
1323 while ((ap = (TApplication *) nxa())) {
1324 TString apn(ap->ApplicationName());
1325 if (apn == url) {
1326 // Found matching application
1327 return ap;
1328 } else {
1329 // Check if same machine and user
1330 TUrl au(apn);
1331 if (strlen(au.GetUser()) > 0 && strlen(nu.GetUser()) > 0 &&
1332 !strcmp(au.GetUser(), nu.GetUser())) {
1333 if (!strncmp(au.GetHost(), nu.GetHost(), strlen(nu.GetHost())))
1334 // New session on a known machine
1335 nnew++;
1336 }
1337 }
1338 }
1339 } else {
1340 ::Error("TApplication::Open", "list of applications undefined - protocol error");
1341 return ap;
1342 }
1343
1344 // If new session on a known machine pass the number as option
1345 if (nnew > 0) {
1346 nnew++;
1347 nu.SetOptions(Form("%d", nnew));
1348 }
1349
1350 // Instantiate the TApplication object to be run
1351 TPluginHandler *h = 0;
1352 if ((h = gROOT->GetPluginManager()->FindHandler("TApplication","remote"))) {
1353 if (h->LoadPlugin() == 0) {
1354 ap = (TApplication *) h->ExecPlugin(3, nu.GetUrl(), debug, script);
1355 } else {
1356 ::Error("TApplication::Open", "failed to load plugin for TApplicationRemote");
1357 }
1358 } else {
1359 ::Error("TApplication::Open", "failed to find plugin for TApplicationRemote");
1360 }
1361
1362 // Add to the list
1363 if (ap && !(ap->TestBit(kInvalidObject))) {
1364 fgApplications->Add(ap);
1365 gROOT->GetListOfBrowsables()->Add(ap, ap->ApplicationName());
1366 TIter next(gROOT->GetListOfBrowsers());
1367 TBrowser *b;
1368 while ((b = (TBrowser*) next()))
1369 b->Add(ap, ap->ApplicationName());
1370 gROOT->RefreshBrowsers();
1371 } else {
1372 SafeDelete(ap);
1373 ::Error("TApplication::Open",
1374 "TApplicationRemote for %s could not be instantiated", url);
1375 }
1376
1377 // Done
1378 return ap;
1379}
1380
1381////////////////////////////////////////////////////////////////////////////////
1382/// Static function used to close a remote application
1383
1385{
1386 if (app) {
1387 app->Terminate(0);
1388 fgApplications->Remove(app);
1389 gROOT->GetListOfBrowsables()->RecursiveRemove(app);
1390 TIter next(gROOT->GetListOfBrowsers());
1391 TBrowser *b;
1392 while ((b = (TBrowser*) next()))
1393 b->RecursiveRemove(app);
1394 gROOT->RefreshBrowsers();
1395 }
1396}
1397
1398////////////////////////////////////////////////////////////////////////////////
1399/// Show available sessions
1400
1402{
1403 if (fgApplications) {
1404 TIter nxa(fgApplications);
1405 TApplication *a = 0;
1406 while ((a = (TApplication *) nxa())) {
1407 a->Print(opt);
1408 }
1409 } else {
1410 Print(opt);
1411 }
1412}
1413
1414////////////////////////////////////////////////////////////////////////////////
1415/// Static method returning the list of available applications
1416
1418{
1419 return fgApplications;
1420}
#define SafeDelete(p)
Definition: RConfig.hxx:543
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
int Ssiz_t
Definition: RtypesCore.h:63
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
R__EXTERN Int_t gDebug
Definition: Rtypes.h:91
static void CallEndOfProcessCleanups()
TApplication * gApplication
R__EXTERN TClassTable * gClassTable
Definition: TClassTable.h:95
#define gDirectory
Definition: TDirectory.h:218
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
void Error(const char *location, const char *msgfmt,...)
void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set.
Definition: TException.cxx:27
R__EXTERN ExceptionContext_t * gException
Definition: TException.h:74
XFontStruct * id
Definition: TGX11.cxx:108
char name[80]
Definition: TGX11.cxx:109
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition: TGuiFactory.h:67
R__EXTERN TGuiFactory * gGuiFactory
Definition: TGuiFactory.h:66
R__EXTERN TVirtualMutex * gInterpreterMutex
Definition: TInterpreter.h:40
#define gInterpreter
Definition: TInterpreter.h:553
@ kInvalidObject
Definition: TObject.h:346
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:59
#define gROOT
Definition: TROOT.h:414
char * Compress(const char *str)
Remove all blanks from the string str.
Definition: TString.cxx:2504
char * Form(const char *fmt,...)
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition: TString.cxx:2454
void Printf(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2490
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
@ kReadPermission
Definition: TSystem.h:48
R__EXTERN TSystem * gSystem
Definition: TSystem.h:560
#define R__LOCKGUARD(mutex)
#define gPad
Definition: TVirtualPad.h:286
#define gVirtualX
Definition: TVirtualX.h:345
R__EXTERN TVirtualX * gGXBatch
Definition: TVirtualX.h:348
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
Definition: TApplication.h:39
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.
static TList * fgApplications
Definition: TApplication.h:83
static void Close(TApplication *app)
Static function used to close a remote application.
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.
virtual void SetEchoMode(Bool_t mode)
Set console echo mode:
virtual void Help(const char *line)
Print help on interpreter.
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
Definition: TApplication.h:60
virtual void Open()
Definition: TApplication.h:127
virtual void LoadGraphicsLibs()
Load shared libs necessary for graphics.
Bool_t fUseMemstat
Definition: TApplication.h:66
virtual void StopIdleing()
Called when system stops idleing.
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 HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
virtual void MakeBatch()
Switch to batch mode.
Bool_t fIsRunning
Window system specific application implementation.
Definition: TApplication.h:61
Bool_t fReturnFromRun
Definition: TApplication.h:62
virtual void Init()
Definition: TApplication.h:112
TString fIdleCommand
Definition: TApplication.h:69
void InitializeGraphics()
Initialize the graphics environment.
char ** Argv() const
Definition: TApplication.h:136
static Bool_t fgGraphNeeded
Definition: TApplication.h:74
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual const char * ApplicationName() const
Definition: TApplication.h:123
static Long_t ExecuteFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
void SetReturnFromRun(Bool_t ret)
Definition: TApplication.h:149
Bool_t fQuit
Definition: TApplication.h:65
virtual Int_t TabCompletionHook(char *buf, int *pLoc, std::ostream &out)
What to do when tab is pressed.
EExitOnException fExitOnException
Definition: TApplication.h:72
TObjArray * fFiles
Definition: TApplication.h:67
const char * GetIdleCommand() const
Definition: TApplication.h:118
virtual void ls(Option_t *option="") const
Show available sessions.
TApplication()
Default ctor. Can be used by classes deriving from TApplication.
TString fWorkDir
Definition: TApplication.h:68
virtual void ReturnPressed(char *text)
Emit signal when return key was pressed.
static Bool_t fgGraphInit
Definition: TApplication.h:75
virtual void RemoveIdleTimer()
Remove idle timer. Normally called via TROOT::Idle(0).
virtual void SetIdleTimer(UInt_t idleTimeInSec, const char *command)
Set the command to be executed after the system has been idle for idleTimeInSec seconds.
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.
static TList * GetApplications()
Static method returning the list of available applications.
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 "....
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
Definition: TApplication.h:70
Bool_t fNoLog
Definition: TApplication.h:63
Bool_t fNoLogo
Definition: TApplication.h:64
virtual void HandleIdleTimer()
Handle idle timeout.
virtual Long_t ProcessFile(const char *file, Int_t *error=0, Bool_t keep=kFALSE)
Process a file containing a C++ macro.
TApplication * fAppRemote
Definition: TApplication.h:81
char ** fArgv
Definition: TApplication.h:59
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition: TColor.cxx:1083
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
Definition: TEnv.cxx:736
This ABC is a factory for GUI components.
Definition: TGuiFactory.h:42
virtual TApplicationImp * CreateApplicationImp(const char *classname, int *argc, char **argv)
Create a batch version of TApplicationImp.
Definition: TGuiFactory.cxx:48
A doubly linked list.
Definition: TList.h:44
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:819
virtual TObjLink * FirstLink() const
Definition: TList.h:108
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
An array of TObjects.
Definition: TObjArray.h:37
void Add(TObject *obj)
Definition: TObjArray.h:74
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:355
Collectable string class.
Definition: TObjString.h:28
TString & String()
Definition: TObjString.h:48
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:908
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition: TObject.cxx:550
void ResetBit(UInt_t f)
Definition: TObject.h:171
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition: TObject.h:68
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition: TROOT.cxx:2767
static void ShutDown()
Shut down ROOT.
Definition: TROOT.cxx:3123
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition: TROOT.cxx:3176
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition: TROOT.cxx:2863
static const TString & GetTutorialDir()
Get the tutorials directory in the installation. Static utility function.
Definition: TROOT.cxx:3102
static const TString & GetDocDir()
Get the documentation directory in the installation. Static utility function.
Definition: TROOT.cxx:3065
Basic string class.
Definition: TString.h:131
Ssiz_t Length() const
Definition: TString.h:405
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:644
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1921
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2177
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition: TString.h:677
const char * Data() const
Definition: TString.h:364
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:610
Bool_t IsNull() const
Definition: TString.h:402
std::istream & ReadFile(std::istream &str)
Replace string with the contents of strm, stopping at an EOF.
Definition: Stringio.cxx:28
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
TString & Append(const char *cs)
Definition: TString.h:559
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634
void SetScreenFactor(Float_t factor=1)
Definition: TStyle.h:297
virtual void NotifyApplicationCreated()
Hook to tell TSystem that the TApplication object has been created.
Definition: TSystem.cxx:320
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1264
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Definition: TSystem.cxx:4163
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1843
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition: TSystem.cxx:1388
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition: TSystem.cxx:1286
virtual void Run()
System event loop.
Definition: TSystem.cxx:352
virtual void ExitLoop()
Exit from event loop.
Definition: TSystem.cxx:401
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition: TSystem.cxx:869
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition: TSystem.cxx:480
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
Definition: TSystem.cxx:725
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:878
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition: TSystem.cxx:1536
virtual void SetProgname(const char *name)
Set the application name (from command line, argv[0]) and copy it in gProgName.
Definition: TSystem.cxx:232
virtual const char * GetBuildArch() const
Return the build architecture.
Definition: TSystem.cxx:3804
virtual void Abort(int code=0)
Abort the application.
Definition: TSystem.cxx:733
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition: TSystem.cxx:490
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
void Reset()
Reset the timer.
Definition: TTimer.cxx:157
virtual Bool_t Notify()
Notify when timer times out.
Definition: TTimer.cxx:143
TTimer(const TTimer &)
This class represents a WWW compatible URL.
Definition: TUrl.h:35
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:385
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition: TUrl.cxx:499
const char * GetFile() const
Definition: TUrl.h:72
const char * GetUser() const
Definition: TUrl.h:68
const char * GetHost() const
Definition: TUrl.h:70
void SetOptions(const char *opt)
Definition: TUrl.h:90
const char * GetProtocol() const
Definition: TUrl.h:67
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition: TVirtualX.h:53
TText * text
TLine * line
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
Definition: TROOT.cxx:579
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.
Definition: TROOT.cxx:548
static constexpr double s
static constexpr double ms
null_t< F > null()
Definition: file.py:1
auto * a
Definition: textangle.C:12