Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TApplication.h"
24#include "TException.h"
25#include "TGuiFactory.h"
26#include "TVirtualX.h"
27#include "TROOT.h"
28#include "TSystem.h"
29#include "TString.h"
30#include "TError.h"
31#include "TObjArray.h"
32#include "TObjString.h"
33#include "TTimer.h"
34#include "TInterpreter.h"
35#include "TStyle.h"
36#include "TVirtualPad.h"
37#include "TEnv.h"
38#include "TColor.h"
39#include "TPluginManager.h"
40#include "TClassTable.h"
41#include "TBrowser.h"
42#include "TUrl.h"
43#include "TVirtualMutex.h"
44#include "TClassEdit.h"
45#include "TMethod.h"
46#include "TDataMember.h"
47#include "TApplicationCommandLineOptionsHelp.h"
48#include "TPRegexp.h"
49#include <cstdlib>
50#include <iostream>
51#include <fstream>
52
56TList *TApplication::fgApplications = nullptr; // List of available applications
57
58////////////////////////////////////////////////////////////////////////////////
59
60class TIdleTimer : public TTimer {
61public:
63 Bool_t Notify() override;
64};
65
66////////////////////////////////////////////////////////////////////////////////
67/// Notify handler.
68
75
76
78
80{
81 // Insure that the files, canvases and sockets are closed.
82
83 // If we get here, the tear down has started. We have no way to know what
84 // has or has not yet been done. In particular on Ubuntu, this was called
85 // after the function static in TSystem.cxx has been destructed. So we
86 // set gROOT in its end-of-life mode which prevents executing code, like
87 // autoloading libraries (!) that is pointless ...
88 if (gROOT) {
89 gROOT->SetBit(kInvalidObject);
90 gROOT->EndOfProcessCleanups();
91 }
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Default ctor. Can be used by classes deriving from TApplication.
96
98 fArgc(0), fArgv(nullptr), fAppImp(nullptr), fIsRunning(kFALSE), fReturnFromRun(kFALSE),
99 fNoLog(kFALSE), fNoLogo(kFALSE), fQuit(kFALSE),
100 fFiles(nullptr), fIdleTimer(nullptr), fSigHandler(nullptr), fExitOnException(kDontExit),
101 fAppRemote(nullptr)
102{
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Create an application environment. The application environment
108/// provides an interface to the graphics system and eventloop
109/// (be it X, Windows, macOS or BeOS). After creating the application
110/// object start the eventloop by calling its Run() method. The command
111/// line options recognized by TApplication are described in the GetOptions()
112/// method. The recognized options are removed from the argument array.
113/// The original list of argument options can be retrieved via the Argc()
114/// and Argv() methods. The appClassName "proofserv" is reserved for the
115/// PROOF system. The "options" and "numOptions" arguments are not used,
116/// except if you want to by-pass the argv processing by GetOptions()
117/// in which case you should specify numOptions<0. All options will
118/// still be available via the Argv() method for later use.
119
121 void * /*options*/, Int_t numOptions) :
122 fArgc(0), fArgv(nullptr), fAppImp(nullptr), fIsRunning(kFALSE), fReturnFromRun(kFALSE),
123 fNoLog(kFALSE), fNoLogo(kFALSE), fQuit(kFALSE),
124 fFiles(nullptr), fIdleTimer(nullptr), fSigHandler(nullptr), fExitOnException(kDontExit),
125 fAppRemote(nullptr)
126{
128
129 // Create the list of applications the first time
130 if (!fgApplications)
131 fgApplications = new TList;
132
133 // Add the new TApplication early, so that the destructor of the
134 // default TApplication (if it is called in the block of code below)
135 // will not destroy the files, socket or TColor that have already been
136 // created.
137 fgApplications->Add(this);
138
140 // allow default TApplication to be replaced by a "real" TApplication
141 delete gApplication;
142 gApplication = nullptr;
143 gROOT->SetBatch(kFALSE);
145 }
146
147 if (gApplication) {
148 Error("TApplication", "only one instance of TApplication allowed");
149 fgApplications->Remove(this);
150 return;
151 }
152
153 if (!gROOT)
154 ::Fatal("TApplication::TApplication", "ROOT system not initialized");
155
156 if (!gSystem)
157 ::Fatal("TApplication::TApplication", "gSystem not initialized");
158
160 if (!hasRegisterAtExit) {
161 // If we are the first TApplication register the atexit)
164 }
165 gROOT->SetName(appClassName);
166
167 // copy command line arguments, can be later accessed via Argc() and Argv()
168 if (argc && *argc > 0) {
169 fArgc = *argc;
170 fArgv = (char **)new char*[fArgc];
171 }
172
173 for (int i = 0; i < fArgc; i++)
174 fArgv[i] = StrDup(argv[i]);
175
176 if (numOptions >= 0)
178
179 if (fArgv)
181
182 // Tell TSystem the TApplication has been created
184
187
188 // Initialize the graphics environment
189 if (gClassTable->GetDict("TPad")) {
191 InitializeGraphics(gROOT->IsWebDisplay());
192 }
193
194 // Save current interpreter context
195 gInterpreter->SaveContext();
196 gInterpreter->SaveGlobalsContext();
197
198 // to allow user to interact with TCanvas's under WIN32
199 gROOT->SetLineHasBeenProcessed();
200
201 //Needs to be done last
202 gApplication = this;
203 gROOT->SetApplication(this);
204
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// TApplication dtor.
209
211{
212 for (int i = 0; i < fArgc; i++)
213 if (fArgv[i]) delete [] fArgv[i];
214 delete [] fArgv;
215
216 if (fgApplications)
217 fgApplications->Remove(this);
218
219 // Reduce the risk of the files or sockets being closed after the
220 // end of 'main' (or more exactly before the library start being
221 // unloaded).
222 if (fgApplications == nullptr || fgApplications->FirstLink() == nullptr ) {
224 }
225
226 // Now that all the canvases and files have been closed we can
227 // delete the implementation.
229}
230
231////////////////////////////////////////////////////////////////////////////////
232/// Static method. This method should be called from static library
233/// initializers if the library needs the low level graphics system.
234
239
240////////////////////////////////////////////////////////////////////////////////
241/// Initialize the graphics environment.
242/// If @param only_web is specified, only web-related part of graphics is loaded
243
245{
247 return;
248
249 if (!only_web) {
250 // Load the graphics related libraries
252
253 // Try to load TrueType font renderer. Only try to load if not in batch
254 // mode and Root.UseTTFonts is true and Root.TTFontPath exists. Abort silently
255 // if libttf or libGX11TTF are not found in $ROOTSYS/lib or $ROOTSYS/ttf/lib.
256 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
258 char *ttfont = gSystem->Which(ttpath, "arialbd.ttf", kReadPermission);
259 // Check for use of DFSG - fonts
260 if (!ttfont)
261 ttfont = gSystem->Which(ttpath, "FreeSansBold.ttf", kReadPermission);
262
263 #if !defined(R__WIN32)
264 if (!gROOT->IsBatch() && !strcmp(gVirtualX->GetName(), "X11") &&
265 ttfont && gEnv->GetValue("Root.UseTTFonts", 1)) {
266 if (gClassTable->GetDict("TGX11TTF")) {
267 // in principle we should not have linked anything against libGX11TTF
268 // but with ACLiC this can happen, initialize TGX11TTF by hand
269 // (normally this is done by the static library initializer)
270 ProcessLine("TGX11TTF::Activate();");
271 } else {
273 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualX", "x11ttf")))
274 if (h->LoadPlugin() == -1)
275 Info("InitializeGraphics", "no TTF support");
276 }
277 }
278 #endif
279 delete [] ttfont;
280 }
281
282 if (!only_web || !fAppImp) {
283 // Create WM dependent application environment
284 if (fAppImp)
285 delete fAppImp;
287 if (!fAppImp) {
288 MakeBatch();
290 }
291 }
292
293 // Create the canvas colors early so they are allocated before
294 // any color table expensive bitmaps get allocated in GUI routines (like
295 // creation of XPM bitmaps).
297
298 // Hook for further initializing the WM dependent application environment
299 Init();
300
301 // Set default screen factor (if not disabled in rc file)
302 if (!only_web && gEnv->GetValue("Canvas.UseScreenFactor", 1)) {
303 Int_t x, y;
304 UInt_t w, h;
305 if (gVirtualX) {
306 gVirtualX->GetGeometry(-1, x, y, w, h);
307 if (h > 0)
308 gStyle->SetScreenFactor(0.001 * h);
309 }
310 }
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Clear list containing macro files passed as program arguments.
315/// This method is called from TRint::Run() to ensure that the macro
316/// files are only executed the first time Run() is called.
317
319{
320 if (fFiles) {
321 fFiles->Delete();
323 }
324}
325
326////////////////////////////////////////////////////////////////////////////////
327/// Return specified argument.
328
330{
331 if (fArgv) {
332 if (index >= fArgc) {
333 Error("Argv", "index (%d) >= number of arguments (%d)", index, fArgc);
334 return nullptr;
335 }
336 return fArgv[index];
337 }
338 return nullptr;
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Get and handle command line options. Arguments handled are removed
343/// from the argument array. See CommandLineOptionsHelp.h for options.
344
346{
347 static char null[1] = { "" };
348
349 fNoLog = kFALSE;
350 fQuit = kFALSE;
351 fFiles = nullptr;
352
353 if (!argc)
354 return;
355
356 int i, j;
357 TString pwd;
358
359 for (i = 1; i < *argc; i++) {
360 if (!strcmp(argv[i], "-?") || !strncmp(argv[i], "-h", 2) ||
361 !strncmp(argv[i], "--help", 6)) {
363 Terminate(0);
364 } else if (!strncmp(argv[i], "--version", 9)) {
365 fprintf(stderr, "ROOT Version: %s\n", gROOT->GetVersion());
366 fprintf(stderr, "Built for %s on %s\n",
368 gROOT->GetGitDate());
369
370 fprintf(stderr, "From %s@%s\n",
371 gROOT->GetGitBranch(),
372 gROOT->GetGitCommit());
373
374 Terminate(0);
375 } else if (!strcmp(argv[i], "-config")) {
376 fprintf(stderr, "ROOT ./configure options:\n%s\n", gROOT->GetConfigOptions());
377 Terminate(0);
378 } else if (!strcmp(argv[i], "-a")) {
379 fprintf(stderr, "ROOT splash screen is not visible with root.exe, use root instead.\n");
380 Terminate(0);
381 } else if (!strcmp(argv[i], "-b")) {
382 MakeBatch();
383 argv[i] = null;
384 } else if (!strcmp(argv[i], "-n")) {
385 fNoLog = kTRUE;
386 argv[i] = null;
387 } else if (!strcmp(argv[i], "-t")) {
389 // EnableImplicitMT() only enables thread safety if IMT was configured;
390 // enable thread safety even with IMT off:
392 argv[i] = null;
393 } else if (!strcmp(argv[i], "-q")) {
394 fQuit = kTRUE;
395 argv[i] = null;
396 } else if (!strcmp(argv[i], "-l")) {
397 // used by front-end program to not display splash screen
398 fNoLogo = kTRUE;
399 argv[i] = null;
400 } else if (!strcmp(argv[i], "-x")) {
402 argv[i] = null;
403 } else if (!strcmp(argv[i], "-splash")) {
404 // used when started by front-end program to signal that
405 // splash screen can be popped down (TRint::PrintLogo())
406 argv[i] = null;
407 } else if (strncmp(argv[i], "--web", 5) == 0) {
408 // the web mode is requested
409 const char *opt = argv[i] + 5;
410 argv[i] = null;
411 gROOT->SetWebDisplay((*opt == '=') ? opt + 1 : "");
412 } else if (!strcmp(argv[i], "-e")) {
413 argv[i] = null;
414 ++i;
415
416 if ( i < *argc ) {
417 if (!fFiles) fFiles = new TObjArray;
418 TObjString *expr = new TObjString(argv[i]);
419 expr->SetBit(kExpression);
420 fFiles->Add(expr);
421 argv[i] = null;
422 } else {
423 Warning("GetOptions", "-e must be followed by an expression.");
424 }
425 } else if (!strcmp(argv[i], "--")) {
426 TObjString* macro = nullptr;
427 bool warnShown = false;
428
429 if (fFiles) {
430 for (auto f: *fFiles) {
431 TObjString *file = dynamic_cast<TObjString *>(f);
432 if (!file) {
433 if (!dynamic_cast<TNamed*>(f)) {
434 Error("GetOptions()", "Inconsistent file entry (not a TObjString)!");
435 if (f)
436 f->Dump();
437 } // else we did not find the file.
438 continue;
439 }
440
441 if (file->TestBit(kExpression))
442 continue;
443 if (file->String().EndsWith(".root"))
444 continue;
445 if (file->String().Contains('('))
446 continue;
447
448 if (macro && !warnShown && (warnShown = true))
449 Warning("GetOptions", "-- is used with several macros. "
450 "The arguments will be passed to the last one.");
451
452 macro = file;
453 }
454 }
455
456 if (macro) {
457 argv[i] = null;
458 ++i;
459 TString& str = macro->String();
460
461 str += '(';
462 for (; i < *argc; i++) {
463 str += argv[i];
464 str += ',';
465 argv[i] = null;
466 }
467 str.EndsWith(",") ? str[str.Length() - 1] = ')' : str += ')';
468 } else {
469 Warning("GetOptions", "no macro to pass arguments to was provided. "
470 "Everything after the -- will be ignored.");
471 for (; i < *argc; i++)
472 argv[i] = null;
473 }
474 } else if (argv[i][0] != '-' && argv[i][0] != '+') {
476 Long_t id, flags, modtime;
477 char *arg = strchr(argv[i], '(');
478 if (arg) *arg = '\0';
481 // ROOT-9959: we do not continue if we could not expand the path
482 continue;
483 }
485 // remove options and anchor to check the path
486 TString sfx = udir.GetFileAndOptions();
487 TString fln = udir.GetFile();
488 sfx.Replace(sfx.Index(fln), fln.Length(), "");
489 TString path = udir.GetFile();
490 if (strcmp(udir.GetProtocol(), "file")) {
491 path = udir.GetUrl();
492 path.Replace(path.Index(sfx), sfx.Length(), "");
493 }
494 // 'path' is the full URL without suffices (options and/or anchor)
495 if (arg) *arg = '(';
496 if (!arg && !gSystem->GetPathInfo(path.Data(), &id, &size, &flags, &modtime)) {
497 if ((flags & 2)) {
498 // if directory set it in fWorkDir
499 if (pwd == "") {
500 pwd = gSystem->WorkingDirectory();
503 argv[i] = null;
504 } else if (!strcmp(gROOT->GetName(), "Rint")) {
505 Warning("GetOptions", "only one directory argument can be specified (%s)", expandedDir.Data());
506 }
507 } else if (size > 0) {
508 // if file add to list of files to be processed
509 if (!fFiles) fFiles = new TObjArray;
510 fFiles->Add(new TObjString(path.Data()));
511 argv[i] = null;
512 } else {
513 Warning("GetOptions", "file %s has size 0, skipping", expandedDir.Data());
514 }
515 } else {
516 if (TString(udir.GetFile()).EndsWith(".root")) {
517 if (!strcmp(udir.GetProtocol(), "file")) {
518 // file ending on .root but does not exist, likely a typo
519 // warn user if plain root...
520 if (!strcmp(gROOT->GetName(), "Rint"))
521 Warning("GetOptions", "file %s not found", expandedDir.Data());
522 } else {
523 // remote file, give it the benefit of the doubt and add it to list of files
524 if (!fFiles) fFiles = new TObjArray;
525 fFiles->Add(new TObjString(argv[i]));
526 argv[i] = null;
527 }
528 } else {
531 char *mac;
532 if (!fFiles) fFiles = new TObjArray;
534 kReadPermission))) {
535 // if file add to list of files to be processed
536 fFiles->Add(new TObjString(argv[i]));
537 argv[i] = null;
538 delete [] mac;
539 } else {
540 // if file add an invalid entry to list of files to be processed
541 fFiles->Add(new TNamed("NOT FOUND!", argv[i]));
542 // only warn if we're plain root,
543 // other progs might have their own params
544 if (!strcmp(gROOT->GetName(), "Rint")) {
545 Error("GetOptions", "macro %s not found", fname.Data());
546 // Return 2 as the Python interpreter does in case the macro
547 // is not found.
548 Terminate(2);
549 }
550 }
551 }
552 }
553 }
554 // ignore unknown options
555 }
556
557 // go back to startup directory
558 if (pwd != "")
560
561 // remove handled arguments from argument array
562 j = 0;
563 for (i = 0; i < *argc; i++) {
564 if (strcmp(argv[i], "")) {
565 argv[j] = argv[i];
566 j++;
567 }
568 }
569
570 *argc = j;
571}
572
573////////////////////////////////////////////////////////////////////////////////
574/// Handle idle timeout. When this timer expires the registered idle command
575/// will be executed by this routine and a signal will be emitted.
576
578{
579 if (!fIdleCommand.IsNull())
581
582 Emit("HandleIdleTimer()");
583}
584
585////////////////////////////////////////////////////////////////////////////////
586/// Handle exceptions (kSigBus, kSigSegmentationViolation,
587/// kSigIllegalInstruction and kSigFloatingException) trapped in TSystem.
588/// Specific TApplication implementations may want something different here.
589
591{
592 if (TROOT::Initialized()) {
593 if (gException) {
594 gInterpreter->RewindDictionary();
595 gInterpreter->ClearFileBusy();
596 }
597 if (fExitOnException == kExit)
598 gSystem->Exit(128 + sig);
599 else if (fExitOnException == kAbort)
600 gSystem->Abort();
601 else
602 Throw(sig);
603 }
604 gSystem->Exit(128 + sig);
605}
606
607////////////////////////////////////////////////////////////////////////////////
608/// Set the exit on exception option. Setting this option determines what
609/// happens in HandleException() in case an exception (kSigBus,
610/// kSigSegmentationViolation, kSigIllegalInstruction or kSigFloatingException)
611/// is trapped. Choices are: kDontExit (default), kExit or kAbort.
612/// Returns the previous value.
613
620
621/////////////////////////////////////////////////////////////////////////////////
622/// The function generates and executes a command that loads the Doxygen URL in
623/// a browser. It works for Mac, Windows and Linux. In the case of Linux, the
624/// function also checks if the DISPLAY is set. If it isn't, a warning message
625/// and the URL will be displayed on the terminal.
626///
627/// \param[in] url web page to be displayed in a browser
628
630{
631 // We check what operating system the user has.
632#ifdef R__MACOSX
633 // Command for opening a browser on Mac.
634 TString cMac("open ");
635 // We generate the full command and execute it.
636 cMac.Append(url);
637 gSystem->Exec(cMac);
638#elif defined(R__WIN32)
639 // Command for opening a browser on Windows.
640 TString cWindows("start \"\" ");
641 cWindows.Append(url);
643#else
644 // Command for opening a browser in Linux.
645 TString cLinux("xdg-open ");
646 // For Linux we check if the DISPLAY is set.
647 if (gSystem->Getenv("DISPLAY")) {
648 // If the DISPLAY is set it will open the browser.
649 cLinux.Append(url);
651 } else {
652 // Else the user will have a warning and the URL in the terminal.
653 Warning("OpenInBrowser", "The $DISPLAY is not set! Please open (e.g. Ctrl-click) %s\n", url.Data());
654 return;
655 }
656#endif
657 Info("OpenInBrowser", "A new tab should have opened in your browser.");
658}
659
660namespace {
662////////////////////////////////////////////////////////////////////////////////
663/// The function generates a URL address for class or namespace (scopeName).
664/// This is the URL to the online reference guide, generated by Doxygen.
665/// With the enumeration "EUrl" we pick which case we need - the one for
666/// class (kURLforClass) or the one for namespace (kURLforNameSpace).
667///
668/// \param[in] scopeName the name of the class or the namespace
669/// \param[in] scopeType the enumerator for class or namespace
670
672{
673 // We start the URL with a static part, the same for all scopes and members.
674 TString url = "https://root.cern/doc/";
675 // Then we check the ROOT version used.
676 TPRegexp re4(R"(.*/(v\d)-(\d\d)-00-patches)");
677 const char *branchName = gROOT->GetGitBranch();
678 TObjArray *objarr = re4.MatchS(branchName);
680 // We extract the correct version name for the URL.
681 if (objarr && objarr->GetEntries() == 3) {
682 // We have a valid version of ROOT and we will extract the correct name for the URL.
683 version = ((TObjString *)objarr->At(1))->GetString() + ((TObjString *)objarr->At(2))->GetString();
684 } else {
685 // If it's not a supported version, we will go to "master" branch.
686 version = "master";
687 }
688 delete objarr;
689 url.Append(version);
690 url.Append("/");
691 // We will replace all "::" with "_1_1" and all "_" with "__" in the
692 // classes definitions, due to Doxygen syntax requirements.
693 scopeName.ReplaceAll("_", "__");
694 scopeName.ReplaceAll("::", "_1_1");
695 // We build the URL for the correct scope type and name.
696 if (scopeType == kURLforClass) {
697 url.Append("class");
698 } else if (scopeType == kURLforStruct) {
699 url.Append("struct");
700 } else {
701 url.Append("namespace");
702 }
703 url.Append(scopeName);
704 url.Append(".html");
705 return url;
706}
707} // namespace
708
709namespace {
710////////////////////////////////////////////////////////////////////////////////
711/// The function returns a TString with the arguments of a method from the
712/// scope (scopeName), but modified with respect to Doxygen syntax - spacing
713/// around special symbols and adding the missing scopes ("std::").
714/// "FormatMethodArgsForDoxygen" works for functions defined inside namespaces
715/// as well. We avoid looking up twice for the TFunction by passing "func".
716///
717/// \param[in] scopeName the name of the class/namespace/struct
718/// \param[in] func pointer to the method
719
721{
722 // With "GetSignature" we get the arguments of the method and put them in a TString.
724 // "methodArguments" is modified with respect of Doxygen requirements.
725 methodArguments.ReplaceAll(" = ", "=");
726 methodArguments.ReplaceAll("* ", " *");
727 methodArguments.ReplaceAll("*=", " *=");
728 methodArguments.ReplaceAll("*)", " *)");
729 methodArguments.ReplaceAll("*,", " *,");
730 methodArguments.ReplaceAll("*& ", " *&");
731 methodArguments.ReplaceAll("& ", " &");
732 // TODO: prepend "std::" to all stdlib classes!
733 methodArguments.ReplaceAll("ostream", "std::ostream");
734 methodArguments.ReplaceAll("istream", "std::istream");
735 methodArguments.ReplaceAll("map", "std::map");
736 methodArguments.ReplaceAll("vector", "std::vector");
737 // We need to replace the "currentClass::foo" with "foo" in the arguments.
738 // TODO: protect the global functions.
739 TString scopeNameRE("\\b");
740 scopeNameRE.Append(scopeName);
741 scopeNameRE.Append("::\\b");
743 argFix.Substitute(methodArguments, "");
744 return methodArguments;
745}
746} // namespace
747
748namespace {
749////////////////////////////////////////////////////////////////////////////////
750/// The function returns a TString with the text as an encoded url so that it
751/// can be passed to the function OpenInBrowser
752///
753/// \param[in] text the input text
754/// \return the text appropriately escaped
755
757{
758 text.ReplaceAll("\n","%0A");
759 text.ReplaceAll("#","%23");
760 text.ReplaceAll(";","%3B");
761 text.ReplaceAll("\"","%22");
762 text.ReplaceAll("`","%60");
763 text.ReplaceAll("+","%2B");
764 text.ReplaceAll("/","%2F");
765 return text;
766}
767} // namespace
768
769namespace {
770////////////////////////////////////////////////////////////////////////////////
771/// The function checks if a member function of a scope is defined as inline.
772/// If so, it also checks if it is virtual. Then the return type of "func" is
773/// modified for the need of Doxygen and with respect to the function
774/// definition. We pass pointer to the method (func) to not re-do the
775/// TFunction lookup.
776///
777/// \param[in] scopeName the name of the class/namespace/struct
778/// \param[in] func pointer to the method
779
781{
782 // We put the return type of "func" in a TString "returnType".
784 // If the return type is a type nested in the current class, it will appear scoped (Class::Enumeration).
785 // Below we make sure to remove the current class, because the syntax of Doxygen requires it.
786 TString scopeNameRE("\\b");
787 scopeNameRE.Append(scopeName);
788 scopeNameRE.Append("::\\b");
790 returnFix.Substitute(returnType, "");
791 // We check is if the method is defined as inline.
792 if (func->ExtraProperty() & kIsInlined) {
793 // We check if the function is defined as virtual.
794 if (func->Property() & kIsVirtual) {
795 // If the function is virtual, we append "virtual" before the return type.
796 returnType.Prepend("virtual ");
797 }
798 returnType.ReplaceAll(" *", "*");
799 } else {
800 // If the function is not inline we only change the spacing in "returnType"
801 returnType.ReplaceAll("*", " *");
802 }
803 // In any case (with no respect to virtual/inline check) we need to change
804 // the return type as following.
805 // TODO: prepend "std::" to all stdlib classes!
806 returnType.ReplaceAll("istream", "std::istream");
807 returnType.ReplaceAll("ostream", "std::ostream");
808 returnType.ReplaceAll("map", "std::map");
809 returnType.ReplaceAll("vector", "std::vector");
810 returnType.ReplaceAll("&", " &");
811 return returnType;
812}
813} // namespace
814
815namespace {
816////////////////////////////////////////////////////////////////////////////////
817/// The function generates a URL for "dataMemberName" defined in "scopeName".
818/// It returns a TString with the URL used in the online reference guide,
819/// generated with Doxygen. For data members the URL consist of 2 parts -
820/// URL for "scopeName" and a part for "dataMemberName".
821/// For enumerator, the URL could be separated into 3 parts - URL for
822/// "scopeName", part for the enumeration and a part for the enumerator.
823///
824/// \param[in] scopeName the name of the class/namespace/struct
825/// \param[in] dataMemberName the name of the data member/enumerator
826/// \param[in] dataMember pointer to the data member/enumerator
827/// \param[in] scopeType enumerator to the scope type
828
829static TString
831{
832 // We first check if the data member is not enumerator.
833 if (!dataMember->IsEnum()) {
834 // If we work with data members, we have to append a hashed with MD5 text, consisting of:
835 // "Type ClassName::DataMemberNameDataMemberName(arguments)".
836 // We first get the type of the data member.
837 TString md5DataMember(dataMember->GetFullTypeName());
838 md5DataMember.Append(" ");
839 // We append the scopeName and "::".
840 md5DataMember.Append(scopeName);
841 md5DataMember.Append("::");
842 // We append the dataMemberName twice.
845 // We call UrlGenerator for the scopeName.
847 // Then we append "#a" and the hashed text.
848 urlForDataMember.Append("#a");
849 urlForDataMember.Append(md5DataMember.MD5());
850 return urlForDataMember;
851 }
852 // If the data member is enumerator, then we first have to check if the enumeration is anonymous.
853 // Doxygen requires different syntax for anonymous enumeration ("scopeName::@1@1").
854 // We create a TString with the name of the scope and the enumeration from which the enumerator is.
855 TString scopeEnumeration = dataMember->GetTrueTypeName();
857 if (scopeEnumeration.Contains("(unnamed)")) {
858 // FIXME: need to investigate the numbering scheme.
859 md5EnumClass.Append(scopeName);
860 md5EnumClass.Append("::@1@1");
861 } else {
862 // If the enumeration is not anonymous we put "scopeName::Enumeration" in a TString,
863 // which will be hashed with MD5 later.
865 // We extract the part after "::" (this is the enumerator name).
867 // The syntax is "Class::EnumeratorEnumerator
869 }
870 // The next part of the URL is hashed "@ scopeName::EnumeratorEnumerator".
872 md5Enumerator.Append(scopeName);
873 md5Enumerator.Append("::");
876 // We make the URL for the "scopeName".
878 // Then we have to append the hashed text for the enumerator.
879 url.Append("#a");
880 url.Append(md5EnumClass.MD5());
881 // We append "a" and then the next hashed text.
882 url.Append("a");
883 url.Append(md5Enumerator.MD5());
884 return url;
885}
886} // namespace
887
888namespace {
889////////////////////////////////////////////////////////////////////////////////
890/// The function generates URL for enumeration. The hashed text consist of:
891/// "Class::EnumerationEnumeration".
892///
893/// \param[in] scopeName the name of the class/namespace/struct
894/// \param[in] enumeration the name of the enumeration
895/// \param[in] scopeType enumerator for class/namespace/struct
896
898{
899 // The URL consists of URL for the "scopeName", "#a" and hashed as MD5 text.
900 // The text is "Class::EnumerationEnumeration.
902 md5Enumeration.Append("::");
905 // We make the URL for the scope "scopeName".
907 // Then we have to append "#a" and the hashed text.
908 url.Append("#a");
909 url.Append(md5Enumeration.MD5());
910 return url;
911}
912} // namespace
913
914namespace {
915enum EMethodKind { kURLforMethod, kURLforStructor };
916////////////////////////////////////////////////////////////////////////////////
917/// The function generates URL for any member function (including Constructor/
918/// Destructor) of "scopeName". Doxygen first generates the URL for the scope.
919/// We do that with the help of "UrlGenerator". Then we append "#a" and a
920/// hashed with MD5 text. It consists of:
921/// "ReturnType ScopeName::MethodNameMethodName(Method arguments)".
922/// For constructor/destructor of a class, the return type is not appended.
923///
924/// \param[in] scopeName the name of the class/namespace/struct
925/// \param[in] methodName the name of the method from the scope
926/// \param[in] func pointer to the method
927/// \param[in] methodType enumerator for method or constructor
928/// \param[in] scopeType enumerator for class/namespace/struct
929
930static TString GetUrlForMethod(const TString &scopeName, const TString &methodName, TFunction *func,
931 EMethodKind methodType, EUrl scopeType)
932{
934 if (methodType == kURLforMethod) {
935 // In the case of method, we append the return type too.
936 // "FormatReturnTypeForDoxygen" modifies the return type with respect to Doxygen's requirement.
939 // We need to append "constexpr" if we work with constexpr functions in namespaces.
940 if (func->Property() & kIsConstexpr) {
941 md5Text.Prepend("constexpr ");
942 }
943 }
944 md5Text.Append(" ");
945 }
946 // We append ScopeName::MethodNameMethodName.
947 md5Text.Append(scopeName);
948 md5Text.Append("::");
949 md5Text.Append(methodName);
950 md5Text.Append(methodName);
951 // We use "FormatMethodArgsForDoxygen" to modify the arguments of Method with respect of Doxygen.
953 // We generate the URL for the class/namespace/struct.
955 url.Append("#a");
956 // We append the hashed text.
957 url.Append(md5Text.MD5());
958 return url;
959}
960} // namespace
961
962////////////////////////////////////////////////////////////////////////////////
963/// It gets the ROOT installation setup as TString
964///
965/// \return a string with several lines
966///
968{
969 std::vector<TString> lines;
970 lines.emplace_back("```");
971 lines.emplace_back(TString::Format("ROOT v%s",
972 gROOT->GetVersion()));
973 lines.emplace_back(TString::Format("Built for %s on %s", gSystem->GetBuildArch(), gROOT->GetGitDate()));
974 if (!strcmp(gROOT->GetGitBranch(), gROOT->GetGitCommit())) {
975 static const char *months[] = {"January","February","March","April","May",
976 "June","July","August","September","October",
977 "November","December"};
978 Int_t idatqq = gROOT->GetVersionDate();
979 Int_t iday = idatqq%100;
980 Int_t imonth = (idatqq/100)%100;
981 Int_t iyear = (idatqq/10000);
982
983 lines.emplace_back(TString::Format("From tag %s, %d %s %4d",
984 gROOT->GetGitBranch(),
985 iday,months[imonth-1],iyear));
986 } else {
987 // If branch and commit are identical - e.g. "v5-34-18" - then we have
988 // a release build. Else specify the git hash this build was made from.
989 lines.emplace_back(TString::Format("From %s@%s",
990 gROOT->GetGitBranch(),
991 gROOT->GetGitCommit()));
992 }
993 lines.emplace_back(TString::Format("With %s",
995 lines.emplace_back("Binary directory: "+ gROOT->GetBinDir());
996 lines.emplace_back("```");
997 TString setup = "";
998 for (auto& line : lines) {
999 setup.Append(line);
1000 setup.Append('\n');
1001 }
1002 setup.Chop(); // trim final `\n`
1003 return setup;
1004}
1005
1006////////////////////////////////////////////////////////////////////////////////
1007/// It opens a Forum topic in a web browser with prefilled ROOT version
1008///
1009/// \param[in] type the issue type (only bug supported right now)
1010
1012{
1013 // https://meta.discourse.org/t/how-to-create-a-post-clicking-a-link/96197
1014
1015 if (type == "bug") {
1016 //OpenInBrowser("\"https://root-forum.cern.ch/new-topic?title=topic%20title&body=topic%20body&category=category/subcategory&tags=email,planned\"");
1018R"(___
1019_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_
1020
1021### Describe the bug
1022<!--
1023A clear and concise description of what the wrong behavior is.
1024-->
1025### Expected behavior
1026<!--
1027A clear and concise description of what you expected to happen.
1028-->
1029
1030### To Reproduce
1031<!--
1032Steps to reproduce the behavior:
10331. Your code that triggers the issue: at least a part; ideally something we can run ourselves.
10342. Don't forget to attach the required input files!
10353. How to run your code and / or build it, e.g. `root myMacro.C`, ...
1036-->
1037
1038### Setup
1039)"+GetSetup()+
1040R"(
1041<!--
1042Please specify also how you obtained ROOT, such as `dnf install` / binary download / you built it yourself.
1043-->
1044
1045### Additional context
1046<!--
1047Add any other context about the problem here.
1048-->)";
1050
1051 OpenInBrowser("\"https://root-forum.cern.ch/new-topic?category=ROOT&tags=bug&body="+report_template+"&\"");
1052 } else {
1053 Warning("OpenForumTopic", "cannot find \"%s\" as type for a Forum topic\n"
1054 "Available types are 'bug'.", type.Data());
1055 }
1056}
1057
1058////////////////////////////////////////////////////////////////////////////////
1059/// It opens a GitHub issue in a web browser with prefilled ROOT version
1060///
1061/// \param[in] type the issue type (bug, feature or improvement)
1062
1064{
1065 // https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue#creating-an-issue-from-a-url-query
1066
1067 if (type == "bug") {
1069 "\"https://github.com/root-project/root/issues/new?labels=bug&template=bug_report.yml&root-version=" +
1070 FormatHttpUrl(GetSetup()) + "\"");
1071 } else if (type == "improvement") {
1072 OpenInBrowser("\"https://github.com/root-project/root/issues/"
1073 "new?labels=improvement&template=improvement_report.yml&root-version=" +
1074 FormatHttpUrl(GetSetup()) + "\"");
1075 } else if (type == "feature") {
1077 "\"https://github.com/root-project/root/issues/new?labels=new+feature&template=feature_request.yml\"");
1078 } else {
1079 Warning("OpenGitHubIssue",
1080 "Cannot find GitHub issue type \"%s\".\n"
1081 "Available types are 'bug', 'feature' and 'improvement'.",
1082 type.Data());
1083 }
1084}
1085
1086////////////////////////////////////////////////////////////////////////////////
1087/// It opens the online reference guide, generated with Doxygen, for the
1088/// chosen scope (class/namespace/struct) or member (method/function/
1089/// data member/enumeration/enumerator. If the user types incorrect value,
1090/// it will return an error or warning.
1091///
1092/// \param[in] strippedClass the scope or scope::member
1093
1095{
1096 // We check if the user is searching for a scope and if the scope exists.
1098 // We check what scope he is searching for (class/namespace/struct).
1099 // Enumerators will switch between the possible cases.
1100 EUrl scopeType;
1101 if (clas->Property() & kIsNamespace) {
1103 } else if (clas->Property() & kIsStruct) {
1105 } else {
1107 }
1108 // If the user search directly for a scope we open the URL for him with OpenInBrowser.
1110 return;
1111 }
1112 // Else we subtract the name of the method and remove it from the command.
1114 // Error out if "strippedClass" is un-scoped (and it's not a class, see `TClass::GetClass(strippedClass)` above).
1115 // TODO: Global functions.
1116 if (strippedClass == memberName) {
1117 Error("OpenReferenceGuideFor", "Unknown entity \"%s\" - global variables / functions not supported yet!",
1118 strippedClass.Data());
1119 return;
1120 }
1121 // Else we remove the member name to be left with the scope.
1122 TString scopeName = strippedClass(0, strippedClass.Length() - memberName.Length() - 2);
1123 // We check if the scope exists in ROOT.
1125 if (!cl) {
1126 // That's a member of something ROOT doesn't know.
1127 Warning("OpenReferenceGuideFor", "\"%s\" does not exist in ROOT!", scopeName.Data());
1128 return;
1129 }
1130 // We have enumerators for the three available cases - class, namespace and struct.
1131 EUrl scopeType;
1132 if (cl->Property() & kIsNamespace) {
1134 } else if (cl->Property() & kIsStruct) {
1136 } else {
1138 }
1139 // If the user wants to search for a method, we take its name (memberName) and
1140 // modify it - we delete everything starting at the first "(" so the user won't have to
1141 // do it by hand when they use Tab.
1142 int bracket = memberName.First("(");
1143 if (bracket > 0) {
1144 memberName.Remove(bracket);
1145 }
1146 // We check if "memberName" is a member function of "cl" or any of its base classes.
1147 if (TFunction *func = cl->GetMethodAllAny(memberName)) {
1148 // If so we find the name of the class that it belongs to.
1149 TString baseClName = ((TMethod *)func)->GetClass()->GetName();
1150 // We define an enumerator to distinguish between structor and method.
1151 EMethodKind methodType;
1152 // We check if "memberName" is a constructor.
1153 if (baseClName == memberName) {
1155 // We check if "memberName" is a destructor.
1156 } else if (memberName[0] == '~') {
1158 // We check if "memberName" is a method.
1159 } else {
1161 }
1162 // We call "GetUrlForMethod" for the correct class and scope.
1164 return;
1166 // We check if "memberName" is an enumeration.
1167 if (cl->GetListOfEnums()->FindObject(memberName)) {
1168 // If so with OpenInBrowser we open the URL generated with GetUrlForEnumeration
1169 // with respect to the "scopeType".
1171 return;
1172 }
1173
1174 // We check if "memberName" is enumerator defined in one the base classes of "scopeName".
1176 // We find the actual scope (might be in a base) and open the URL in a browser.
1177 TString baseClName = ((TMethod *)enumerator->GetClass())->GetName();
1179 return;
1180 }
1181
1182 // Warning message will appear if the user types the function name incorrectly
1183 // or the function is not a member function of "cl" or any of its base classes.
1184 Warning("OpenReferenceGuideFor", "cannot find \"%s\" as member of %s or its base classes! Check %s\n", memberName.Data(),
1185 scopeName.Data(), UrlGenerator(scopeName, scopeType).Data());
1187
1188////////////////////////////////////////////////////////////////////////////////
1189/// The function (".forum <type>") submits a new post on the ROOT forum
1190/// via web browser.
1191/// \note You can use "bug" as <type>.
1192/// \param[in] line command from the command line
1193
1194void TApplication::Forum(const char *line)
1195{
1196 // We first check if the user chose a correct syntax.
1198 if (!strippedCommand.BeginsWith(".forum ")) {
1199 Error("Forum", "Unknown command! Use 'bug' after '.forum '");
1200 return;
1201 }
1202 // We remove the command ".forum" from the TString.
1203 strippedCommand.Remove(0, 7);
1204 // We strip the command line after removing ".help" or ".?".
1206
1209
1210////////////////////////////////////////////////////////////////////////////////
1211/// The function (".gh <type>") submits a new issue on GitHub via web browser.
1212/// \note You can use "bug", "feature" or "improvement" as <type>.
1213/// \param[in] line command from the command line
1214
1215void TApplication::GitHub(const char *line)
1216{
1217 // We first check if the user chose a correct syntax.
1219 if (!strippedCommand.BeginsWith(".gh ")) {
1220 Error("GitHub", "Unknown command! Use 'bug', 'feature' or 'improvement' after '.gh '");
1221 return;
1222 }
1223 // We remove the command ".gh" from the TString.
1224 strippedCommand.Remove(0, 4);
1225 // We strip the command line after removing ".help" or ".?".
1227
1229}
1230
1231////////////////////////////////////////////////////////////////////////////////
1232/// The function lists useful commands (".help") or opens the online reference
1233/// guide, generated with Doxygen (".help scope" or ".help scope::member").
1234/// \note You can use ".?" as the short version of ".help"
1235/// \param[in] line command from the command line
1236
1237void TApplication::Help(const char *line)
1238{
1239 // We first check if the user wants to print the help on the interpreter.
1241 // If the user chooses ".help" or ".?".
1242 if ((strippedCommand == ".help") || (strippedCommand == ".?")) {
1243 gInterpreter->ProcessLine(line);
1244 Printf("\n ROOT special commands.");
1245 Printf(" ==============================================================================");
1246 Printf(" .L <filename>[flags]: load the given file with optional flags like\n"
1247 " + to compile or ++ to force recompile.\n"
1248 " Type .? TSystem::CompileMacro for a list of all flags.\n"
1249 " <filename> can also be a shared library; skip flags.");
1250 Printf(" .(x|X) <filename>[flags](args) :\n"
1251 " same as .L <filename>[flags] and runs then a function\n"
1252 " with signature: ret_type filename(args).");
1253 Printf(" .credits : show credits");
1254 Printf(" .demo : launch GUI demo");
1255 Printf(" .forum bug : ask for help with a bug or crash at the ROOT forum.");
1256 Printf(" .gh [bug|feature|improvement]\n"
1257 " : submit a bug report, feature or improvement suggestion");
1258 Printf(" .help Class::Member : open reference guide for that class member (or .?).\n"
1259 " Specifying '::Member' is optional.");
1260 Printf(" .help edit : show line editing shortcuts (or .?)");
1261 Printf(" .license : show license");
1262 Printf(" .libraries : show loaded libraries");
1263 Printf(" .ls : list contents of current TDirectory");
1264 Printf(" .pwd : show current TDirectory, pad and style");
1265 Printf(" .quit (or .exit) : quit ROOT (long form of .q)");
1266 Printf(" .R [user@]host[:dir] [-l user] [-d dbg] [script] :\n"
1267 " launch process in a remote host");
1268 Printf(" .qqq : quit ROOT - mandatory");
1269 Printf(" .qqqqq : exit process immediately");
1270 Printf(" .qqqqqqq : abort process");
1271 Printf(" .which [file] : show path of macro file");
1272 Printf(" .![OS_command] : execute OS-specific shell command");
1273 Printf(" .!root -? : print ROOT usage (CLI options)");
1274 return;
1275 } else {
1276 // If the user wants to use the extended ".help scopeName" command to access
1277 // the online reference guide, we first check if the command starts correctly.
1278 if ((!strippedCommand.BeginsWith(".help ")) && (!strippedCommand.BeginsWith(".? "))) {
1279 Error("Help", "Unknown command!");
1280 return;
1281 }
1282 // We remove the command ".help" or ".?" from the TString.
1283 if (strippedCommand.BeginsWith(".? ")) {
1284 strippedCommand.Remove(0, 3);
1285 } else {
1286 strippedCommand.Remove(0, 5);
1287 }
1288 // We strip the command line after removing ".help" or ".?".
1290
1291 if (strippedCommand == "edit") {
1292 Printf("\n ROOT terminal keyboard shortcuts (GNU-readline style).");
1293 #ifdef R__MACOSX
1294 #define FOOTNOTE " *"
1295 Printf("* Some of these commands might be intercepted by macOS predefined system shortcuts.");
1296 // https://apple.stackexchange.com/questions/18043/how-can-i-make-ctrlright-left-arrow-stop-changing-desktops-in-lion
1297 #else
1298 #define FOOTNOTE ""
1299 #endif
1300 Printf(" ==============================================================================");
1301 Printf(" Arrow_Left : move cursor left [Ctrl+B]");
1302 Printf(" Arrow_Right : move cursor right [Ctrl+F] [Ctrl+G]");
1303 #ifdef R__MACOSX
1304 Printf(" Fn+Arrow_Left : move cursor to beginning of line [Ctrl+A]");
1305 #else
1306 Printf(" Home : move cursor to beginning of line [Ctrl+A]");
1307 #endif
1308 #ifdef R__MACOSX
1309 Printf(" Fn+Arrow_Right : move cursor to end of line [Ctrl+E]");
1310 #else
1311 Printf(" End : move cursor to end of line [Ctrl+E]");
1312 #endif
1313 Printf(" Ctrl+Arrow_Left : jump to previous word [Esc,B] [Alt,B]" FOOTNOTE);
1314 Printf(" Ctrl+Arrow_Right : jump to next word [Esc,F] [Alt,F]" FOOTNOTE);
1315
1316 Printf(" Backspace : delete previous character [Ctrl+H]");
1317 Printf(" Del : delete next character [Ctrl+D]");
1318 Printf(" Esc,Backspace : delete previous word [Ctrl+W] [Esc,Ctrl+H] [Alt+Backspace] [Esc,Del] [Esc,Ctrl+Del]" FOOTNOTE);// Del is 0x7F on macOS
1319 Printf(" Ctrl+Del : delete next word [Esc,D] [Alt,D]" FOOTNOTE);
1320 Printf(" Ctrl+U : cut all characters between cursor and start of line");
1321 Printf(" Ctrl+K : cut all characters between cursor and end of line");
1322
1323 Printf(" Ctrl+T : transpose characters");
1324 Printf(" Esc,C : character to upper and jump to next word");
1325 Printf(" Esc,L : word to lower case and jump to its end");
1326 Printf(" Esc,U : word to upper case and jump to its end");
1327 Printf(" Ctrl+Shift+C : copy clipboard content");
1328 Printf(" Ctrl+Shift+V : paste clipboard content [Ctrl+Y] [Alt+Y]");
1329 #ifdef R__MACOSX
1330 Printf(" Fn+Enter : toggle overwrite mode");
1331 #else
1332 Printf(" Ins : toggle overwrite mode");
1333 #endif
1335 Printf(" Ctrl+_ : undo last keypress action");
1336 Printf(" Tab : autocomplete command or print suggestions [Ctrl+I] [Esc,Tab]");
1337 Printf(" Enter : execute command [Ctrl+J] [Ctrl+M]");
1338 Printf(" Ctrl+L : clear prompt screen");
1339 Printf(" Ctrl+D : quit ROOT (if empty line)");
1340 Printf(" Ctrl+C : send kSigInt interrupt signal");
1341 Printf(" Ctrl+Z : send kSigStop pause job signal");
1342 Printf(" Ctrl+\\ : send kSigQuit quit job signal");
1343
1344 Printf(" Arrow_Down : navigate downwards in command history [Ctrl+N]");
1345 Printf(" Arrow_Up : navigate upwards in command history [Ctrl+P]");
1346 Printf(" Ctrl+R ; Ctrl+S : search command in your history by typing a string.\n"
1347 " Use Backspace if you mistyped (but not arrows).\n"
1348 " Press Ctrl+R (Ctrl+S) repeateadly to navigate matches in reverse (forward) order");
1349 Printf(" Arrow_Right : after Ctrl+R (Ctrl+S), select current match of the history search\n"
1350 " [Ctrl+O] [Enter] [Ctrl+J] [Ctrl+M] [Arrow_Left] [Esc,Esc].\n"
1351 " Use Ctrl+F or Ctrl+G to cancel search and revert original line");
1352
1353 return;
1354 }
1355 // We call the function what handles the extended ".help scopeName" command.
1357 }
1358}
1359
1360/// Load shared libs necessary for graphics. These libraries are only
1361/// loaded when gROOT->IsBatch() is kFALSE.
1362
1364{
1365 if (gROOT->IsBatch())
1366 return;
1367
1368 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualPad"))
1369 if (h->LoadPlugin() == -1)
1370 return;
1371
1372 TString name;
1373 TString title1 = "ROOT interface to ";
1374 TString nativex, title;
1375
1376#ifdef R__WIN32
1377 nativex = "win32gdk";
1378 name = "Win32gdk";
1379 title = title1 + "Win32gdk";
1380#elif defined(R__HAS_COCOA)
1381 nativex = "quartz";
1382 name = "quartz";
1383 title = title1 + "Quartz";
1384#else
1385 nativex = "x11";
1386 name = "X11";
1387 title = title1 + "X11";
1388#endif
1389
1390 TString guiBackend = gEnv->GetValue("Gui.Backend", "native");
1391 guiBackend.ToLower();
1392 if (guiBackend == "native") {
1394 } else {
1395 name = guiBackend;
1397 }
1398
1399 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualX", guiBackend)) {
1400 if (h->LoadPlugin() == -1) {
1401 gROOT->SetBatch(kTRUE);
1402 return;
1403 }
1404 gVirtualX = (TVirtualX *) h->ExecPlugin(2, name.Data(), title.Data());
1406 }
1407
1408 TString guiFactory = gEnv->GetValue("Gui.Factory", "native");
1409 guiFactory.ToLower();
1410 if (guiFactory == "native")
1411 guiFactory = "root";
1412
1413 if (auto h = gROOT->GetPluginManager()->FindHandler("TGuiFactory", guiFactory)) {
1414 if (h->LoadPlugin() == -1) {
1415 gROOT->SetBatch(kTRUE);
1416 return;
1417 }
1418 gGuiFactory = (TGuiFactory *) h->ExecPlugin(0);
1419 }
1421
1422////////////////////////////////////////////////////////////////////////////////
1423/// Switch to batch mode.
1424
1426{
1427 gROOT->SetBatch();
1430#ifndef R__WIN32
1431 if (gVirtualX != gGXBatch) delete gVirtualX;
1432#endif
1434}
1435
1436////////////////////////////////////////////////////////////////////////////////
1437/// Parse the content of a line starting with ".R" (already stripped-off)
1438/// The format is
1439/// ~~~ {.cpp}
1440/// [user@]host[:dir] [-l user] [-d dbg] [script]
1441/// ~~~
1442/// The variable 'dir' is the remote directory to be used as working dir.
1443/// The username can be specified in two ways, "-l" having the priority
1444/// (as in ssh).
1445/// A 'dbg' value > 0 gives increasing verbosity.
1446/// The last argument 'script' allows to specify an alternative script to
1447/// be executed remotely to startup the session.
1448
1450 TString &hostdir, TString &user,
1452{
1453 if (!ln || strlen(ln) <= 0)
1454 return 0;
1455
1456 Int_t rc = 0;
1461
1462 TString line(ln);
1463 TString tkn;
1464 Int_t from = 0;
1465 while (line.Tokenize(tkn, from, " ")) {
1466 if (tkn == "-l") {
1467 // Next is a user name
1468 isUser = kTRUE;
1469 } else if (tkn == "-d") {
1470 isDbg = kTRUE;
1471 } else if (tkn == "-close") {
1472 rc = 1;
1473 } else if (tkn.BeginsWith("-")) {
1474 ::Warning("TApplication::ParseRemoteLine","unknown option: %s", tkn.Data());
1475 } else {
1476 if (isUser) {
1477 user = tkn;
1478 isUser = kFALSE;
1479 } else if (isDbg) {
1480 dbg = tkn.Atoi();
1481 isDbg = kFALSE;
1482 } else if (isHostDir) {
1483 hostdir = tkn;
1484 hostdir.ReplaceAll(":","/");
1485 isHostDir = kFALSE;
1487 } else if (isScript) {
1488 // Add everything left
1489 script = tkn;
1490 script.Insert(0, "\"");
1491 script += "\"";
1492 // isScript = kFALSE; // [clang-tidy] never read
1493 break;
1494 }
1495 }
1496 }
1497
1498 // Done
1499 return rc;
1500}
1501
1502////////////////////////////////////////////////////////////////////////////////
1503/// Process the content of a line starting with ".R" (already stripped-off)
1504/// The format is
1505/// ~~~ {.cpp}
1506/// [user@]host[:dir] [-l user] [-d dbg] [script] | [host] -close
1507/// ~~~
1508/// The variable 'dir' is the remote directory to be used as working dir.
1509/// The username can be specified in two ways, "-l" having the priority
1510/// (as in ssh).
1511/// A 'dbg' value > 0 gives increasing verbosity.
1512/// The last argument 'script' allows to specify an alternative script to
1513/// be executed remotely to startup the session.
1514
1516{
1517 if (!line) return 0;
1518
1519 if (!strncmp(line, "-?", 2) || !strncmp(line, "-h", 2) ||
1520 !strncmp(line, "--help", 6)) {
1521 Info("ProcessRemote", "remote session help:");
1522 Printf(".R [user@]host[:dir] [-l user] [-d dbg] [[<]script] | [host] -close");
1523 Printf("Create a ROOT session on the specified remote host.");
1524 Printf("The variable \"dir\" is the remote directory to be used as working dir.");
1525 Printf("The username can be specified in two ways, \"-l\" having the priority");
1526 Printf("(as in ssh). A \"dbg\" value > 0 gives increasing verbosity.");
1527 Printf("The last argument \"script\" allows to specify an alternative script to");
1528 Printf("be executed remotely to startup the session, \"roots\" being");
1529 Printf("the default. If the script is preceded by a \"<\" the script will be");
1530 Printf("sourced, after which \"roots\" is executed. The sourced script can be ");
1531 Printf("used to change the PATH and other variables, allowing an alternative");
1532 Printf("\"roots\" script to be found.");
1533 Printf("To close down a session do \".R host -close\".");
1534 Printf("To switch between sessions do \".R host\", to switch to the local");
1535 Printf("session do \".R\".");
1536 Printf("To list all open sessions do \"gApplication->GetApplications()->Print()\".");
1537 return 0;
1538 }
1539
1540 TString hostdir, user, script;
1541 Int_t dbg = 0;
1543 if (hostdir.Length() <= 0) {
1544 // Close the remote application if required
1545 if (rc == 1) {
1547 delete fAppRemote;
1548 }
1549 // Return to local run
1550 fAppRemote = nullptr;
1551 // Done
1552 return 1;
1553 } else if (rc == 1) {
1554 // close an existing remote application
1555 TApplication *ap = TApplication::Open(hostdir, 0, nullptr);
1556 if (ap) {
1558 delete ap;
1559 }
1560 }
1561 // Attach or start a remote application
1562 if (user.Length() > 0)
1563 hostdir.Insert(0, TString::Format("%s@", user.Data()));
1564 const char *sc = (script.Length() > 0) ? script.Data() : nullptr;
1566 if (ap) {
1567 fAppRemote = ap;
1568 }
1569
1570 // Done
1571 return 1;
1572}
1573
1574namespace {
1575 static int PrintFile(const char* filename) {
1579 Error("ProcessLine()", "Cannot find file %s", filename);
1580 return 1;
1581 }
1582 std::ifstream instr(sFileName);
1584 content.ReadFile(instr);
1585 Printf("%s", content.Data());
1586 return 0;
1587 }
1588 } // namespace
1589
1590////////////////////////////////////////////////////////////////////////////////
1591/// Process a single command line, either a C++ statement or an interpreter
1592/// command starting with a ".".
1593/// Return the return value of the command cast to a long.
1594
1596{
1597 if (!line || !*line) return 0;
1598
1599 // If we are asked to go remote do it
1600 if (!strncmp(line, ".R", 2)) {
1601 Int_t n = 2;
1602 while (*(line+n) == ' ')
1603 n++;
1604 return ProcessRemote(line+n, err);
1605 }
1606
1607 // Redirect, if requested
1610 return fAppRemote->ProcessLine(line, err);
1611 }
1612
1613 if (!strncasecmp(line, ".qqqqqqq", 7)) {
1614 gSystem->Abort();
1615 } else if (!strncasecmp(line, ".qqqqq", 5)) {
1616 Info("ProcessLine", "Bye... (try '.qqqqqqq' if still running)");
1617 gSystem->Exit(1);
1618 } else if (!strncasecmp(line, ".exit", 4) || !strncasecmp(line, ".quit", 2)) {
1619 Terminate(0);
1620 return 0;
1621 }
1622
1623 if (!strncmp(line, ".gh", 3)) {
1624 GitHub(line);
1625 return 1;
1626 }
1627
1628 if (!strncmp(line, ".forum", 6)) {
1629 Forum(line);
1630 return 1;
1631 }
1632
1633 if (!strncmp(line, ".?", 2) || !strncmp(line, ".help", 5)) {
1634 Help(line);
1635 return 1;
1636 }
1637
1638 if (!strncmp(line, ".demo", 5)) {
1639 if (gROOT->IsBatch()) {
1640 Error("ProcessLine", "Cannot show demos in batch mode!");
1641 return 1;
1642 }
1643 ProcessLine(".x " + TROOT::GetTutorialDir() + "/demos.C");
1644 return 0;
1645 }
1646
1647 if (!strncmp(line, ".license", 8)) {
1648 return PrintFile(TROOT::GetDocDir() + "/LICENSE");
1649 }
1650
1651 if (!strncmp(line, ".credits", 8)) {
1652 TString credits = TROOT::GetDocDir() + "/CREDITS";
1654 credits = TROOT::GetDocDir() + "/README/CREDITS";
1655 return PrintFile(credits);
1656 }
1657
1658 if (!strncmp(line, ".pwd", 4)) {
1659 if (gDirectory)
1660 Printf("Current directory: %s", gDirectory->GetPath());
1661 if (gPad)
1662 Printf("Current pad: %s", gPad->GetName());
1663 if (gStyle)
1664 Printf("Current style: %s", gStyle->GetName());
1665 return 1;
1666 }
1667
1668 if (!strncmp(line, ".ls", 3)) {
1669 const char *opt = nullptr;
1670 if (line[3]) opt = &line[3];
1671 if (gDirectory) gDirectory->ls(opt);
1672 return 1;
1673 }
1674
1675 if (!strncmp(line, ".which", 6)) {
1676 char *fn = Strip(line+7);
1677 char *s = strtok(fn, "+("); // this method does not need to be reentrant
1679 if (!mac)
1680 Printf("No macro %s in path %s", s, TROOT::GetMacroPath());
1681 else
1682 Printf("%s", mac);
1683 delete [] fn;
1684 delete [] mac;
1685 return mac ? 1 : 0;
1686 }
1687
1688 if (!strncmp(line, ".L", 2) || !strncmp(line, ".U", 2)) {
1689 TString aclicMode, arguments, io;
1690 TString fname = gSystem->SplitAclicMode(line+3, aclicMode, arguments, io);
1691
1693 if (arguments.Length())
1694 Warning("ProcessLine", "argument(s) \"%s\" ignored with .%c", arguments.Data(), line[1]);
1695 Longptr_t retval = 0;
1696 if (!mac) {
1697 Error("ProcessLine", "macro %s not found in path %s", fname.Data(), TROOT::GetMacroPath());
1698 } else {
1699 TString cmd(line + 1);
1700 Ssiz_t posSpace = cmd.Index(' ');
1701 if (posSpace == kNPOS)
1702 cmd.Remove(1);
1703 else
1704 cmd.Remove(posSpace);
1705 auto tempbuf = TString::Format(".%s %s%s%s", cmd.Data(), mac, aclicMode.Data(), io.Data());
1706 delete[] mac;
1707 if (sync)
1708 retval = gInterpreter->ProcessLineSynch(tempbuf.Data(), (TInterpreter::EErrorCode *)err);
1709 else
1710 retval = gInterpreter->ProcessLine(tempbuf.Data(), (TInterpreter::EErrorCode *)err);
1711 }
1712
1713 InitializeGraphics(gROOT->IsWebDisplay());
1714
1715 return retval;
1716 }
1717
1718 if (!strncmp(line, ".X", 2) || !strncmp(line, ".x", 2)) {
1719 return ProcessFile(line+3, err, line[2] == 'k');
1720 }
1722 if (!strcmp(line, ".reset")) {
1723 // Do nothing, .reset disabled in Cling because too many side effects
1724 Printf("*** .reset not allowed, please use gROOT->Reset() ***");
1725 return 0;
1726
1727#if 0
1728 // delete the ROOT dictionary since CINT will destroy all objects
1729 // referenced by the dictionary classes (TClass et. al.)
1730 gROOT->GetListOfClasses()->Delete();
1731 // fall through
1732#endif
1733 }
1734
1735 if (!strcmp(line, ".libraries")) {
1736 // List the loaded libraries
1738 return 0;
1739 }
1740
1741 if (sync)
1742 return gInterpreter->ProcessLineSynch(line, (TInterpreter::EErrorCode*)err);
1743 else
1744 return gInterpreter->ProcessLine(line, (TInterpreter::EErrorCode*)err);
1745}
1746
1747////////////////////////////////////////////////////////////////////////////////
1748/// Process a file containing a C++ macro.
1749
1750Longptr_t TApplication::ProcessFile(const char *file, Int_t *error, Bool_t keep)
1751{
1752 return ExecuteFile(file, error, keep);
1753}
1754
1755////////////////////////////////////////////////////////////////////////////////
1756/// Execute a file containing a C++ macro (static method). Can be used
1757/// while TApplication is not yet created.
1758
1759Longptr_t TApplication::ExecuteFile(const char *file, Int_t *error, Bool_t keep)
1760{
1761 static const Int_t kBufSize = 1024;
1762
1763 if (!file || !*file) return 0;
1764
1766 TString arguments;
1767 TString io;
1768 TString fname = gSystem->SplitAclicMode(file, aclicMode, arguments, io);
1769
1771 if (!exnam) {
1772 ::Error("TApplication::ExecuteFile", "macro %s not found in path %s", fname.Data(),
1774 delete [] exnam;
1775 if (error)
1777 return 0;
1778 }
1779
1780 ::std::ifstream macro(exnam, std::ios::in);
1781 if (!macro.good()) {
1782 ::Error("TApplication::ExecuteFile", "%s no such file", exnam);
1783 if (error)
1785 delete [] exnam;
1786 return 0;
1787 }
1788
1789 char currentline[kBufSize];
1790 char dummyline[kBufSize];
1791 int tempfile = 0;
1792 int comment = 0;
1793 int ifndefc = 0;
1794 int ifdef = 0;
1795 char *s = nullptr;
1796 Bool_t execute = kFALSE;
1797 Longptr_t retval = 0;
1798
1799 while (1) {
1800 bool res = (bool)macro.getline(currentline, kBufSize);
1801 if (macro.eof()) break;
1802 if (!res) {
1803 // Probably only read kBufSize, let's ignore the remainder of
1804 // the line.
1805 macro.clear();
1806 while (!macro.getline(dummyline, kBufSize) && !macro.eof()) {
1807 macro.clear();
1808 }
1809 }
1810 s = currentline;
1811 while (s && (*s == ' ' || *s == '\t')) s++; // strip-off leading blanks
1812
1813 // very simple minded pre-processor parsing, only works in case macro file
1814 // starts with "#ifndef __CINT__". In that case everything till next
1815 // "#else" or "#endif" will be skipped.
1816 if (*s == '#') {
1817 char *cs = Compress(currentline);
1818 if (strstr(cs, "#ifndef__CINT__") ||
1819 strstr(cs, "#if!defined(__CINT__)"))
1820 ifndefc = 1;
1821 else if (ifndefc && (strstr(cs, "#ifdef") || strstr(cs, "#ifndef") ||
1822 strstr(cs, "#ifdefined") || strstr(cs, "#if!defined")))
1823 ifdef++;
1824 else if (ifndefc && strstr(cs, "#endif")) {
1825 if (ifdef)
1826 ifdef--;
1827 else
1828 ifndefc = 0;
1829 } else if (ifndefc && !ifdef && strstr(cs, "#else"))
1830 ifndefc = 0;
1831 delete [] cs;
1832 }
1833 if (!*s || *s == '#' || ifndefc || !strncmp(s, "//", 2)) continue;
1834
1835 if (!comment && (!strncmp(s, ".X", 2) || !strncmp(s, ".x", 2))) {
1836 retval = ExecuteFile(s+3);
1837 execute = kTRUE;
1838 continue;
1839 }
1840
1841 if (!strncmp(s, "/*", 2)) comment = 1;
1842 if (comment) {
1843 // handle slightly more complex cases like: /* */ /*
1844again:
1845 s = strstr(s, "*/");
1846 if (s) {
1847 comment = 0;
1848 s += 2;
1849
1850 while (s && (*s == ' ' || *s == '\t')) s++; // strip-off leading blanks
1851 if (!*s) continue;
1852 if (!strncmp(s, "//", 2)) continue;
1853 if (!strncmp(s, "/*", 2)) {
1854 comment = 1;
1855 goto again;
1856 }
1857 }
1858 }
1859 if (!comment && *s == '{') tempfile = 1;
1860 if (!comment) break;
1862 macro.close();
1863
1864 if (!execute) {
1866 if (!tempfile) {
1867 // We have a script that does NOT contain an unnamed macro,
1868 // so we can call the script compiler on it.
1869 exname += aclicMode;
1870 }
1871 exname += arguments;
1872 exname += io;
1873
1876 tempbuf.Form(".x %s", exname.Data());
1877 } else {
1878 tempbuf.Form(".X%s %s", keep ? "k" : " ", exname.Data());
1879 }
1880 retval = gInterpreter->ProcessLineSynch(tempbuf,(TInterpreter::EErrorCode*)error);
1881 }
1882
1883 delete [] exnam;
1884 return retval;
1885}
1887////////////////////////////////////////////////////////////////////////////////
1888/// Main application eventloop. Calls system dependent eventloop via gSystem.
1889
1891{
1893
1894 fIsRunning = kTRUE;
1895
1896 gSystem->Run();
1898}
1899
1900////////////////////////////////////////////////////////////////////////////////
1901/// Set the command to be executed after the system has been idle for
1902/// idleTimeInSec seconds. Normally called via TROOT::Idle(...).
1903
1905{
1910}
1911
1912////////////////////////////////////////////////////////////////////////////////
1913/// Remove idle timer. Normally called via TROOT::Idle(0).
1914
1916{
1917 if (fIdleTimer) {
1918 // timers are removed from the gSystem timer list by their dtor
1920 }
1921}
1922
1923////////////////////////////////////////////////////////////////////////////////
1924/// Called when system starts idleing.
1925
1927{
1929 fIdleTimer->Reset();
1931 }
1932}
1933
1934////////////////////////////////////////////////////////////////////////////////
1935/// Called when system stops idleing.
1936
1938{
1939 if (fIdleTimer)
1941}
1943////////////////////////////////////////////////////////////////////////////////
1944/// What to do when tab is pressed. Re-implemented by TRint.
1945/// See TTabCom::Hook() for meaning of return values.
1946
1947Int_t TApplication::TabCompletionHook(char* /*buf*/, int* /*pLoc*/, std::ostream& /*out*/)
1948{
1949 return -1;
1951
1952
1953////////////////////////////////////////////////////////////////////////////////
1954/// Terminate the application by call TSystem::Exit() unless application has
1955/// been told to return from Run(), by a call to SetReturnFromRun().
1956
1957void TApplication::Terminate(Int_t status)
1959 Emit("Terminate(Int_t)", status);
1960
1961 if (fReturnFromRun)
1962 gSystem->ExitLoop();
1963 else {
1964 gSystem->Exit(status);
1965 }
1966}
1967
1968////////////////////////////////////////////////////////////////////////////////
1969/// Emit signal when a line has been processed.
1970
1971void TApplication::LineProcessed(const char *line)
1972{
1973 Emit("LineProcessed(const char*)", line);
1974}
1975
1976////////////////////////////////////////////////////////////////////////////////
1977/// Emit signal when console keyboard key was pressed.
1978
1980{
1981 Emit("KeyPressed(Int_t)", key);
1982}
1983
1984////////////////////////////////////////////////////////////////////////////////
1985/// Emit signal when return key was pressed.
1986
1988{
1989 Emit("ReturnPressed(char*)", text);
1990}
1991
1992////////////////////////////////////////////////////////////////////////////////
1993/// Set console echo mode:
1994///
1995/// - mode = kTRUE - echo input symbols
1996/// - mode = kFALSE - noecho input symbols
1997
1999{
2001
2002////////////////////////////////////////////////////////////////////////////////
2003/// Static function used to create a default application environment.
2004
2006{
2008 // gApplication is set at the end of 'new TApplication.
2009 if (!gApplication) {
2010 char *a = StrDup("RootApp");
2011 char *b = StrDup("-b");
2012 char *argv[2];
2013 Int_t argc = 2;
2014 argv[0] = a;
2015 argv[1] = b;
2016 new TApplication("RootApp", &argc, argv, nullptr, 0);
2017 if (gDebug > 0)
2018 Printf("<TApplication::CreateApplication>: "
2019 "created default TApplication");
2020 delete [] a; delete [] b;
2022 }
2023}
2024
2025////////////////////////////////////////////////////////////////////////////////
2026/// Static function used to attach to an existing remote application
2027/// or to start one.
2028
2030 Int_t debug, const char *script)
2031{
2032 TApplication *ap = nullptr;
2033 TUrl nu(url);
2034 Int_t nnew = 0;
2035
2036 // Look among the existing ones
2037 if (fgApplications) {
2039 while ((ap = (TApplication *) nxa())) {
2040 TString apn(ap->ApplicationName());
2041 if (apn == url) {
2042 // Found matching application
2043 return ap;
2044 } else {
2045 // Check if same machine and user
2046 TUrl au(apn);
2047 if (strlen(au.GetUser()) > 0 && strlen(nu.GetUser()) > 0 &&
2048 !strcmp(au.GetUser(), nu.GetUser())) {
2049 if (!strncmp(au.GetHost(), nu.GetHost(), strlen(nu.GetHost())))
2050 // New session on a known machine
2051 nnew++;
2052 }
2053 }
2054 }
2055 } else {
2056 ::Error("TApplication::Open", "list of applications undefined - protocol error");
2057 return ap;
2058 }
2059
2060 // If new session on a known machine pass the number as option
2061 if (nnew > 0) {
2062 nnew++;
2063 nu.SetOptions(TString::Format("%d", nnew).Data());
2064 }
2065
2066 // Instantiate the TApplication object to be run
2067 TPluginHandler *h = nullptr;
2068 if ((h = gROOT->GetPluginManager()->FindHandler("TApplication","remote"))) {
2069 if (h->LoadPlugin() == 0) {
2070 ap = (TApplication *) h->ExecPlugin(3, nu.GetUrl(), debug, script);
2071 } else {
2072 ::Error("TApplication::Open", "failed to load plugin for TApplicationRemote");
2073 }
2074 } else {
2075 ::Error("TApplication::Open", "failed to find plugin for TApplicationRemote");
2076 }
2077
2078 // Add to the list
2079 if (ap && !(ap->TestBit(kInvalidObject))) {
2080 fgApplications->Add(ap);
2081 gROOT->GetListOfBrowsables()->Add(ap, ap->ApplicationName());
2082 TIter next(gROOT->GetListOfBrowsers());
2083 TBrowser *b;
2084 while ((b = (TBrowser*) next()))
2085 b->Add(ap, ap->ApplicationName());
2086 gROOT->RefreshBrowsers();
2087 } else {
2089 ::Error("TApplication::Open",
2090 "TApplicationRemote for %s could not be instantiated", url);
2091 }
2092
2093 // Done
2094 return ap;
2095}
2096
2097////////////////////////////////////////////////////////////////////////////////
2098/// Static function used to close a remote application
2099
2101{
2102 if (app) {
2103 app->Terminate(0);
2105 gROOT->GetListOfBrowsables()->RecursiveRemove(app);
2106 TIter next(gROOT->GetListOfBrowsers());
2107 TBrowser *b;
2108 while ((b = (TBrowser*) next()))
2110 gROOT->RefreshBrowsers();
2111 }
2112}
2113
2114////////////////////////////////////////////////////////////////////////////////
2115/// Show available sessions
2116
2117void TApplication::ls(Option_t *opt) const
2118{
2119 if (fgApplications) {
2121 TApplication *a = nullptr;
2122 while ((a = (TApplication *) nxa())) {
2123 a->Print(opt);
2124 }
2125 } else {
2126 Print(opt);
2127 }
2128}
2129
2130////////////////////////////////////////////////////////////////////////////////
2131/// Static method returning the list of available applications
2132
2134{
2135 return fgApplications;
2136}
#define SafeDelete(p)
Definition RConfig.hxx:541
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:75
int Ssiz_t
Definition RtypesCore.h:67
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
static void CallEndOfProcessCleanups()
#define FOOTNOTE
TApplication * gApplication
R__EXTERN TApplication * gApplication
R__EXTERN TClassTable * gClassTable
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kIsInlined
@ kIsConstexpr
Definition TDictionary.h:93
@ kIsStruct
Definition TDictionary.h:66
@ kIsVirtual
Definition TDictionary.h:72
@ kIsNamespace
Definition TDictionary.h:95
#define gDirectory
Definition TDirectory.h:384
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
R__EXTERN ExceptionContext_t * gException
Definition TException.h:69
R__EXTERN void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set.
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 filename
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 GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
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
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition TGuiFactory.h:67
R__EXTERN TGuiFactory * gGuiFactory
Definition TGuiFactory.h:66
R__EXTERN TVirtualMutex * gInterpreterMutex
#define gInterpreter
@ kInvalidObject
Definition TObject.h:374
Int_t gDebug
Definition TROOT.cxx:597
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:406
char * Compress(const char *str)
Remove all blanks from the string str.
Definition TString.cxx:2572
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition TString.cxx:2521
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2503
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
R__EXTERN TStyle * gStyle
Definition TStyle.h:436
@ kReadPermission
Definition TSystem.h:45
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
#define R__LOCKGUARD(mutex)
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
R__EXTERN TVirtualX * gGXBatch
Definition TVirtualX.h:339
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 void SetEchoMode(Bool_t mode)
Set console echo mode:
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
static Longptr_t ExecuteFile(const char *file, Int_t *error=nullptr, Bool_t keep=kFALSE)
Execute a file containing a C++ macro (static method).
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 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.
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.
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...
void OpenInBrowser(const TString &url)
The function generates and executes a command that loads the Doxygen URL in a browser.
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
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).
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.
static TList * GetApplications()
Static method returning the list of available applications.
std::atomic< bool > fIsRunning
Window system specific application implementation.
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
void ls(Option_t *option="") const override
Show available sessions.
TString GetSetup()
It gets the ROOT installation setup as TString.
virtual void HandleIdleTimer()
Handle idle timeout.
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
char ** fArgv
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
void RecursiveRemove(TObject *obj) override
Recursively remove obj from browser.
Definition TBrowser.cxx:408
void Add(TObject *obj, const char *name=nullptr, Int_t check=-1)
Add object with name to browser.
Definition TBrowser.cxx:303
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
TList * GetListOfAllPublicDataMembers(Bool_t load=kTRUE)
Returns a list of all public data members of this class and its base classes.
Definition TClass.cxx:3959
TList * GetListOfEnums(Bool_t load=kTRUE)
Return a list containing the TEnums of a class.
Definition TClass.cxx:3783
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
Definition TClass.cxx:6195
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
Definition TClass.cxx:4481
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:3069
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition TColor.cxx:1171
All ROOT classes may have RTTI (run time type identification) support added.
Definition TDataMember.h:31
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
Global functions class (global functions are obtained from CINT).
Definition TFunction.h:30
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
const char * GetSignature()
Return signature of function.
Long_t ExtraProperty() const
Get property description word. For meaning of bits see EProperty.
const char * GetReturnTypeName() const
Get full type description of function return type, e,g.: "class TDirectory*".
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.
TIdleTimer(Long_t ms)
Bool_t Notify() override
Notify handler.
void ls(Option_t *option="") const override
List this line with its attributes.
Definition TLine.cxx:380
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:576
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
An array of TObjects.
Definition TObjArray.h:31
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
void Add(TObject *obj) override
Definition TObjArray.h:68
Collectable string class.
Definition TObjString.h:28
TString & String()
Definition TObjString.h:48
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:456
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:991
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:798
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1005
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1033
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition TObject.cxx:654
void ResetBit(UInt_t f)
Definition TObject.h:198
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition TObject.h:72
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:2762
static void ShutDown()
Shut down ROOT.
Definition TROOT.cxx:3140
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition TROOT.cxx:3193
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition TROOT.cxx:2910
static const TString & GetTutorialDir()
Get the tutorials directory in the installation. Static utility function.
Definition TROOT.cxx:3119
static const TString & GetDocDir()
Get the documentation directory in the installation. Static utility function.
Definition TROOT.cxx:3082
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2244
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1163
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition TString.h:694
const char * Data() const
Definition TString.h:376
TString & Chop()
Definition TString.h:691
@ kBoth
Definition TString.h:276
Bool_t IsNull() const
Definition TString.h:414
TString & Append(const char *cs)
Definition TString.h:572
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
void SetScreenFactor(Float_t factor=1)
Definition TStyle.h:317
virtual void NotifyApplicationCreated()
Hook to tell TSystem that the TApplication object has been created.
Definition TSystem.cxx:311
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1274
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1665
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Definition TSystem.cxx:4258
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:653
virtual void ListLibraries(const char *regexp="")
List the loaded shared libraries.
Definition TSystem.cxx:2085
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:1398
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:1296
virtual void Run()
System event loop.
Definition TSystem.cxx:343
virtual void ExitLoop()
Exit from event loop.
Definition TSystem.cxx:392
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:862
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:471
virtual const char * GetBuildCompilerVersionStr() const
Return the build compiler version identifier string.
Definition TSystem.cxx:3899
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
Definition TSystem.cxx:716
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:871
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1548
virtual void SetProgname(const char *name)
Set the application name (from command line, argv[0]) and copy it in gProgName.
Definition TSystem.cxx:226
virtual const char * GetBuildArch() const
Return the build architecture.
Definition TSystem.cxx:3875
virtual void Abort(int code=0)
Abort the application.
Definition TSystem.cxx:725
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition TSystem.cxx:481
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:159
This class represents a WWW compatible URL.
Definition TUrl.h:33
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition TVirtualX.h:46
TLine * line
std::ostream & Info()
Definition hadd.cxx:163
static constexpr const char kCommandLineOptionsHelp[]
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:539
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...
Definition TROOT.cxx:501
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.