ROOT  6.06/08
Reference Guide
TROOT.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Rene Brun 08/12/94
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 TROOT
13 ROOT top level object description.
14 
15  The TROOT object is the entry point to the ROOT system.
16  The single instance of TROOT is accessible via the global gROOT.
17  Using the gROOT pointer one has access to basically every object
18  created in a ROOT based program. The TROOT object is essentially a
19  container of several lists pointing to the main ROOT objects.
20 
21  The following lists are accessible from gROOT object:
22 
23 ~~~ {.cpp}
24  gROOT->GetListOfClasses
25  gROOT->GetListOfColors
26  gROOT->GetListOfTypes
27  gROOT->GetListOfGlobals
28  gROOT->GetListOfGlobalFunctions
29  gROOT->GetListOfFiles
30  gROOT->GetListOfMappedFiles
31  gROOT->GetListOfSockets
32  gROOT->GetListOfSecContexts
33  gROOT->GetListOfCanvases
34  gROOT->GetListOfStyles
35  gROOT->GetListOfFunctions
36  gROOT->GetListOfSpecials (for example graphical cuts)
37  gROOT->GetListOfGeometries
38  gROOT->GetListOfBrowsers
39  gROOT->GetListOfCleanups
40  gROOT->GetListOfMessageHandlers
41 ~~~
42 
43  The TROOT class provides also many useful services:
44  - Get pointer to an object in any of the lists above
45  - Time utilities TROOT::Time
46 
47  The ROOT object must be created as a static object. An example
48  of a main program creating an interactive version is shown below:
49 
50 ### Example of a main program
51 
52 ~~~ {.cpp}
53  #include "TRint.h"
54 
55  int main(int argc, char **argv)
56  {
57  TRint *theApp = new TRint("ROOT example", &argc, argv);
58 
59  // Init Intrinsics, build all windows, and enter event loop
60  theApp->Run();
61 
62  return(0);
63  }
64 ~~~
65 */
66 
67 #include "RConfig.h"
68 #include "RConfigure.h"
69 #include "RConfigOptions.h"
70 #include "RVersion.h"
71 #include "RGitCommit.h"
72 
73 #include <string>
74 #include <map>
75 #include <stdlib.h>
76 #ifdef WIN32
77 #include <io.h>
78 #include "Windows4Root.h"
79 #include <Psapi.h>
80 #define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
81 #define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
82 #define dlopen(library_name, flags) ::LoadLibrary(library_name)
83 #define dlclose(library) ::FreeLibrary((HMODULE)library)
84 char *dlerror() {
85  static char Msg[1000];
86  FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
87  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), Msg,
88  sizeof(Msg), NULL);
89  return Msg;
90 }
91 #else
92 #include <dlfcn.h>
93 #endif
94 
95 #include "Riostream.h"
96 #include "Gtypes.h"
97 #include "TROOT.h"
98 #include "TClass.h"
99 #include "TClassEdit.h"
100 #include "TClassGenerator.h"
101 #include "TDataType.h"
102 #include "TDatime.h"
103 #include "TStyle.h"
104 #include "TObjectTable.h"
105 #include "TClassTable.h"
106 #include "TSystem.h"
107 #include "THashList.h"
108 #include "TObjArray.h"
109 #include "TEnv.h"
110 #include "TError.h"
111 #include "TColor.h"
112 #include "TGlobal.h"
113 #include "TFunction.h"
114 #include "TVirtualPad.h"
115 #include "TBrowser.h"
116 #include "TSystemDirectory.h"
117 #include "TApplication.h"
118 #include "TInterpreter.h"
119 #include "TGuiFactory.h"
120 #include "TMessageHandler.h"
121 #include "TFolder.h"
122 #include "TQObject.h"
123 #include "TProcessUUID.h"
124 #include "TPluginManager.h"
125 #include "TMap.h"
126 #include "TObjString.h"
127 #include "TVirtualMutex.h"
128 #include "TInterpreter.h"
129 #include "TListOfTypes.h"
130 #include "TListOfDataMembers.h"
131 #include "TListOfEnumsWithLock.h"
132 #include "TListOfFunctions.h"
134 #include "TFunctionTemplate.h"
135 #include "ThreadLocalStorage.h"
136 
137 #include <string>
138 namespace std {} using namespace std;
139 
140 #if defined(R__UNIX)
141 #if defined(R__HAS_COCOA)
142 #include "TMacOSXSystem.h"
143 #include "TUrl.h"
144 #else
145 #include "TUnixSystem.h"
146 #endif
147 #elif defined(R__WIN32)
148 #include "TWinNTSystem.h"
149 #endif
150 
151 extern "C" void R__SetZipMode(int);
152 
153 static DestroyInterpreter_t *gDestroyInterpreter = 0;
154 static void *gInterpreterLib = 0;
155 
156 // Mutex for protection of concurrent gROOT access
157 TVirtualMutex* gROOTMutex = 0;
158 
159 // For accessing TThread::Tsd indirectly.
160 void **(*gThreadTsd)(void*,Int_t) = 0;
161 
162 //-------- Names of next three routines are a small homage to CMZ --------------
163 ////////////////////////////////////////////////////////////////////////////////
164 /// Return version id as an integer, i.e. "2.22/04" -> 22204.
165 
166 static Int_t IVERSQ()
167 {
168  Int_t maj, min, cycle;
169  sscanf(ROOT_RELEASE, "%d.%d/%d", &maj, &min, &cycle);
170  return 10000*maj + 100*min + cycle;
171 }
172 
173 ////////////////////////////////////////////////////////////////////////////////
174 /// Return built date as integer, i.e. "Apr 28 2000" -> 20000428.
175 
176 static Int_t IDATQQ(const char *date)
177 {
178  static const char *months[] = {"Jan","Feb","Mar","Apr","May",
179  "Jun","Jul","Aug","Sep","Oct",
180  "Nov","Dec"};
181 
182  char sm[12];
183  Int_t yy, mm=0, dd;
184  sscanf(date, "%s %d %d", sm, &dd, &yy);
185  for (int i = 0; i < 12; i++)
186  if (!strncmp(sm, months[i], 3)) {
187  mm = i+1;
188  break;
189  }
190  return 10000*yy + 100*mm + dd;
191 }
192 
193 ////////////////////////////////////////////////////////////////////////////////
194 /// Return built time as integer (with min precision), i.e.
195 /// "17:32:37" -> 1732.
196 
197 static Int_t ITIMQQ(const char *time)
198 {
199  Int_t hh, mm, ss;
200  sscanf(time, "%d:%d:%d", &hh, &mm, &ss);
201  return 100*hh + mm;
202 }
203 
204 ////////////////////////////////////////////////////////////////////////////////
205 /// Clean up at program termination before global objects go out of scope.
206 
207 static void CleanUpROOTAtExit()
208 {
209  if (gROOT) {
210  R__LOCKGUARD(gROOTMutex);
211 
212  if (gROOT->GetListOfFiles())
213  gROOT->GetListOfFiles()->Delete("slow");
214  if (gROOT->GetListOfSockets())
215  gROOT->GetListOfSockets()->Delete();
216  if (gROOT->GetListOfMappedFiles())
217  gROOT->GetListOfMappedFiles()->Delete("slow");
218  if (gROOT->GetListOfClosedObjects())
219  gROOT->GetListOfClosedObjects()->Delete("slow");
220  }
221 }
222 
223 ////////////////////////////////////////////////////////////////////////////////
224 /// A module and its headers. Intentionally not a copy:
225 /// If these strings end up in this struct they are
226 /// long lived by definition because they get passed in
227 /// before initialization of TCling.
228 
229 namespace {
230  struct ModuleHeaderInfo_t {
231  ModuleHeaderInfo_t(const char* moduleName,
232  const char** headers,
233  const char** includePaths,
234  const char* payloadCode,
235  const char* fwdDeclCode,
236  void (*triggerFunc)(),
237  const TROOT::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
238  const char** classesHeaders):
239  fModuleName(moduleName),
240  fHeaders(headers),
241  fPayloadCode(payloadCode),
242  fFwdDeclCode(fwdDeclCode),
243  fIncludePaths(includePaths),
244  fTriggerFunc(triggerFunc),
245  fClassesHeaders(classesHeaders),
246  fFwdNargsToKeepColl(fwdDeclsArgToSkip){}
247 
248  const char* fModuleName; // module name
249  const char** fHeaders; // 0-terminated array of header files
250  const char* fPayloadCode; // Additional code to be given to cling at library load
251  const char* fFwdDeclCode; // Additional code to let cling know about selected classes and functions
252  const char** fIncludePaths; // 0-terminated array of header files
253  void (*fTriggerFunc)(); // Pointer to the dict initialization used to find the library name
254  const char** fClassesHeaders; // 0-terminated list of classes and related header files
255  const TROOT::FwdDeclArgsToKeepCollection_t fFwdNargsToKeepColl; // Collection of
256  // pairs of template fwd decls and number of
257  };
258 
259  std::vector<ModuleHeaderInfo_t>& GetModuleHeaderInfoBuffer() {
260  static std::vector<ModuleHeaderInfo_t> moduleHeaderInfoBuffer;
261  return moduleHeaderInfoBuffer;
262  }
263 }
264 
265 Int_t TROOT::fgDirLevel = 0;
266 Bool_t TROOT::fgRootInit = kFALSE;
267 Bool_t TROOT::fgMemCheck = kFALSE;
268 
269 static void at_exit_of_TROOT() {
270  if (ROOT::Internal::gROOTLocal)
271  ROOT::Internal::gROOTLocal->~TROOT();
272 }
273 
274 // This local static object initializes the ROOT system
275 namespace ROOT {
276 namespace Internal {
277  class TROOTAllocator {
278  // Simple wrapper to separate, time-wise, the call to the
279  // TROOT destructor and the actual free-ing of the memory.
280  //
281  // Since the interpreter implementation (currently TCling) is
282  // loaded via dlopen by libCore, the destruction of its global
283  // variable (i.e. in particular clang's) is scheduled before
284  // those in libCore so we need to schedule the call to the TROOT
285  // destructor before that *but* we want to make sure the memory
286  // stay around until libCore itself is unloaded so that code
287  // using gROOT can 'properly' check for validity.
288  //
289  // The order of loading for is:
290  // libCore.so
291  // libRint.so
292  // ... anything other library hard linked to the executable ...
293  // ... for example libEvent
294  // libCling.so
295  // ... other libraries like libTree for example ....
296  // and the destruction order is (of course) the reverse.
297  // By default the unloading of the dictionary, does use
298  // the service of the interpreter ... which of course
299  // fails if libCling is already unloaded by that information
300  // has not been registered per se.
301  //
302  // To solve this problem, we now schedule the destruction
303  // of the TROOT object to happen _just_ before the
304  // unloading/destruction of libCling so that we can
305  // maximize the amount of clean-up we can do correctly
306  // and we can still allocate the TROOT object's memory
307  // statically.
308  //
309  char fHolder[sizeof(TROOT)];
310  public:
311  TROOTAllocator() {
312  new(&(fHolder[0])) TROOT("root", "The ROOT of EVERYTHING");
313  }
314 
315  ~TROOTAllocator() {
316  if (gROOTLocal) {
317  gROOTLocal->~TROOT();
318  }
319  }
320  };
321 
322  // The global gROOT is defined to be a function (ROOT::GetROOT())
323  // which itself is dereferencing a function pointer.
324 
325  // Initially this function pointer's value is & GetROOT1 whose role is to
326  // create and initialize the TROOT object itself.
327  // At the very end of the TROOT constructor the value of the function pointer
328  // is switch to & GetROOT2 whose role is to initialize the interpreter.
329 
330  // This mechanism was primarily intended to fix the issues with order in which
331  // global TROOT and LLVM globals are initialized. TROOT was initializing
332  // Cling, but Cling could not be used yet due to LLVM globals not being
333  // initialized yet. The solution is to delay initializing the interpreter in
334  // TROOT till after main() when all LLVM globals are initialized.
335 
336  // Technically, the mechanism used actually delay the interpreter
337  // initialization until the first use of gROOT *after* the end of the
338  // TROOT constructor.
339 
340  // So to delay until after the start of main, we also made sure that none
341  // of the ROOT code (mostly the dictionary code) used during library loading
342  // is using gROOT (directly or indirectly).
343 
344  // In practice, the initialization of the interpreter is now delayed until
345  // the first use gROOT (or gInterpreter) after the start of main (but user
346  // could easily break this by using gROOT in their library initialization
347  // code).
348 
349  extern TROOT *gROOTLocal;
350 
352  if (gROOTLocal)
353  return gROOTLocal;
354  static TROOTAllocator alloc;
355  return gROOTLocal;
356  }
357 
359  static Bool_t initInterpreter = kFALSE;
360  if (!initInterpreter) {
361  initInterpreter = kTRUE;
362  gROOTLocal->InitInterpreter();
363  // Load and init threads library
364  gROOTLocal->InitThreads();
365  }
366  return gROOTLocal;
367  }
368  typedef TROOT *(*GetROOTFun_t)();
369 
371 
372 } // end of Internal sub namespace
373 // back to ROOT namespace
374 
376  return (*Internal::gGetROOT)();
377  }
378 
380  static TString macroPath;
381  return macroPath;
382  }
383 
384  ////////////////////////////////////////////////////////////////////////////////
385  /// Enables the global mutex to make ROOT thread safe/aware.
387  {
388  static void (*tthreadInitialize)() = nullptr;
389 
390  if (!tthreadInitialize) {
391  const static auto loadSuccess = -1 != gSystem->Load("libThread");
392  if (loadSuccess) {
393  if (auto sym = dlsym(RTLD_DEFAULT,"ROOT_TThread_Initialize")) {
394  tthreadInitialize = (void(*)()) sym;
395  tthreadInitialize();
396  } else {
397  Error("EnableThreadSafety","Cannot initialize multithreading support.");
398  }
399  } else {
400  Error("EnableThreadSafety","Cannot load Thread library.");
401  }
402  }
403  }
404 
405 }
406 
407 TROOT *ROOT::Internal::gROOTLocal = ROOT::GetROOT();
408 
409 // Global debug flag (set to > 0 to get debug output).
410 // Can be set either via the interpreter (gDebug is exported to CINT),
411 // via the rootrc resource "Root.Debug", via the shell environment variable
412 // ROOTDEBUG, or via the debugger.
414 
415 
417 
418 ////////////////////////////////////////////////////////////////////////////////
419 /// Default ctor.
420 
422  fLineIsProcessing(0), fVersion(0), fVersionInt(0), fVersionCode(0),
423  fVersionDate(0), fVersionTime(0), fBuiltDate(0), fBuiltTime(0),
424  fTimer(0), fApplication(0), fInterpreter(0), fBatch(kTRUE), fEditHistograms(kTRUE),
425  fFromPopUp(kTRUE),fMustClean(kTRUE),fReadingObject(kFALSE),fForceStyle(kFALSE),
426  fInterrupt(kFALSE),fEscape(kFALSE),fExecutingMacro(kFALSE),fEditorMode(0),
427  fPrimitive(0),fSelectPad(0),fClasses(0),fTypes(0),fGlobals(0),fGlobalFunctions(0),
428  fClosedObjects(0),fFiles(0),fMappedFiles(0),fSockets(0),fCanvases(0),fStyles(0),fFunctions(0),
429  fTasks(0),fColors(0),fGeometries(0),fBrowsers(0),fSpecials(0),fCleanups(0),
430  fMessageHandlers(0),fStreamerInfo(0),fClassGenerators(0),fSecContexts(0),
431  fProofs(0),fClipboard(0),fDataSets(0),fUUIDs(0),fRootFolder(0),fBrowsables(0),
432  fPluginManager(0)
433 {
434 }
435 
436 ////////////////////////////////////////////////////////////////////////////////
437 /// Initialize the ROOT system. The creation of the TROOT object initializes
438 /// the ROOT system. It must be the first ROOT related action that is
439 /// performed by a program. The TROOT object must be created on the stack
440 /// (can not be called via new since "operator new" is protected). The
441 /// TROOT object is either created as a global object (outside the main()
442 /// program), or it is one of the first objects created in main().
443 /// Make sure that the TROOT object stays in scope for as long as ROOT
444 /// related actions are performed. TROOT is a so called singleton so
445 /// only one instance of it can be created. The single TROOT object can
446 /// always be accessed via the global pointer gROOT.
447 /// The name and title arguments can be used to identify the running
448 /// application. The initfunc argument can contain an array of
449 /// function pointers (last element must be 0). These functions are
450 /// executed at the end of the constructor. This way one can easily
451 /// extend the ROOT system without adding permanent dependencies
452 /// (e.g. the graphics system is initialized via such a function).
453 
454 TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc)
455  : TDirectory(), fLineIsProcessing(0), fVersion(0), fVersionInt(0), fVersionCode(0),
456  fVersionDate(0), fVersionTime(0), fBuiltDate(0), fBuiltTime(0),
457  fTimer(0), fApplication(0), fInterpreter(0), fBatch(kTRUE), fEditHistograms(kTRUE),
458  fFromPopUp(kTRUE),fMustClean(kTRUE),fReadingObject(kFALSE),fForceStyle(kFALSE),
459  fInterrupt(kFALSE),fEscape(kFALSE),fExecutingMacro(kFALSE),fEditorMode(0),
460  fPrimitive(0),fSelectPad(0),fClasses(0),fTypes(0),fGlobals(0),fGlobalFunctions(0),
461  fClosedObjects(0),fFiles(0),fMappedFiles(0),fSockets(0),fCanvases(0),fStyles(0),fFunctions(0),
462  fTasks(0),fColors(0),fGeometries(0),fBrowsers(0),fSpecials(0),fCleanups(0),
463  fMessageHandlers(0),fStreamerInfo(0),fClassGenerators(0),fSecContexts(0),
464  fProofs(0),fClipboard(0),fDataSets(0),fUUIDs(0),fRootFolder(0),fBrowsables(0),
465  fPluginManager(0)
466 {
467  if (fgRootInit || ROOT::Internal::gROOTLocal) {
468  //Warning("TROOT", "only one instance of TROOT allowed");
469  return;
470  }
471 
472  R__LOCKGUARD2(gROOTMutex);
473 
474  ROOT::Internal::gROOTLocal = this;
475  gDirectory = 0;
476 
477  // initialize gClassTable is not already done
478  if (!gClassTable) new TClassTable;
479 
480  SetName(name);
481  SetTitle(title);
482 
483  // will be used by global "operator delete" so make sure it is set
484  // before anything is deleted
485  fMappedFiles = 0;
486 
487  // create already here, but only initialize it after gEnv has been created
489 
490  // Initialize Operating System interface
491  InitSystem();
492 
493  // Initialize static directory functions
494  GetRootSys();
495  GetBinDir();
496  GetLibDir();
497  GetIncludeDir();
498  GetEtcDir();
499  GetDataDir();
500  GetDocDir();
501  GetMacroDir();
502  GetTutorialsDir();
503  GetSourceDir();
504  GetIconPath();
505  GetTTFFontDir();
506 
507  gRootDir = GetRootSys().Data();
508 
510 
511  // Initialize interface to CINT C++ interpreter
512  fVersionInt = 0; // check in TROOT dtor in case TCling fails
513  fClasses = 0; // might be checked via TCling ctor
514  fEnums = 0;
515 
516  fConfigOptions = R__CONFIGUREOPTIONS;
517  fConfigFeatures = R__CONFIGUREFEATURES;
520  fVersionInt = IVERSQ();
523  fBuiltDate = IDATQQ(__DATE__);
524  fBuiltTime = ITIMQQ(__TIME__);
525 
526  ReadGitInfo();
527 
528  fClasses = new THashTable(800,3);
529  //fIdMap = new IdMap_t;
530  fStreamerInfo = new TObjArray(100);
531  fClassGenerators = new TList;
532 
533  // usedToIdentifyRootClingByDlSym is available when TROOT is part of
534  // rootcling.
535  if (!dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")) {
536  // initialize plugin manager early
538 #if defined(R__MACOSX) && (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
539  if (TARGET_OS_IPHONE | TARGET_IPHONE_SIMULATOR) {
540  TEnv plugins(".plugins-ios");
542  }
543 #endif
544  }
545 
546  TSystemDirectory *workdir = new TSystemDirectory("workdir", gSystem->WorkingDirectory());
547 
548  fTimer = 0;
549  fApplication = 0;
550  fColors = new TObjArray(1000); fColors->SetName("ListOfColors");
551  fTypes = 0;
552  fGlobals = 0;
553  fGlobalFunctions = 0;
554  // fList was created in TDirectory::Build but with different sizing.
555  delete fList;
556  fList = new THashList(1000,3);
557  fClosedObjects = new TList; fClosedObjects->SetName("ClosedFiles");
558  fFiles = new TList; fFiles->SetName("Files");
559  fMappedFiles = new TList; fMappedFiles->SetName("MappedFiles");
560  fSockets = new TList; fSockets->SetName("Sockets");
561  fCanvases = new TList; fCanvases->SetName("Canvases");
562  fStyles = new TList; fStyles->SetName("Styles");
563  fFunctions = new TList; fFunctions->SetName("Functions");
564  fTasks = new TList; fTasks->SetName("Tasks");
565  fGeometries = new TList; fGeometries->SetName("Geometries");
566  fBrowsers = new TList; fBrowsers->SetName("Browsers");
567  fSpecials = new TList; fSpecials->SetName("Specials");
568  fBrowsables = new TList; fBrowsables->SetName("Browsables");
569  fCleanups = new THashList; fCleanups->SetName("Cleanups");
570  fMessageHandlers = new TList; fMessageHandlers->SetName("MessageHandlers");
571  fSecContexts = new TList; fSecContexts->SetName("SecContexts");
572  fProofs = new TList; fProofs->SetName("Proofs");
573  fClipboard = new TList; fClipboard->SetName("Clipboard");
574  fDataSets = new TList; fDataSets->SetName("DataSets");
575  fTypes = new TListOfTypes;
576 
578  fUUIDs = new TProcessUUID();
579 
580  fRootFolder = new TFolder();
581  fRootFolder->SetName("root");
582  fRootFolder->SetTitle("root of all folders");
583  fRootFolder->AddFolder("Classes", "List of Active Classes",fClasses);
584  fRootFolder->AddFolder("Colors", "List of Active Colors",fColors);
585  fRootFolder->AddFolder("MapFiles", "List of MapFiles",fMappedFiles);
586  fRootFolder->AddFolder("Sockets", "List of Socket Connections",fSockets);
587  fRootFolder->AddFolder("Canvases", "List of Canvases",fCanvases);
588  fRootFolder->AddFolder("Styles", "List of Styles",fStyles);
589  fRootFolder->AddFolder("Functions", "List of Functions",fFunctions);
590  fRootFolder->AddFolder("Tasks", "List of Tasks",fTasks);
591  fRootFolder->AddFolder("Geometries","List of Geometries",fGeometries);
592  fRootFolder->AddFolder("Browsers", "List of Browsers",fBrowsers);
593  fRootFolder->AddFolder("Specials", "List of Special Objects",fSpecials);
594  fRootFolder->AddFolder("Handlers", "List of Message Handlers",fMessageHandlers);
595  fRootFolder->AddFolder("Cleanups", "List of RecursiveRemove Collections",fCleanups);
596  fRootFolder->AddFolder("StreamerInfo","List of Active StreamerInfo Classes",fStreamerInfo);
597  fRootFolder->AddFolder("SecContexts","List of Security Contexts",fSecContexts);
598  fRootFolder->AddFolder("PROOF Sessions", "List of PROOF sessions",fProofs);
599  fRootFolder->AddFolder("ROOT Memory","List of Objects in the gROOT Directory",fList);
600  fRootFolder->AddFolder("ROOT Files","List of Connected ROOT Files",fFiles);
601 
602  // by default, add the list of files, tasks, canvases and browsers in the Cleanups list
608 
611  fFromPopUp = kFALSE;
613  fInterrupt = kFALSE;
614  fEscape = kFALSE;
615  fMustClean = kTRUE;
616  fPrimitive = 0;
617  fSelectPad = 0;
618  fEditorMode = 0;
619  fDefCanvasName = "c1";
621  fLineIsProcessing = 1; // This prevents WIN32 "Windows" thread to pick ROOT objects with mouse
622  gDirectory = this;
623  gPad = 0;
624 
625  //set name of graphical cut class for the graphics editor
626  //cannot call SetCutClassName at this point because the TClass of TCutG
627  //is not yet build
628  fCutClassName = "TCutG";
629 
630  // Create a default MessageHandler
631  new TMessageHandler((TClass*)0);
632 
633  // Create some styles
634  gStyle = 0;
636  SetStyle(gEnv->GetValue("Canvas.Style", "Modern"));
637 
638  // Setup default (batch) graphics and GUI environment
641  gGXBatch = new TVirtualX("Batch", "ROOT Interface to batch graphics");
643 
644 #if defined(R__WIN32)
645  fBatch = kFALSE;
646 #elif defined(R__HAS_COCOA)
647  fBatch = kFALSE;
648 #else
649  if (gSystem->Getenv("DISPLAY"))
650  fBatch = kFALSE;
651  else
652  fBatch = kTRUE;
653 #endif
654 
655  int i = 0;
656  while (initfunc && initfunc[i]) {
657  (initfunc[i])();
658  fBatch = kFALSE; // put system in graphics mode (backward compatible)
659  i++;
660  }
661 
662  // Set initial/default list of browsable objects
663  fBrowsables->Add(fRootFolder, "root");
664  fBrowsables->Add(fProofs, "PROOF Sessions");
665  fBrowsables->Add(workdir, gSystem->WorkingDirectory());
666  fBrowsables->Add(fFiles, "ROOT Files");
667 
668  atexit(CleanUpROOTAtExit);
669 
671 }
672 
673 ////////////////////////////////////////////////////////////////////////////////
674 /// Clean up and free resources used by ROOT (files, network sockets,
675 /// shared memory segments, etc.).
676 
678 {
679  using namespace ROOT::Internal;
680 
681  if (gROOTLocal == this) {
682 
683  // If the interpreter has not yet been initialized, don't bother
684  gGetROOT = &GetROOT1;
685 
686  // Mark the object as invalid, so that we can veto some actions
687  // (like autoloading) while we are in the destructor.
689 
690  // Turn-off the global mutex to avoid recreating mutexes that have
691  // already been deleted during the destruction phase
692  gGlobalMutex = 0;
693 
694  // Return when error occurred in TCling, i.e. when setup file(s) are
695  // out of date
696  if (!fVersionInt) return;
697 
698  // ATTENTION!!! Order is important!
699 
700 #ifdef R__COMPLETE_MEM_TERMINATION
703  fSpecials->Delete(); SafeDelete(fSpecials); // delete special objects : PostScript, Minuit, Html
704 #endif
705  fClosedObjects->Delete("slow"); // and closed files
706  fFiles->Delete("slow"); // and files
708  fSecContexts->Delete("slow"); SafeDelete(fSecContexts); // and security contexts
709  fSockets->Delete(); SafeDelete(fSockets); // and sockets
710  fMappedFiles->Delete("slow"); // and mapped files
711  delete fUUIDs;
712  TProcessID::Cleanup(); // and list of ProcessIDs
713  TSeqCollection *tl = fMappedFiles; fMappedFiles = 0; delete tl;
714 
716 
717  fFunctions->Delete(); SafeDelete(fFunctions); // etc..
720 #ifdef R__COMPLETE_MEM_TERMINATION
722 #endif
725 
726 #ifdef R__COMPLETE_MEM_TERMINATION
731 #endif
732 
733  // Stop emitting signals
735 
737 
738 #ifdef R__COMPLETE_MEM_TERMINATION
744 
745  fCleanups->Clear();
747  delete gClassTable; gClassTable = 0;
748  delete gEnv; gEnv = 0;
749 
750  if (fTypes) fTypes->Delete();
752  if (fGlobals) fGlobals->Delete();
756  fEnums->Delete();
757  fClasses->Delete(); SafeDelete(fClasses); // TClass'es must be deleted last
758 #endif
759 
760  // Remove shared libraries produced by the TSystem::CompileMacro() call
762 
763  // Cleanup system class
764  delete gSystem;
765 
766  // ROOT-6022:
767  // if (gInterpreterLib) dlclose(gInterpreterLib);
768 #ifdef R__COMPLETE_MEM_TERMINATION
769  // On some 'newer' platform (Fedora Core 17+, Ubuntu 12), the
770  // initialization order is (by default?) is 'wrong' and so we can't
771  // delete the interpreter now .. because any of the static in the
772  // interpreter's library have already been deleted.
773  // On the link line, we must list the most dependent .o file
774  // and end with the least dependent (LLVM libraries), unfortunately,
775  // Fedora Core 17+ or Ubuntu 12 will also execute the initialization
776  // in the same order (hence doing libCore's before LLVM's and
777  // vice et versa for both the destructor. We worked around the
778  // initialization order by delay the TROOT creation until first use.
779  // We can not do the same for destruction as we have no way of knowing
780  // the last access ...
781  // So for now, let's avoid delete TCling except in the special build
782  // checking the completeness of the termination deletion.
783  gDestroyCling(fInterpreter);
784 #endif
785 
786 #ifdef R__COMPLETE_MEM_TERMINATION
788 #endif
789 
790  // Prints memory stats
792 
793  gROOTLocal = 0;
794  fgRootInit = kFALSE;
795  }
796 }
797 
798 ////////////////////////////////////////////////////////////////////////////////
799 /// Add a class to the list and map of classes.
800 /// This routine is deprecated, use TClass::AddClass directly.
801 
803 {
804  TClass::AddClass(cl);
805 }
806 
807 ////////////////////////////////////////////////////////////////////////////////
808 /// Add a class generator. This generator will be called by TClass::GetClass
809 /// in case its does not find a loaded rootcint dictionary to request the
810 /// creation of a TClass object.
811 
813 {
814  if (!generator) return;
815  fClassGenerators->Add(generator);
816 }
817 
818 ////////////////////////////////////////////////////////////////////////////////
819 /// Add browsable objects to TBrowser.
820 
822 {
823  TObject *obj;
824  TIter next(fBrowsables);
825 
826  while ((obj = (TObject *) next())) {
827  const char *opt = next.GetOption();
828  if (opt && strlen(opt))
829  b->Add(obj, opt);
830  else
831  b->Add(obj, obj->GetName());
832  }
833 }
834 
835 ////////////////////////////////////////////////////////////////////////////////
836 /// return class status bit kClassSaved for class cl
837 /// This function is called by the SavePrimitive functions writing
838 /// the C++ code for an object.
839 
841 {
842  if (cl == 0) return kFALSE;
843  if (cl->TestBit(TClass::kClassSaved)) return kTRUE;
845  return kFALSE;
846 }
847 
848 namespace {
849  static void R__ListSlowClose(TList *files)
850  {
851  // Routine to close a list of files using the 'slow' techniques
852  // that also for the deletion ot update the list itself.
853 
854  static TObject harmless;
855  TObjLink *cursor = files->FirstLink();
856  while (cursor) {
857  TDirectory *dir = static_cast<TDirectory*>( cursor->GetObject() );
858  if (dir) {
859  // In order for the iterator to stay valid, we must
860  // prevent the removal of the object (dir) from the list
861  // (which is done in TFile::Close). We can also can not
862  // just move to the next iterator since the Close might
863  // also (indirectly) remove that file.
864  // So we SetObject to a harmless value, so that 'dir'
865  // is not seen as part of the list.
866  // We will later, remove all the object (see files->Clear()
867  cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
868  dir->Close();
869  // Put it back
870  cursor->SetObject(dir);
871  }
872  cursor = cursor->Next();
873  };
874  // Now were done, clear the list but do not delete the objects as
875  // they have been moved to the list of closed objects and must be
876  // deleted from there in order to avoid a double delete from a
877  // use objects (on the interpreter stack).
878  files->Clear("nodelete");
879  }
880 }
881 
882 ////////////////////////////////////////////////////////////////////////////////
883 /// Close any files and sockets that gROOT knows about.
884 /// This can be used to insures that the files and sockets are closed before any library is unloaded!
885 
887 {
888  if (fFiles && fFiles->First()) {
889  R__ListSlowClose(static_cast<TList*>(fFiles));
890  }
891  // and Close TROOT itself.
892  Close();
893  // Now sockets.
894  if (fSockets && fSockets->First()) {
895  if (0==fCleanups->FindObject(fSockets) ) {
898  }
899  CallFunc_t *socketCloser = gInterpreter->CallFunc_Factory();
900  Long_t offset = 0;
901  TClass *socketClass = TClass::GetClass("TSocket");
902  gInterpreter->CallFunc_SetFuncProto(socketCloser, socketClass->GetClassInfo(), "Close", "", &offset);
903  if (gInterpreter->CallFunc_IsValid(socketCloser)) {
904  static TObject harmless;
905  TObjLink *cursor = static_cast<TList*>(fSockets)->FirstLink();
906  TList notclosed;
907  while (cursor) {
908  TObject *socket = cursor->GetObject();
909  // In order for the iterator to stay valid, we must
910  // prevent the removal of the object (dir) from the list
911  // (which is done in TFile::Close). We can also can not
912  // just move to the next iterator since the Close might
913  // also (indirectly) remove that file.
914  // So we SetObject to a harmless value, so that 'dir'
915  // is not seen as part of the list.
916  // We will later, remove all the object (see files->Clear()
917  cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
918 
919  if (socket->IsA()->InheritsFrom(socketClass)) {
920  gInterpreter->CallFunc_Exec(socketCloser, ((char*)socket)+offset);
921  // Put the object in the closed list for later deletion.
922  socket->SetBit(kMustCleanup);
923  fClosedObjects->AddLast(socket);
924  } else {
925  // Crap ... this is not a socket, likely Proof or something, let's try to find a Close
926  Long_t other_offset;
927  CallFunc_t *otherCloser = gInterpreter->CallFunc_Factory();
928  gInterpreter->CallFunc_SetFuncProto(otherCloser, socket->IsA()->GetClassInfo(), "Close", "", &other_offset);
929  if (gInterpreter->CallFunc_IsValid(otherCloser)) {
930  gInterpreter->CallFunc_Exec(otherCloser, ((char*)socket)+other_offset);
931  // Put the object in the closed list for later deletion.
932  socket->SetBit(kMustCleanup);
933  fClosedObjects->AddLast(socket);
934  } else {
935  notclosed.AddLast(socket);
936  }
937  gInterpreter->CallFunc_Delete(otherCloser);
938  // Put it back
939  cursor->SetObject(socket);
940  }
941  cursor = cursor->Next();
942  }
943  // Now were done, clear the list
944  fSockets->Clear();
945  // Read the one we did not close
946  cursor = notclosed.FirstLink();
947  while (cursor) {
948  static_cast<TList*>(fSockets)->AddLast(cursor->GetObject());
949  cursor = cursor->Next();
950  }
951  }
952  gInterpreter->CallFunc_Delete(socketCloser);
953  }
954  if (fMappedFiles && fMappedFiles->First()) {
955  R__ListSlowClose(static_cast<TList*>(fMappedFiles));
956  }
957 
958 }
959 
960 ////////////////////////////////////////////////////////////////////////////////
961 /// Execute the cleanups necessary at the end of the process, in particular
962 /// those that must be executed before the library start being unloaded.
963 
965 {
966  CloseFiles();
967 
968  if (gInterpreter) {
969  gInterpreter->ResetGlobals();
970  }
971 
972  // Now a set of simpler things to delete. See the same ordering in
973  // TROOT::~TROOT
974  fFunctions->Delete();
975  fGeometries->Delete();
976  fBrowsers->Delete();
977  fCanvases->Delete();
978  fColors->Delete();
979  fStyles->Delete();
980 }
981 
982 
983 ////////////////////////////////////////////////////////////////////////////////
984 /// Find an object in one Root folder
985 
987 {
988  Error("FindObject","Not yet implemented");
989  return 0;
990 }
991 
992 ////////////////////////////////////////////////////////////////////////////////
993 /// Returns address of a ROOT object if it exists
994 ///
995 /// If name contains at least one "/" the function calls FindObjectany
996 /// else
997 /// This function looks in the following order in the ROOT lists:
998 /// - List of files
999 /// - List of memory mapped files
1000 /// - List of functions
1001 /// - List of geometries
1002 /// - List of canvases
1003 /// - List of styles
1004 /// - List of specials
1005 /// - List of materials in current geometry
1006 /// - List of shapes in current geometry
1007 /// - List of matrices in current geometry
1008 /// - List of Nodes in current geometry
1009 /// - Current Directory in memory
1010 /// - Current Directory on file
1011 
1012 TObject *TROOT::FindObject(const char *name) const
1013 {
1014  if (name && strstr(name,"/")) return FindObjectAny(name);
1015 
1016  TObject *temp = 0;
1017 
1018  temp = fFiles->FindObject(name); if (temp) return temp;
1019  temp = fMappedFiles->FindObject(name); if (temp) return temp;
1020  {
1021  R__LOCKGUARD2(gROOTMutex);
1022  temp = fFunctions->FindObject(name); if (temp) return temp;
1023  }
1024  temp = fGeometries->FindObject(name); if (temp) return temp;
1025  temp = fCanvases->FindObject(name); if (temp) return temp;
1026  temp = fStyles->FindObject(name); if (temp) return temp;
1027  temp = fSpecials->FindObject(name); if (temp) return temp;
1028  TIter next(fGeometries);
1029  TObject *obj;
1030  while ((obj=next())) {
1031  temp = obj->FindObject(name); if (temp) return temp;
1032  }
1033  if (gDirectory) temp = gDirectory->Get(name);
1034  if (temp) return temp;
1035  if (gPad) {
1036  TVirtualPad *canvas = gPad->GetVirtCanvas();
1037  if (fCanvases->FindObject(canvas)) { //this check in case call from TCanvas ctor
1038  temp = canvas->FindObject(name);
1039  if (!temp && canvas != gPad) temp = gPad->FindObject(name);
1040  }
1041  }
1042  return temp;
1043 }
1044 
1045 ////////////////////////////////////////////////////////////////////////////////
1046 /// Returns address and folder of a ROOT object if it exists
1047 ///
1048 /// This function looks in the following order in the ROOT lists:
1049 /// - List of files
1050 /// - List of memory mapped files
1051 /// - List of functions
1052 /// - List of geometries
1053 /// - List of canvases
1054 /// - List of styles
1055 /// - List of specials
1056 /// - List of materials in current geometry
1057 /// - List of shapes in current geometry
1058 /// - List of matrices in current geometry
1059 /// - List of Nodes in current geometry
1060 /// - Current Directory in memory
1061 /// - Current Directory on file
1062 
1063 TObject *TROOT::FindSpecialObject(const char *name, void *&where)
1064 {
1065  TObject *temp = 0;
1066  where = 0;
1067 
1068  if (!temp) {
1069  temp = fFiles->FindObject(name);
1070  where = fFiles;
1071  }
1072  if (!temp) {
1073  temp = fMappedFiles->FindObject(name);
1074  where = fMappedFiles;
1075  }
1076  if (!temp) {
1077  R__LOCKGUARD2(gROOTMutex);
1078  temp = fFunctions->FindObject(name);
1079  where = fFunctions;
1080  }
1081  if (!temp) {
1082  temp = fCanvases->FindObject(name);
1083  where = fCanvases;
1084  }
1085  if (!temp) {
1086  temp = fStyles->FindObject(name);
1087  where = fStyles;
1088  }
1089  if (!temp) {
1090  temp = fSpecials->FindObject(name);
1091  where = fSpecials;
1092  }
1093  if (!temp) {
1094  TObject *glast = fGeometries->Last();
1095  if (glast) {where = glast; temp = glast->FindObject(name);}
1096  }
1097  if (!temp && gDirectory) {
1098  temp = gDirectory->Get(name);
1099  where = gDirectory;
1100  }
1101  if (!temp && gPad) {
1102  TVirtualPad *canvas = gPad->GetVirtCanvas();
1103  if (fCanvases->FindObject(canvas)) { //this check in case call from TCanvas ctor
1104  temp = canvas->FindObject(name);
1105  where = canvas;
1106  if (!temp && canvas != gPad) {
1107  temp = gPad->FindObject(name);
1108  where = gPad;
1109  }
1110  }
1111  }
1112  if (!temp) return 0;
1113  if (temp->TestBit(kNotDeleted)) return temp;
1114  return 0;
1115 }
1116 
1117 ////////////////////////////////////////////////////////////////////////////////
1118 /// Return a pointer to the first object with name starting at //root.
1119 /// This function scans the list of all folders.
1120 /// if no object found in folders, it scans the memory list of all files.
1121 
1122 TObject *TROOT::FindObjectAny(const char *name) const
1123 {
1124  TObject *obj = fRootFolder->FindObjectAny(name);
1125  if (obj) return obj;
1126  return gDirectory->FindObjectAnyFile(name);
1127 }
1128 
1129 ////////////////////////////////////////////////////////////////////////////////
1130 /// Scan the memory lists of all files for an object with name
1131 
1133 {
1134  R__LOCKGUARD(gROOTMutex);
1135  TDirectory *d;
1136  TIter next(GetListOfFiles());
1137  while ((d = (TDirectory*)next())) {
1138  // Call explicitly TDirectory::FindObject to restrict the search to the
1139  // already in memory object.
1140  TObject *obj = d->TDirectory::FindObject(name);
1141  if (obj) return obj;
1142  }
1143  return 0;
1144 }
1145 
1146 ////////////////////////////////////////////////////////////////////////////////
1147 /// Returns class name of a ROOT object including CINT globals.
1148 
1149 const char *TROOT::FindObjectClassName(const char *name) const
1150 {
1151  // Search first in the list of "standard" objects
1152  TObject *obj = FindObject(name);
1153  if (obj) return obj->ClassName();
1154 
1155  // Is it a global variable?
1156  TGlobal *g = GetGlobal(name);
1157  if (g) return g->GetTypeName();
1158 
1159  return 0;
1160 }
1161 
1162 ////////////////////////////////////////////////////////////////////////////////
1163 /// Return path name of obj somewhere in the //root/... path.
1164 /// The function returns the first occurence of the object in the list
1165 /// of folders. The returned string points to a static char array in TROOT.
1166 /// If this function is called in a loop or recursively, it is the
1167 /// user's responsibility to copy this string in their area.
1168 
1169 const char *TROOT::FindObjectPathName(const TObject *) const
1170 {
1171  Error("FindObjectPathName","Not yet implemented");
1172  return "??";
1173 }
1174 
1175 ////////////////////////////////////////////////////////////////////////////////
1176 /// return a TClass object corresponding to 'name' assuming it is an STL container.
1177 /// In particular we looking for possible alternative name (default template
1178 /// parameter, typedefs template arguments, typedefed name).
1179 
1180 TClass *TROOT::FindSTLClass(const char *name, Bool_t load, Bool_t silent) const
1181 {
1182  // Example of inputs are
1183  // vector<int> (*)
1184  // vector<Int_t>
1185  // vector<long long>
1186  // vector<Long_64_t> (*)
1187  // vector<int, allocator<int> >
1188  // vector<Int_t, allocator<int> >
1189  //
1190  // One of the possibly expensive operation is the resolving of the typedef
1191  // which can provoke the parsing of the header files (and/or the loading
1192  // of clang pcms information).
1193 
1195 
1196  // Remove std::, allocator, typedef, add Long64_t, etc. in just one call.
1197  std::string normalized;
1198  TClassEdit::GetNormalizedName(normalized, name);
1199 
1200  TClass *cl = 0;
1201  if (normalized != name) cl = TClass::GetClass(normalized.c_str(),load,silent);
1202 
1203  if (load && cl==0) {
1204  // Create an Emulated class for this container.
1205  cl = gInterpreter->GenerateTClass(normalized.c_str(), kTRUE, silent);
1206  }
1207 
1208  return cl;
1209 }
1210 
1211 ////////////////////////////////////////////////////////////////////////////////
1212 /// Return pointer to class with name. Obsolete, use TClass::GetClass directly
1213 
1214 TClass *TROOT::GetClass(const char *name, Bool_t load, Bool_t silent) const
1215 {
1216  return TClass::GetClass(name,load,silent);
1217 }
1218 
1219 
1220 ////////////////////////////////////////////////////////////////////////////////
1221 /// Return pointer to class from its name. Obsolete, use TClass::GetClass directly
1222 /// See TClass::GetClass
1223 
1224 TClass *TROOT::GetClass(const type_info& typeinfo, Bool_t load, Bool_t silent) const
1225 {
1226  return TClass::GetClass(typeinfo,load,silent);
1227 }
1228 
1229 ////////////////////////////////////////////////////////////////////////////////
1230 /// Return address of color with index color.
1231 
1233 {
1235  TObjArray *lcolors = (TObjArray*) GetListOfColors();
1236  if (!lcolors) return 0;
1237  if (color < 0 || color >= lcolors->GetSize()) return 0;
1238  TColor *col = (TColor*)lcolors->At(color);
1239  if (col && col->GetNumber() == color) return col;
1240  TIter next(lcolors);
1241  while ((col = (TColor *) next()))
1242  if (col->GetNumber() == color) return col;
1243 
1244  return 0;
1245 }
1246 
1247 ////////////////////////////////////////////////////////////////////////////////
1248 /// Return a default canvas.
1249 
1251 {
1252  return (TCanvas*)gROOT->ProcessLine("TCanvas::MakeDefCanvas();");
1253 }
1254 
1255 ////////////////////////////////////////////////////////////////////////////////
1256 /// Return pointer to type with name.
1257 
1258 TDataType *TROOT::GetType(const char *name, Bool_t /* load */) const
1259 {
1260  return (TDataType*)gROOT->GetListOfTypes()->FindObject(name);
1261 }
1262 
1263 ////////////////////////////////////////////////////////////////////////////////
1264 /// Return pointer to file with name.
1265 
1266 TFile *TROOT::GetFile(const char *name) const
1267 {
1268  R__LOCKGUARD(gROOTMutex);
1269  return (TFile*)GetListOfFiles()->FindObject(name);
1270 }
1271 
1272 ////////////////////////////////////////////////////////////////////////////////
1273 /// Return pointer to style with name
1274 
1275 TStyle *TROOT::GetStyle(const char *name) const
1276 {
1277  return (TStyle*)GetListOfStyles()->FindObject(name);
1278 }
1279 
1280 ////////////////////////////////////////////////////////////////////////////////
1281 /// Return pointer to function with name.
1282 
1283 TObject *TROOT::GetFunction(const char *name) const
1284 {
1285  if (name == 0 || name[0] == 0) {
1286  return 0;
1287  }
1288 
1289  {
1290  R__LOCKGUARD2(gROOTMutex);
1291  TObject *f1 = fFunctions->FindObject(name);
1292  if (f1) return f1;
1293  }
1294 
1295  gROOT->ProcessLine("TF1::InitStandardFunctions();");
1296 
1297  R__LOCKGUARD2(gROOTMutex);
1298  return fFunctions->FindObject(name);
1299 }
1300 
1301 ////////////////////////////////////////////////////////////////////////////////
1302 
1304 {
1305  if (!gInterpreter) return 0;
1306 
1308 
1309  return (TFunctionTemplate*)fFuncTemplate->FindObject(name);
1310 }
1311 
1312 ////////////////////////////////////////////////////////////////////////////////
1313 /// Return pointer to global variable by name. If load is true force
1314 /// reading of all currently defined globals from CINT (more expensive).
1315 
1316 TGlobal *TROOT::GetGlobal(const char *name, Bool_t load) const
1317 {
1318  return (TGlobal *)gROOT->GetListOfGlobals(load)->FindObject(name);
1319 }
1320 
1321 ////////////////////////////////////////////////////////////////////////////////
1322 /// Return pointer to global variable with address addr.
1323 
1324 TGlobal *TROOT::GetGlobal(const TObject *addr, Bool_t /* load */) const
1325 {
1326  if (addr == 0 || ((Long_t)addr) == -1) return 0;
1327 
1328  TInterpreter::DeclId_t decl = gInterpreter->GetDataMemberAtAddr(addr);
1329  if (decl) {
1330  TListOfDataMembers *globals = ((TListOfDataMembers*)(gROOT->GetListOfGlobals(kFALSE)));
1331  return (TGlobal*)globals->Get(decl);
1332  }
1333  // If we are actually looking for a global that is held by a global
1334  // pointer (for example gRandom), we need to find a pointer with the
1335  // correct value.
1336  decl = gInterpreter->GetDataMemberWithValue(addr);
1337  if (decl) {
1338  TListOfDataMembers *globals = ((TListOfDataMembers*)(gROOT->GetListOfGlobals(kFALSE)));
1339  return (TGlobal*)globals->Get(decl);
1340  }
1341  return 0;
1342 }
1343 
1344 ////////////////////////////////////////////////////////////////////////////////
1345 /// Internal routine returning, and creating if necessary, the list
1346 /// of global function.
1347 
1349 {
1351  return fGlobalFunctions;
1352 }
1353 
1354 ////////////////////////////////////////////////////////////////////////////////
1355 /// Return the collection of functions named "name".
1356 
1358 {
1359  return ((TListOfFunctions*)fFunctions)->GetListForObject(name);
1360 }
1361 
1362 ////////////////////////////////////////////////////////////////////////////////
1363 /// Return pointer to global function by name.
1364 /// If params != 0 it will also resolve overloading other it returns the first
1365 /// name match.
1366 /// If params == 0 and load is true force reading of all currently defined
1367 /// global functions from Cling.
1368 /// The param string must be of the form: "3189,\"aap\",1.3".
1369 
1370 TFunction *TROOT::GetGlobalFunction(const char *function, const char *params,
1371  Bool_t load)
1372 {
1373  if (!params) {
1374  R__LOCKGUARD2(gROOTMutex);
1375  return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
1376  } else {
1377  if (!fInterpreter)
1378  Fatal("GetGlobalFunction", "fInterpreter not initialized");
1379 
1380  R__LOCKGUARD2(gROOTMutex);
1381  TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithValues(0,
1382  function, params,
1383  false);
1384 
1385  if (!decl) return 0;
1386 
1387  TFunction *f = GetGlobalFunctions()->Get(decl);
1388  if (f) return f;
1389 
1390  Error("GetGlobalFunction",
1391  "\nDid not find matching TFunction <%s> with \"%s\".",
1392  function,params);
1393  return 0;
1394  }
1395 }
1396 
1397 ////////////////////////////////////////////////////////////////////////////////
1398 /// Return pointer to global function by name. If proto != 0
1399 /// it will also resolve overloading. If load is true force reading
1400 /// of all currently defined global functions from CINT (more expensive).
1401 /// The proto string must be of the form: "int, char*, float".
1402 
1404  const char *proto, Bool_t load)
1405 {
1406  if (!proto) {
1407  R__LOCKGUARD2(gROOTMutex);
1408  return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
1409  } else {
1410  if (!fInterpreter)
1411  Fatal("GetGlobalFunctionWithPrototype", "fInterpreter not initialized");
1412 
1413  R__LOCKGUARD2(gROOTMutex);
1414  TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithPrototype(0,
1415  function, proto);
1416 
1417  if (!decl) return 0;
1418 
1419  TFunction *f = GetGlobalFunctions()->Get(decl);
1420  if (f) return f;
1421 
1422  Error("GetGlobalFunctionWithPrototype",
1423  "\nDid not find matching TFunction <%s> with \"%s\".",
1424  function,proto);
1425  return 0;
1426  }
1427 }
1428 
1429 ////////////////////////////////////////////////////////////////////////////////
1430 /// Return pointer to Geometry with name
1431 
1432 TObject *TROOT::GetGeometry(const char *name) const
1433 {
1434  return GetListOfGeometries()->FindObject(name);
1435 }
1436 
1437 ////////////////////////////////////////////////////////////////////////////////
1438 
1440 {
1441  if(!fEnums.load()) {
1442  R__LOCKGUARD2(gROOTMutex);
1443  // Test again just in case, another thread did the work while we were
1444  // waiting.
1445  if (!fEnums.load()) fEnums = new TListOfEnumsWithLock(0);
1446  }
1447  if (load) {
1448  R__LOCKGUARD2(gROOTMutex);
1449  (*fEnums).Load(); // Refresh the list of enums.
1450  }
1451  return fEnums.load();
1452 }
1453 
1454 ////////////////////////////////////////////////////////////////////////////////
1455 
1457 {
1458  R__LOCKGUARD2(gROOTMutex);
1459  if(!fFuncTemplate) {
1461  }
1462  return fFuncTemplate;
1463 }
1464 
1465 ////////////////////////////////////////////////////////////////////////////////
1466 /// Return list containing the TGlobals currently defined.
1467 /// Since globals are created and deleted during execution of the
1468 /// program, we need to update the list of globals every time we
1469 /// execute this method. However, when calling this function in
1470 /// a (tight) loop where no interpreter symbols will be created
1471 /// you can set load=kFALSE (default).
1472 
1474 {
1475  if (!fGlobals) {
1476  // We add to the list the "funcky-fake" globals.
1477  fGlobals = new TListOfDataMembers(0);
1478  fGlobals->Add(new TGlobalMappedFunction("gROOT", "TROOT*",
1480  fGlobals->Add(new TGlobalMappedFunction("gPad", "TVirtualPad*",
1482  fGlobals->Add(new TGlobalMappedFunction("gInterpreter", "TInterpreter*",
1484  fGlobals->Add(new TGlobalMappedFunction("gVirtualX", "TTVirtualX*",
1486  fGlobals->Add(new TGlobalMappedFunction("gDirectory", "TDirectory*",
1490  }
1491 
1492  if (!fInterpreter)
1493  Fatal("GetListOfGlobals", "fInterpreter not initialized");
1494 
1495  if (load) fGlobals->Load();
1496 
1497  return fGlobals;
1498 }
1499 
1500 ////////////////////////////////////////////////////////////////////////////////
1501 /// Return list containing the TFunctions currently defined.
1502 /// Since functions are created and deleted during execution of the
1503 /// program, we need to update the list of functions every time we
1504 /// execute this method. However, when calling this function in
1505 /// a (tight) loop where no interpreter symbols will be created
1506 /// you can set load=kFALSE (default).
1507 
1509 {
1510  R__LOCKGUARD2(gROOTMutex);
1511 
1512  if (!fGlobalFunctions) {
1514  }
1515 
1516  if (!fInterpreter)
1517  Fatal("GetListOfGlobalFunctions", "fInterpreter not initialized");
1518 
1519  // A thread that calls with load==true and a thread that calls with load==false
1520  // will conflict here (the load==true will be updating the list while the
1521  // other is reading it). To solve the problem, we could use a read-write lock
1522  // inside the list itself.
1523  if (load) fGlobalFunctions->Load();
1524 
1525  return fGlobalFunctions;
1526 }
1527 
1528 ////////////////////////////////////////////////////////////////////////////////
1529 /// Return a dynamic list giving access to all TDataTypes (typedefs)
1530 /// currently defined.
1531 ///
1532 /// The list is populated on demand. Calling
1533 /// ~~~ {.cpp}
1534 /// gROOT->GetListOfTypes()->FindObject(nameoftype);
1535 /// ~~~
1536 /// will return the TDataType corresponding to 'nameoftype'. If the
1537 /// TDataType is not already in the list itself and the type does exist,
1538 /// a new TDataType will be created and added to the list.
1539 ///
1540 /// Calling
1541 /// ~~~ {.cpp}
1542 /// gROOT->GetListOfTypes()->ls(); // or Print()
1543 /// ~~~
1544 /// list only the typedefs that have been previously accessed through the
1545 /// list (plus the builtins types).
1546 
1548 {
1549  if (!fInterpreter)
1550  Fatal("GetListOfTypes", "fInterpreter not initialized");
1551 
1552  return fTypes;
1553 }
1554 
1555 
1556 ////////////////////////////////////////////////////////////////////////////////
1557 /// Execute command when system has been idle for idleTimeInSec seconds.
1558 
1559 void TROOT::Idle(UInt_t idleTimeInSec, const char *command)
1560 {
1561  if (!fApplication.load())
1563 
1564  if (idleTimeInSec <= 0)
1565  (*fApplication).RemoveIdleTimer();
1566  else
1567  (*fApplication).SetIdleTimer(idleTimeInSec, command);
1568 }
1569 
1570 ////////////////////////////////////////////////////////////////////////////////
1571 /// Check whether className is a known class, and only autoload
1572 /// if we can. Helper function for TROOT::IgnoreInclude().
1573 
1574 static TClass* R__GetClassIfKnown(const char* className)
1575 {
1576  // Check whether the class is available for auto-loading first:
1577  const char* libsToLoad = gInterpreter->GetClassSharedLibs(className);
1578  TClass* cla = 0;
1579  if (libsToLoad) {
1580  // trigger autoload, and only create TClass in this case.
1581  return TClass::GetClass(className);
1582  } else if (gROOT->GetListOfClasses()
1583  && (cla = (TClass*)gROOT->GetListOfClasses()->FindObject(className))) {
1584  // cla assigned in if statement
1585  } else if (gClassTable->FindObject(className)) {
1586  return TClass::GetClass(className);
1587  }
1588  return cla;
1589 }
1590 
1591 ////////////////////////////////////////////////////////////////////////////////
1592 /// Return 1 if the name of the given include file corresponds to a class that
1593 /// is known to ROOT, e.g. "TLorentzVector.h" versus TLorentzVector.
1594 
1595 Int_t TROOT::IgnoreInclude(const char *fname, const char * /*expandedfname*/)
1596 {
1597  if (fname == 0) return 0;
1598 
1599  TString stem(fname);
1600  // Remove extension if any, ignore files with extension not being .h*
1601  Int_t where = stem.Last('.');
1602  if (where != kNPOS) {
1603  if (stem.EndsWith(".so") || stem.EndsWith(".sl") ||
1604  stem.EndsWith(".dl") || stem.EndsWith(".a") ||
1605  stem.EndsWith(".dll", TString::kIgnoreCase))
1606  return 0;
1607  stem.Remove(where);
1608  }
1609 
1610  TString className = gSystem->BaseName(stem);
1611  TClass* cla = R__GetClassIfKnown(className);
1612  if (!cla) {
1613  // Try again with modifications to the file name:
1614  className = stem;
1615  className.ReplaceAll("/", "::");
1616  className.ReplaceAll("\\", "::");
1617  if (className.Contains(":::")) {
1618  // "C:\dir" becomes "C:::dir".
1619  // fname corresponds to whatever is stated after #include and
1620  // a full path name usually means that it's not a regular #include
1621  // but e.g. a ".L", so we can assume that this is not a header of
1622  // a class in a namespace (a global-namespace class would have been
1623  // detected already before).
1624  return 0;
1625  }
1626  cla = R__GetClassIfKnown(className);
1627  }
1628 
1629  if (!cla) {
1630  return 0;
1631  }
1632 
1633  // cla is valid, check wether it's actually in the header of the same name:
1634  if (cla->GetDeclFileLine() <= 0) return 0; // to a void an error with VisualC++
1635  TString decfile = gSystem->BaseName(cla->GetDeclFileName());
1636  if (decfile != gSystem->BaseName(fname)) {
1637  return 0;
1638  }
1639  return 1;
1640 }
1641 
1642 ////////////////////////////////////////////////////////////////////////////////
1643 /// Initialize operating system interface.
1644 
1646 {
1647  if (gSystem == 0) {
1648 #if defined(R__UNIX)
1649 #if defined(R__HAS_COCOA)
1650  gSystem = new TMacOSXSystem;
1651 #else
1652  gSystem = new TUnixSystem;
1653 #endif
1654 #elif defined(R__WIN32)
1655  gSystem = new TWinNTSystem;
1656 #else
1657  gSystem = new TSystem;
1658 #endif
1659 
1660  if (gSystem->Init())
1661  fprintf(stderr, "Fatal in <TROOT::InitSystem>: can't init operating system layer\n");
1662 
1663  if (!gSystem->HomeDirectory()) {
1664  fprintf(stderr, "Fatal in <TROOT::InitSystem>: HOME directory not set\n");
1665  fprintf(stderr, "Fix this by defining the HOME shell variable\n");
1666  }
1667 
1668  // read default files
1669  gEnv = new TEnv(".rootrc");
1670 
1671  gDebug = gEnv->GetValue("Root.Debug", 0);
1672 
1673  if (!gEnv->GetValue("Root.ErrorHandlers", 1))
1674  gSystem->ResetSignals();
1675 
1676  // by default the zipmode is 1 (see Bits.h)
1677  Int_t zipmode = gEnv->GetValue("Root.ZipMode", 1);
1678  if (zipmode != 1) R__SetZipMode(zipmode);
1679 
1680  const char *sdeb;
1681  if ((sdeb = gSystem->Getenv("ROOTDEBUG")))
1682  gDebug = atoi(sdeb);
1683 
1684  if (gDebug > 0 && isatty(2))
1685  fprintf(stderr, "Info in <TROOT::InitSystem>: running with gDebug = %d\n", gDebug);
1686 
1687  if (gEnv->GetValue("Root.MemStat", 0))
1689  int msize = gEnv->GetValue("Root.MemStat.size", -1);
1690  int mcnt = gEnv->GetValue("Root.MemStat.cnt", -1);
1691  if (msize != -1 || mcnt != -1)
1692  TStorage::EnableStatistics(msize, mcnt);
1693 
1694  fgMemCheck = gEnv->GetValue("Root.MemCheck", 0);
1695 
1696 #if defined(R__HAS_COCOA)
1697  // create and delete a dummy TUrl so that TObjectStat table does not contain
1698  // objects that are deleted after recording is turned-off (in next line),
1699  // like the TUrl::fgSpecialProtocols list entries which are created in the
1700  // TMacOSXSystem ctor.
1701  { TUrl dummy("/dummy"); }
1702 #endif
1703  TObject::SetObjectStat(gEnv->GetValue("Root.ObjectStat", 0));
1704  }
1705 }
1706 
1707 ////////////////////////////////////////////////////////////////////////////////
1708 /// Load and initialize thread library.
1709 
1711 {
1712  if (gEnv->GetValue("Root.UseThreads", 0) || gEnv->GetValue("Root.EnableThreadSafety", 0)) {
1714  }
1715 }
1716 
1717 ////////////////////////////////////////////////////////////////////////////////
1718 /// Initialize the interpreter. Should be called only after main(),
1719 /// to make sure LLVM/Clang is fully initialized.
1720 
1722 {
1723  // usedToIdentifyRootClingByDlSym is available when TROOT is part of
1724  // rootcling.
1725  if (!dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")
1726  && !dlsym(RTLD_DEFAULT, "usedToIdentifyStaticRoot")) {
1727  // Make sure no llvm symbols are visible before loading libCling. If they
1728  // exist libCling will use those and not ours, causing havoc in the
1729  // interpreter. Look for an extern "C" symbol to avoid mangling; look for a
1730  // symbol from llvm because clang builds on top, so users would likely
1731  // have also their own llvm symbols when providing their own clang.
1732  void *LLVMEnablePrettyStackTraceAddr = 0;
1733  // Can't use gSystem->DynFindSymbol() because that iterates over all *known*
1734  // libraries which is not the same!
1735  LLVMEnablePrettyStackTraceAddr = dlsym(RTLD_DEFAULT, "LLVMEnablePrettyStackTrace");
1736  if (LLVMEnablePrettyStackTraceAddr) {
1737  Error("InitInterpreter()", "LLVM SYMBOLS ARE EXPOSED TO CLING! "
1738  "This will cause problems; please hide them or dlopen() them "
1739  "after the call to TROOT::InitInterpreter()!");
1740  }
1741 
1742  char *libcling = gSystem->DynamicPathName("libCling");
1743  gInterpreterLib = dlopen(libcling, RTLD_LAZY|RTLD_LOCAL);
1744  delete [] libcling;
1745 
1746  if (!gInterpreterLib) {
1747  TString err = dlerror();
1748  fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load library %s\n", err.Data());
1749  exit(1);
1750  }
1751  dlerror(); // reset error message
1752  } else {
1753  gInterpreterLib = RTLD_DEFAULT;
1754  }
1755  CreateInterpreter_t *CreateInterpreter = (CreateInterpreter_t*) dlsym(gInterpreterLib, "CreateInterpreter");
1756  if (!CreateInterpreter) {
1757  TString err = dlerror();
1758  fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load symbol %s\n", err.Data());
1759  exit(1);
1760  }
1761  // Schedule the destruction of TROOT.
1762  atexit(at_exit_of_TROOT);
1763 
1764  gDestroyInterpreter = (DestroyInterpreter_t*) dlsym(gInterpreterLib, "DestroyInterpreter");
1765  if (!gDestroyInterpreter) {
1766  TString err = dlerror();
1767  fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load symbol %s\n", err.Data());
1768  exit(1);
1769  }
1770 
1771  fInterpreter = CreateInterpreter(gInterpreterLib);
1772 
1775 
1776  fgRootInit = kTRUE;
1777 
1778  // Initialize all registered dictionaries.
1779  for (std::vector<ModuleHeaderInfo_t>::const_iterator
1780  li = GetModuleHeaderInfoBuffer().begin(),
1781  le = GetModuleHeaderInfoBuffer().end(); li != le; ++li) {
1782  // process buffered module registrations
1783  fInterpreter->RegisterModule(li->fModuleName,
1784  li->fHeaders,
1785  li->fIncludePaths,
1786  li->fPayloadCode,
1787  li->fFwdDeclCode,
1788  li->fTriggerFunc,
1789  li->fFwdNargsToKeepColl,
1790  li->fClassesHeaders);
1791  }
1792  GetModuleHeaderInfoBuffer().clear();
1793 
1795 
1796  // Read the rules before enabling the auto loading to not inadvertently
1797  // load the libraries for the classes concerned even-though the user is
1798  // *not* using them.
1799  TClass::ReadRules(); // Read the default customization rules ...
1800 
1801  // Enable autoloading
1803 }
1804 
1805 ////////////////////////////////////////////////////////////////////////////////
1806 /// Helper function used by TClass::GetClass().
1807 /// This function attempts to load the dictionary for 'classname'
1808 /// either from the TClassTable or from the list of generator.
1809 /// If silent is 'true', do not warn about missing dictionary for the class.
1810 /// (typically used for class that are used only for transient members)
1811 ///
1812 /// The 'requestedname' is expected to be already normalized.
1813 
1814 TClass *TROOT::LoadClass(const char *requestedname, Bool_t silent) const
1815 {
1816  return TClass::LoadClass(requestedname, silent);
1817 }
1818 
1819 ////////////////////////////////////////////////////////////////////////////////
1820 /// Check if class "classname" is known to the interpreter (in fact,
1821 /// this check is not needed anymore, so classname is ignored). If
1822 /// not it will load library "libname". If the library name does
1823 /// not start with "lib", "lib" will be prepended and a search will
1824 /// be made in the DynamicPath (see .rootrc). If not found a search
1825 /// will be made on libname (without "lib" prepended) and if not found
1826 /// a direct try of libname will be made (in case it contained an
1827 /// absolute path).
1828 /// If check is true it will only check if libname exists and is
1829 /// readable.
1830 /// Returns 0 on successful loading, -1 in case libname does not
1831 /// exist or in case of error and -2 in case of version mismatch.
1832 
1833 Int_t TROOT::LoadClass(const char * /*classname*/, const char *libname,
1834  Bool_t check)
1835 {
1836  Int_t err = -1;
1837 
1838  char *path;
1839  TString lib = libname;
1840  if (!lib.BeginsWith("lib"))
1841  lib = "lib" + lib;
1842  if ((path = gSystem->DynamicPathName(lib, kTRUE))) {
1843  if (check)
1844  err = 0;
1845  else {
1846  err = gSystem->Load(path, 0, kTRUE);
1847  }
1848  delete [] path;
1849  } else {
1850  if (check) {
1851  FileStat_t stat;
1852  if (!gSystem->GetPathInfo(libname, stat)) {
1853  if (R_ISREG(stat.fMode) &&
1855  err = 0;
1856  else
1857  err = -1;
1858  } else
1859  err = -1;
1860  } else {
1861  err = gSystem->Load(libname, 0, kTRUE);
1862  }
1863  }
1864 
1865  if (err == -1) {
1866  //Error("LoadClass", "library %s could not be loaded", libname);
1867  }
1868 
1869  if (err == 1) {
1870  //Error("LoadClass", "library %s already loaded, but class %s unknown",
1871  // libname, classname);
1872  err = 0;
1873  }
1874 
1875  return err;
1876 }
1877 
1878 ////////////////////////////////////////////////////////////////////////////////
1879 /// Return true if the file is local and is (likely) to be a ROOT file
1880 
1882 {
1883  Bool_t result = kFALSE;
1884  FILE *mayberootfile = fopen(filename,"rb");
1885  if (mayberootfile) {
1886  char header[5];
1887  if (fgets(header,5,mayberootfile)) {
1888  result = strncmp(header,"root",4)==0;
1889  }
1890  fclose(mayberootfile);
1891  }
1892  return result;
1893 }
1894 
1895 ////////////////////////////////////////////////////////////////////////////////
1896 /// To list all objects of the application.
1897 /// Loop on all objects created in the ROOT linked lists.
1898 /// Objects may be files and windows or any other object directly
1899 /// attached to the ROOT linked list.
1900 
1901 void TROOT::ls(Option_t *option) const
1902 {
1903 // TObject::SetDirLevel();
1904 // GetList()->R__FOR_EACH(TObject,ls)(option);
1905  TDirectory::ls(option);
1906 }
1907 
1908 ////////////////////////////////////////////////////////////////////////////////
1909 /// Load a macro in the interpreter's memory. Equivalent to the command line
1910 /// command ".L filename". If the filename has "+" or "++" appended
1911 /// the macro will be compiled by ACLiC. The filename must have the format:
1912 /// [path/]macro.C[+|++[g|O]].
1913 /// The possible error codes are defined by TInterpreter::EErrorCode.
1914 /// If check is true it will only check if filename exists and is
1915 /// readable.
1916 /// Returns 0 on successful loading and -1 in case filename does not
1917 /// exist or in case of error.
1918 
1919 Int_t TROOT::LoadMacro(const char *filename, int *error, Bool_t check)
1920 {
1921  Int_t err = -1;
1922  Int_t lerr, *terr;
1923  if (error)
1924  terr = error;
1925  else
1926  terr = &lerr;
1927 
1928  if (fInterpreter) {
1929  TString aclicMode;
1930  TString arguments;
1931  TString io;
1932  TString fname = gSystem->SplitAclicMode(filename, aclicMode, arguments, io);
1933 
1934  if (arguments.Length()) {
1935  Warning("LoadMacro", "argument(%s) ignored in %s", arguments.Data(), GetMacroPath());
1936  }
1937  char *mac = gSystem->Which(GetMacroPath(), fname, kReadPermission);
1938  if (!mac) {
1939  if (!check)
1940  Error("LoadMacro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
1941  *terr = TInterpreter::kFatal;
1942  } else {
1943  err = 0;
1944  if (!check) {
1945  fname = mac;
1946  fname += aclicMode;
1947  fname += io;
1948  gInterpreter->LoadMacro(fname.Data(), (TInterpreter::EErrorCode*)terr);
1949  if (*terr)
1950  err = -1;
1951  }
1952  }
1953  delete [] mac;
1954  }
1955  return err;
1956 }
1957 
1958 ////////////////////////////////////////////////////////////////////////////////
1959 /// Execute a macro in the interpreter. Equivalent to the command line
1960 /// command ".x filename". If the filename has "+" or "++" appended
1961 /// the macro will be compiled by ACLiC. The filename must have the format:
1962 /// [path/]macro.C[+|++[g|O]][(args)].
1963 /// The possible error codes are defined by TInterpreter::EErrorCode.
1964 /// If padUpdate is true (default) update the current pad.
1965 /// Returns the macro return value.
1966 
1967 Long_t TROOT::Macro(const char *filename, Int_t *error, Bool_t padUpdate)
1968 {
1969  Long_t result = 0;
1970 
1971  if (fInterpreter) {
1972  TString aclicMode;
1973  TString arguments;
1974  TString io;
1975  TString fname = gSystem->SplitAclicMode(filename, aclicMode, arguments, io);
1976 
1977  char *mac = gSystem->Which(GetMacroPath(), fname, kReadPermission);
1978  if (!mac) {
1979  Error("Macro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
1980  if (error)
1981  *error = TInterpreter::kFatal;
1982  } else {
1983  fname = mac;
1984  fname += aclicMode;
1985  fname += arguments;
1986  fname += io;
1987  result = gInterpreter->ExecuteMacro(fname, (TInterpreter::EErrorCode*)error);
1988  }
1989  delete [] mac;
1990 
1991  if (padUpdate && gPad)
1992  gPad->Update();
1993  }
1994 
1995  return result;
1996 }
1997 
1998 ////////////////////////////////////////////////////////////////////////////////
1999 /// Process message id called by obj.
2000 
2001 void TROOT::Message(Int_t id, const TObject *obj)
2002 {
2003  TIter next(fMessageHandlers);
2004  TMessageHandler *mh;
2005  while ((mh = (TMessageHandler*)next())) {
2006  mh->HandleMessage(id,obj);
2007  }
2008 }
2009 
2010 ////////////////////////////////////////////////////////////////////////////////
2011 /// Process interpreter command via TApplication::ProcessLine().
2012 /// On Win32 the line will be processed asynchronously by sending
2013 /// it to the CINT interpreter thread. For explicit synchronous processing
2014 /// use ProcessLineSync(). On non-Win32 platforms there is no difference
2015 /// between ProcessLine() and ProcessLineSync().
2016 /// The possible error codes are defined by TInterpreter::EErrorCode. In
2017 /// particular, error will equal to TInterpreter::kProcessing until the
2018 /// CINT interpreted thread has finished executing the line.
2019 /// Returns the result of the command, cast to a Long_t.
2020 
2021 Long_t TROOT::ProcessLine(const char *line, Int_t *error)
2022 {
2023  TString sline = line;
2024  sline = sline.Strip(TString::kBoth);
2025 
2026  if (!fApplication.load())
2028 
2029  return (*fApplication).ProcessLine(sline, kFALSE, error);
2030 }
2031 
2032 ////////////////////////////////////////////////////////////////////////////////
2033 /// Process interpreter command via TApplication::ProcessLine().
2034 /// On Win32 the line will be processed synchronously (i.e. it will
2035 /// only return when the CINT interpreter thread has finished executing
2036 /// the line). On non-Win32 platforms there is no difference between
2037 /// ProcessLine() and ProcessLineSync().
2038 /// The possible error codes are defined by TInterpreter::EErrorCode.
2039 /// Returns the result of the command, cast to a Long_t.
2040 
2042 {
2043  TString sline = line;
2044  sline = sline.Strip(TString::kBoth);
2045 
2046  if (!fApplication.load())
2048 
2049  return (*fApplication).ProcessLine(sline, kTRUE, error);
2050 }
2051 
2052 ////////////////////////////////////////////////////////////////////////////////
2053 /// Process interpreter command directly via CINT interpreter.
2054 /// Only executable statements are allowed (no variable declarations),
2055 /// In all other cases use TROOT::ProcessLine().
2056 /// The possible error codes are defined by TInterpreter::EErrorCode.
2057 
2059 {
2060  TString sline = line;
2061  sline = sline.Strip(TString::kBoth);
2062 
2063  if (!fApplication.load())
2065 
2066  Long_t result = 0;
2067 
2068  if (fInterpreter) {
2070  result = gInterpreter->Calc(sline, code);
2071  }
2072 
2073  return result;
2074 }
2075 
2076 ////////////////////////////////////////////////////////////////////////////////
2077 /// Read Git commit information and branch name from the
2078 /// etc/gitinfo.txt file.
2079 
2081 {
2082 #ifdef ROOT_GIT_COMMIT
2083  fGitCommit = ROOT_GIT_COMMIT;
2084 #endif
2085 #ifdef ROOT_GIT_BRANCH
2086  fGitBranch = ROOT_GIT_BRANCH;
2087 #endif
2088 
2089  TString gitinfo = "gitinfo.txt";
2090  char *filename = gSystem->ConcatFileName(TROOT::GetEtcDir(), gitinfo);
2091 
2092  FILE *fp = fopen(filename, "r");
2093  if (fp) {
2094  TString s;
2095  // read branch name
2096  s.Gets(fp);
2097  fGitBranch = s;
2098  // read commit SHA1
2099  s.Gets(fp);
2100  fGitCommit = s;
2101  // read date/time make was run
2102  s.Gets(fp);
2103  fGitDate = s;
2104  fclose(fp);
2105  }
2106  delete [] filename;
2107 }
2108 
2110  TTHREAD_TLS(Bool_t) fgReadingObject = false;
2111  return fgReadingObject;
2112 }
2113 
2114 ////////////////////////////////////////////////////////////////////////////////
2115 /// Deprecated (will be removed in next release).
2116 
2118 {
2119  return GetReadingObject();
2120 }
2121 
2123 {
2124  GetReadingObject() = flag;
2125 }
2126 
2127 
2128 ////////////////////////////////////////////////////////////////////////////////
2129 /// Return date/time make was run.
2130 
2131 const char *TROOT::GetGitDate()
2132 {
2133  if (fGitDate == "") {
2134  Int_t iday,imonth,iyear, ihour, imin;
2135  static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
2136  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
2137  Int_t idate = gROOT->GetBuiltDate();
2138  Int_t itime = gROOT->GetBuiltTime();
2139  iday = idate%100;
2140  imonth = (idate/100)%100;
2141  iyear = idate/10000;
2142  ihour = itime/100;
2143  imin = itime%100;
2144  fGitDate.Form("%s %02d %4d, %02d:%02d:00", months[imonth-1], iday, iyear, ihour, imin);
2145  }
2146  return fGitDate;
2147 }
2148 
2149 ////////////////////////////////////////////////////////////////////////////////
2150 /// Refresh all browsers. Call this method when some command line
2151 /// command or script has changed the browser contents. Not needed
2152 /// for objects that have the kMustCleanup bit set. Most useful to
2153 /// update browsers that show the file system or other objects external
2154 /// to the running ROOT session.
2155 
2157 {
2158  TIter next(GetListOfBrowsers());
2159  TBrowser *b;
2160  while ((b = (TBrowser*) next()))
2161  b->SetRefreshFlag(kTRUE);
2162 }
2163 ////////////////////////////////////////////////////////////////////////////////
2164 /// Insure that the files, canvases and sockets are closed.
2165 
2166 static void CallCloseFiles()
2167 {
2168  if (TROOT::Initialized() && ROOT::Internal::gROOTLocal) {
2169  gROOT->CloseFiles();
2170  }
2171 }
2172 
2173 ////////////////////////////////////////////////////////////////////////////////
2174 /// Called by static dictionary initialization to register clang modules
2175 /// for headers. Calls TCling::RegisterModule() unless gCling
2176 /// is NULL, i.e. during startup, where the information is buffered in
2177 /// the static GetModuleHeaderInfoBuffer().
2178 
2179 void TROOT::RegisterModule(const char* modulename,
2180  const char** headers,
2181  const char** includePaths,
2182  const char* payloadCode,
2183  const char* fwdDeclCode,
2184  void (*triggerFunc)(),
2185  const TInterpreter::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
2186  const char** classesHeaders)
2187 {
2188 
2189  // First a side track to insure proper end of process behavior.
2190 
2191  // Register for each loaded dictionary (and thus for each library),
2192  // that we need to Close the ROOT files as soon as this library
2193  // might start being unloaded after main.
2194  //
2195  // By calling atexit here (rather than directly from within the
2196  // library) we make sure that this is not called if the library is
2197  // 'only' dlclosed.
2198 
2199  // On Ubuntu the linker strips the unused libraries. Eventhough
2200  // stressHistogram is explicitly linked against libNet, it is not
2201  // retained and thus is loaded only as needed in the middle part of
2202  // the execution. Concretely this also means that it is loaded
2203  // *after* the construction of the TApplication object and thus
2204  // after the registration (atexit) of the EndOfProcessCleanups
2205  // routine. Consequently, after the end of main, libNet is
2206  // unloaded before EndOfProcessCleanups is called. When
2207  // EndOfProcessCleanups is executed it indirectly needs the TClass
2208  // for TSocket and its search will use resources that have already
2209  // been unloaded (technically the function static in TUnixSystem's
2210  // DynamicPath and the dictionary from libNet).
2211 
2212  // Similarly, the ordering (before this commit) was broken in the
2213  // following case:
2214 
2215  // TApplication creation (EndOfProcessCleanups registration)
2216  // load UserLibrary
2217  // create TFile
2218  // Append UserObject to TFile
2219 
2220  // and after the end of main the order of execution was
2221 
2222  // unload UserLibrary
2223  // call EndOfProcessCleanups
2224  // Write the TFile
2225  // attempt to write the user object.
2226  // ....
2227 
2228  // where what we need is to have the files closen/written before
2229  // the unloading of the library.
2230 
2231  // To solve the problem we now register an atexit function for
2232  // every dictionary thus making sure there is at least one executed
2233  // before the first library tear down after main.
2234 
2235  // If atexit is called directly within a library's code, the
2236  // function will called *either* when the library is 'dlclose'd or
2237  // after then end of main (whichever comes first). We do *not*
2238  // want the files to be closed whenever a library is unloaded via
2239  // dlclose. To avoid this, we add the function (CallCloseFiles)
2240  // from the dictionary indirectly (via ROOT::RegisterModule). In
2241  // this case the function will only only be called either when
2242  // libCore is 'dlclose'd or right after the end of main.
2243 
2244  atexit(CallCloseFiles);
2245 
2246  // Now register with TCling.
2247  if (gCling) {
2248  gCling->RegisterModule(modulename, headers, includePaths, payloadCode, fwdDeclCode,
2249  triggerFunc, fwdDeclsArgToSkip, classesHeaders);
2250  } else {
2251  GetModuleHeaderInfoBuffer()
2252  .push_back(ModuleHeaderInfo_t (modulename, headers, includePaths, payloadCode, fwdDeclCode,
2253  triggerFunc, fwdDeclsArgToSkip,classesHeaders));
2254  }
2255 }
2256 
2257 ////////////////////////////////////////////////////////////////////////////////
2258 /// Remove a class from the list and map of classes.
2259 /// This routine is deprecated, use TClass::RemoveClass directly.
2260 
2262 {
2263  TClass::RemoveClass(oldcl);
2264 }
2265 
2266 ////////////////////////////////////////////////////////////////////////////////
2267 /// Delete all global interpreter objects created since the last call to Reset
2268 ///
2269 /// If option="a" is set reset to startup context (i.e. unload also
2270 /// all loaded files, classes, structs, typedefs, etc.).
2271 ///
2272 /// This function is typically used at the beginning (or end) of an unnamed macro
2273 /// to clean the environment.
2274 ///
2275 /// IMPORTANT WARNING:
2276 /// Do not use this call from within any function (neither compiled nor
2277 /// interpreted. This should only be used from a unnamed macro
2278 /// (which starts with a { (curly braces) ). For example, using TROOT::Reset
2279 /// from within an interpreted function will lead to the unloading of the
2280 /// dictionary and source file, including the one defining the function being
2281 /// executed.
2282 ///
2283 
2284 void TROOT::Reset(Option_t *option)
2285 {
2286  if (IsExecutingMacro()) return; //True when TMacro::Exec runs
2287  if (fInterpreter) {
2288  if (!strncmp(option, "a", 1)) {
2289  fInterpreter->Reset();
2291  } else
2292  gInterpreter->ResetGlobals();
2293 
2294  if (fGlobals) fGlobals->Unload();
2296 
2297  SaveContext();
2298  }
2299 }
2300 
2301 ////////////////////////////////////////////////////////////////////////////////
2302 /// Save the current interpreter context.
2303 
2305 {
2306  if (fInterpreter)
2307  gInterpreter->SaveGlobalsContext();
2308 }
2309 
2310 ////////////////////////////////////////////////////////////////////////////////
2311 /// Set the default graphical cut class name for the graphics editor
2312 /// By default the graphics editor creates an instance of a class TCutG.
2313 /// This function may be called to specify a different class that MUST
2314 /// derive from TCutG
2315 
2316 void TROOT::SetCutClassName(const char *name)
2317 {
2318  if (!name) {
2319  Error("SetCutClassName","Invalid class name");
2320  return;
2321  }
2322  TClass *cl = TClass::GetClass(name);
2323  if (!cl) {
2324  Error("SetCutClassName","Unknown class:%s",name);
2325  return;
2326  }
2327  if (!cl->InheritsFrom("TCutG")) {
2328  Error("SetCutClassName","Class:%s does not derive from TCutG",name);
2329  return;
2330  }
2331  fCutClassName = name;
2332 }
2333 
2334 ////////////////////////////////////////////////////////////////////////////////
2335 /// Set editor mode
2336 
2337 void TROOT::SetEditorMode(const char *mode)
2338 {
2339  fEditorMode = 0;
2340  if (!mode[0]) return;
2341  if (!strcmp(mode,"Arc")) {fEditorMode = kArc; return;}
2342  if (!strcmp(mode,"Line")) {fEditorMode = kLine; return;}
2343  if (!strcmp(mode,"Arrow")) {fEditorMode = kArrow; return;}
2344  if (!strcmp(mode,"Button")) {fEditorMode = kButton; return;}
2345  if (!strcmp(mode,"Diamond")) {fEditorMode = kDiamond; return;}
2346  if (!strcmp(mode,"Ellipse")) {fEditorMode = kEllipse; return;}
2347  if (!strcmp(mode,"Pad")) {fEditorMode = kPad; return;}
2348  if (!strcmp(mode,"Pave")) {fEditorMode = kPave; return;}
2349  if (!strcmp(mode,"PaveLabel")){fEditorMode = kPaveLabel; return;}
2350  if (!strcmp(mode,"PaveText")) {fEditorMode = kPaveText; return;}
2351  if (!strcmp(mode,"PavesText")){fEditorMode = kPavesText; return;}
2352  if (!strcmp(mode,"PolyLine")) {fEditorMode = kPolyLine; return;}
2353  if (!strcmp(mode,"CurlyLine")){fEditorMode = kCurlyLine; return;}
2354  if (!strcmp(mode,"CurlyArc")) {fEditorMode = kCurlyArc; return;}
2355  if (!strcmp(mode,"Text")) {fEditorMode = kText; return;}
2356  if (!strcmp(mode,"Marker")) {fEditorMode = kMarker; return;}
2357  if (!strcmp(mode,"CutG")) {fEditorMode = kCutG; return;}
2358 }
2359 
2360 ////////////////////////////////////////////////////////////////////////////////
2361 /// Change current style to style with name stylename
2362 
2363 void TROOT::SetStyle(const char *stylename)
2364 {
2365  TString style_name = stylename;
2366 
2367  TStyle *style = GetStyle(style_name);
2368  if (style) style->cd();
2369  else Error("SetStyle","Unknown style:%s",style_name.Data());
2370 }
2371 
2372 
2373 //-------- Static Member Functions ---------------------------------------------
2374 
2375 
2376 ////////////////////////////////////////////////////////////////////////////////
2377 /// Decrease the indentation level for ls().
2378 
2380 {
2381  return --fgDirLevel;
2382 }
2383 
2384 ////////////////////////////////////////////////////////////////////////////////
2385 ///return directory level
2386 
2388 {
2389  return fgDirLevel;
2390 }
2391 
2392 ////////////////////////////////////////////////////////////////////////////////
2393 /// Get macro search path. Static utility function.
2394 
2395 const char *TROOT::GetMacroPath()
2396 {
2397  TString &macroPath = ROOT::GetMacroPath();
2398 
2399  if (macroPath.Length() == 0) {
2400  macroPath = gEnv->GetValue("Root.MacroPath", (char*)0);
2401 #if defined(R__WIN32)
2402  macroPath.ReplaceAll("; ", ";");
2403 #else
2404  macroPath.ReplaceAll(": ", ":");
2405 #endif
2406  if (macroPath.Length() == 0)
2407 #if !defined(R__WIN32)
2408  macroPath = ".:" + TROOT::GetMacroDir();
2409 #else
2410  macroPath = ".;" + TROOT::GetMacroDir();
2411 #endif
2412  }
2413 
2414  return macroPath;
2415 }
2416 
2417 ////////////////////////////////////////////////////////////////////////////////
2418 /// Set or extend the macro search path. Static utility function.
2419 /// If newpath=0 or "" reset to value specified in the rootrc file.
2420 
2421 void TROOT::SetMacroPath(const char *newpath)
2422 {
2423  TString &macroPath = ROOT::GetMacroPath();
2424 
2425  if (!newpath || !*newpath)
2426  macroPath = "";
2427  else
2428  macroPath = newpath;
2429 }
2430 
2431 ////////////////////////////////////////////////////////////////////////////////
2432 /// Increase the indentation level for ls().
2433 
2435 {
2436  return ++fgDirLevel;
2437 }
2438 
2439 ////////////////////////////////////////////////////////////////////////////////
2440 /// Functions used by ls() to indent an object hierarchy.
2441 
2443 {
2444  for (int i = 0; i < fgDirLevel; i++) std::cout.put(' ');
2445 }
2446 
2447 ////////////////////////////////////////////////////////////////////////////////
2448 /// Return kTRUE if the TROOT object has been initialized.
2449 
2451 {
2452  return fgRootInit;
2453 }
2454 
2455 ////////////////////////////////////////////////////////////////////////////////
2456 /// Return kTRUE if the memory leak checker is on.
2457 
2459 {
2460  return fgMemCheck;
2461 }
2462 
2463 ////////////////////////////////////////////////////////////////////////////////
2464 /// Return Indentation level for ls().
2465 
2467 {
2468  fgDirLevel = level;
2469 }
2470 
2471 ////////////////////////////////////////////////////////////////////////////////
2472 /// Convert version code to an integer, i.e. 331527 -> 51507.
2473 
2475 {
2476  return 10000*(code>>16) + 100*((code&65280)>>8) + (code&255);
2477 }
2478 
2479 ////////////////////////////////////////////////////////////////////////////////
2480 /// Convert version as an integer to version code as used in RVersion.h.
2481 
2483 {
2484  int a = v/10000;
2485  int b = (v - a*10000)/100;
2486  int c = v - a*10000 - b*100;
2487  return (a << 16) + (b << 8) + c;
2488 }
2489 
2490 ////////////////////////////////////////////////////////////////////////////////
2491 /// Return ROOT version code as defined in RVersion.h.
2492 
2494 {
2495  return ROOT_VERSION_CODE;
2496 }
2497 
2498 ////////////////////////////////////////////////////////////////////////////////
2499 
2501  static const char** extraInterpArgs = 0;
2502  return extraInterpArgs;
2503 }
2504 
2505 ////////////////////////////////////////////////////////////////////////////////
2506 
2507 #ifdef ROOTPREFIX
2508 static Bool_t IgnorePrefix() {
2509  static Bool_t ignorePrefix = gSystem->Getenv("ROOTIGNOREPREFIX");
2510  return ignorePrefix;
2511 }
2512 #endif
2513 
2514 ////////////////////////////////////////////////////////////////////////////////
2515 /// Get the rootsys directory in the installation. Static utility function.
2516 
2518 #ifdef ROOTPREFIX
2519  if (IgnorePrefix()) {
2520 #endif
2521  static TString rootsys;
2522  if (rootsys.IsNull())
2523  rootsys = gSystem->Getenv("ROOTSYS");
2524  if (rootsys.IsNull())
2525  rootsys = gRootDir;
2526  return rootsys;
2527 #ifdef ROOTPREFIX
2528  } else {
2529  const static TString rootsys = ROOTPREFIX;
2530  return rootsys;
2531  }
2532 #endif
2533 }
2534 
2535 ////////////////////////////////////////////////////////////////////////////////
2536 /// Get the binary directory in the installation. Static utility function.
2537 
2539 #ifdef ROOTBINDIR
2540  if (IgnorePrefix()) {
2541 #endif
2542  static TString rootbindir;
2543  if (rootbindir.IsNull()) {
2544  rootbindir = "bin";
2545  gSystem->PrependPathName(GetRootSys(), rootbindir);
2546  }
2547  return rootbindir;
2548 #ifdef ROOTBINDIR
2549  } else {
2550  const static TString rootbindir = ROOTBINDIR;
2551  return rootbindir;
2552  }
2553 #endif
2554 }
2555 
2556 ////////////////////////////////////////////////////////////////////////////////
2557 /// Get the library directory in the installation. Static utility function.
2558 
2560 #ifdef ROOTLIBDIR
2561  if (IgnorePrefix()) {
2562 #endif
2563  static TString rootlibdir;
2564  if (rootlibdir.IsNull()) {
2565  rootlibdir = "lib";
2566  gSystem->PrependPathName(GetRootSys(), rootlibdir);
2567  }
2568  return rootlibdir;
2569 #ifdef ROOTLIBDIR
2570  } else {
2571  const static TString rootlibdir = ROOTLIBDIR;
2572  return rootlibdir;
2573  }
2574 #endif
2575 }
2576 
2577 ////////////////////////////////////////////////////////////////////////////////
2578 /// Get the include directory in the installation. Static utility function.
2579 
2581 #ifdef ROOTINCDIR
2582  if (IgnorePrefix()) {
2583 #endif
2584  static TString rootincdir;
2585  if (rootincdir.IsNull()) {
2586  rootincdir = "include";
2587  gSystem->PrependPathName(GetRootSys(), rootincdir);
2588  }
2589  return rootincdir;
2590 #ifdef ROOTINCDIR
2591  } else {
2592  const static TString rootincdir = ROOTINCDIR;
2593  return rootincdir;
2594  }
2595 #endif
2596 }
2597 
2598 ////////////////////////////////////////////////////////////////////////////////
2599 /// Get the sysconfig directory in the installation. Static utility function.
2600 
2602 #ifdef ROOTETCDIR
2603  if (IgnorePrefix()) {
2604 #endif
2605  static TString rootetcdir;
2606  if (rootetcdir.IsNull()) {
2607  rootetcdir = "etc";
2608  gSystem->PrependPathName(GetRootSys(), rootetcdir);
2609  }
2610  return rootetcdir;
2611 #ifdef ROOTETCDIR
2612  } else {
2613  const static TString rootetcdir = ROOTETCDIR;
2614  return rootetcdir;
2615  }
2616 #endif
2617 }
2618 
2619 ////////////////////////////////////////////////////////////////////////////////
2620 /// Get the data directory in the installation. Static utility function.
2621 
2623 #ifdef ROOTDATADIR
2624  if (IgnorePrefix()) {
2625 #endif
2626  return GetRootSys();
2627 #ifdef ROOTDATADIR
2628  } else {
2629  const static TString rootdatadir = ROOTDATADIR;
2630  return rootdatadir;
2631  }
2632 #endif
2633 }
2634 
2635 ////////////////////////////////////////////////////////////////////////////////
2636 /// Get the documentation directory in the installation. Static utility function.
2637 
2639 #ifdef ROOTDOCDIR
2640  if (IgnorePrefix()) {
2641 #endif
2642  return GetRootSys();
2643 #ifdef ROOTDOCDIR
2644  } else {
2645  const static TString rootdocdir = ROOTDOCDIR;
2646  return rootdocdir;
2647  }
2648 #endif
2649 }
2650 
2651 ////////////////////////////////////////////////////////////////////////////////
2652 /// Get the macro directory in the installation. Static utility function.
2653 
2655 #ifdef ROOTMACRODIR
2656  if (IgnorePrefix()) {
2657 #endif
2658  static TString rootmacrodir;
2659  if (rootmacrodir.IsNull()) {
2660  rootmacrodir = "macros";
2661  gSystem->PrependPathName(GetRootSys(), rootmacrodir);
2662  }
2663  return rootmacrodir;
2664 #ifdef ROOTMACRODIR
2665  } else {
2666  const static TString rootmacrodir = ROOTMACRODIR;
2667  return rootmacrodir;
2668  }
2669 #endif
2670 }
2671 
2672 ////////////////////////////////////////////////////////////////////////////////
2673 /// Get the tutorials directory in the installation. Static utility function.
2674 
2676 #ifdef ROOTTUTDIR
2677  if (IgnorePrefix()) {
2678 #endif
2679  static TString roottutdir;
2680  if (roottutdir.IsNull()) {
2681  roottutdir = "tutorials";
2682  gSystem->PrependPathName(GetRootSys(), roottutdir);
2683  }
2684  return roottutdir;
2685 #ifdef ROOTTUTDIR
2686  } else {
2687  const static TString roottutdir = ROOTTUTDIR;
2688  return roottutdir;
2689  }
2690 #endif
2691 }
2692 
2693 ////////////////////////////////////////////////////////////////////////////////
2694 /// Get the source directory in the installation. Static utility function.
2695 
2697 #ifdef ROOTSRCDIR
2698  if (IgnorePrefix()) {
2699 #endif
2700  static TString rootsrcdir;
2701  if (rootsrcdir.IsNull()) {
2702  rootsrcdir = "src";
2703  gSystem->PrependPathName(GetRootSys(), rootsrcdir);
2704  }
2705  return rootsrcdir;
2706 #ifdef ROOTSRCDIR
2707  } else {
2708  const static TString rootsrcdir = ROOTSRCDIR;
2709  return rootsrcdir;
2710  }
2711 #endif
2712 }
2713 
2714 ////////////////////////////////////////////////////////////////////////////////
2715 /// Get the icon path in the installation. Static utility function.
2716 
2718 #ifdef ROOTICONPATH
2719  if (IgnorePrefix()) {
2720 #endif
2721  static TString rooticonpath;
2722  if (rooticonpath.IsNull()) {
2723  rooticonpath = "icons";
2724  gSystem->PrependPathName(GetRootSys(), rooticonpath);
2725  }
2726  return rooticonpath;
2727 #ifdef ROOTICONPATH
2728  } else {
2729  const static TString rooticonpath = ROOTICONPATH;
2730  return rooticonpath;
2731  }
2732 #endif
2733 }
2734 
2735 ////////////////////////////////////////////////////////////////////////////////
2736 /// Get the fonts directory in the installation. Static utility function.
2737 
2739 #ifdef TTFFONTDIR
2740  if (IgnorePrefix()) {
2741 #endif
2742  static TString ttffontdir;
2743  if (ttffontdir.IsNull()) {
2744  ttffontdir = "fonts";
2745  gSystem->PrependPathName(GetRootSys(), ttffontdir);
2746  }
2747  return ttffontdir;
2748 #ifdef TTFFONTDIR
2749  } else {
2750  const static TString ttffontdir = TTFFONTDIR;
2751  return ttffontdir;
2752  }
2753 #endif
2754 }
TSeqCollection * fStreamerInfo
Definition: TROOT.h:144
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:259
const char * FindObjectPathName(const TObject *obj) const
Return path name of obj somewhere in the //root/...
Definition: TROOT.cxx:1169
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:928
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:1264
Bool_t fExecutingMacro
Definition: TROOT.h:121
void AddClass(TClass *cl)
Add a class to the list and map of classes.
Definition: TROOT.cxx:802
virtual void Add(TObject *obj)
TListOfFunctionTemplates * fFuncTemplate
Definition: TROOT.h:127
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition: TROOT.cxx:2738
TInterpreter * CreateInterpreter_t(void *shlibHandle)
Definition: TInterpreter.h:498
A TFolder object is a collection of objects and folders.
Definition: TFolder.h:32
TCanvas * MakeDefCanvas() const
Return a default canvas.
Definition: TROOT.cxx:1250
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition: TGuiFactory.h:69
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
Semi-Abstract base class defining a generic interface to the underlying, low level, native graphics backend (X11, Win32, MacOS, OpenGL...).
Definition: TVirtualX.h:70
An array of TObjects.
Definition: TObjArray.h:39
virtual void Clear(Option_t *option="")=0
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2379
static Bool_t BlockAllSignals(Bool_t b)
Block or unblock all signals. Returns the previous block status.
Definition: TQObject.cxx:1323
TFolder * fRootFolder
Definition: TROOT.h:152
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
TCollection * GetListOfEnums(Bool_t load=kFALSE)
Definition: TROOT.cxx:1439
ROOT top level object description.
Definition: TROOT.h:80
static const TString & GetMacroDir()
Get the macro directory in the installation. Static utility function.
Definition: TROOT.cxx:2654
void * DestroyInterpreter_t(TInterpreter *)
Definition: TInterpreter.h:499
This class is a specialized TProcessID managing the list of UUIDs.
Definition: TProcessUUID.h:34
TSeqCollection * fProofs
Definition: TROOT.h:147
const char * GetDeclFileName() const
Definition: TClass.h:386
void RemoveClass(TClass *)
Remove a class from the list and map of classes.
Definition: TROOT.cxx:2261
TCollection * GetListOfGlobalFunctions(Bool_t load=kFALSE)
Return list containing the TFunctions currently defined.
Definition: TROOT.cxx:1508
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:865
Int_t LoadMacro(const char *filename, Int_t *error=0, Bool_t check=kFALSE)
Load a macro in the interpreter&#39;s memory.
Definition: TROOT.cxx:1919
virtual void Build(TFile *motherFile=0, TDirectory *motherDir=0)
Initialise directory to defaults.
Definition: TDirectory.cxx:198
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
static const char **& GetExtraInterpreterArgs()
Definition: TROOT.cxx:2500
TLine * line
TSeqCollection * fGeometries
Definition: TROOT.h:139
R__EXTERN TClassTable * gClassTable
Definition: TClassTable.h:97
Handle messages that might be generated by the system.
TDictionary::DeclId_t DeclId_t
Definition: TInterpreter.h:236
const char Option_t
Definition: RtypesCore.h:62
Dictionary for function template This class describes one single function template.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form: ~~~ {.cpp} [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)]...
Definition: TSystem.cxx:4026
static TVirtualX *& Instance()
Returns gVirtualX global.
Definition: TVirtualX.cxx:56
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
Short_t GetDeclFileLine() const
Definition: TClass.h:387
#define ROOT_RELEASE_TIME
Definition: RVersion.h:19
TList * fList
Definition: TDirectory.h:96
static const TString & GetIconPath()
Get the icon path in the installation. Static utility function.
Definition: TROOT.cxx:2717
R__EXTERN TVirtualMutex * gInterpreterMutex
Definition: TInterpreter.h:46
This class represents a WWW compatible URL.
Definition: TUrl.h:41
Int_t fVersionDate
Definition: TROOT.h:103
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
Definition: Buttons.h:33
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
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:1362
Bool_t fForceStyle
Definition: TROOT.h:118
virtual void HandleMessage(Int_t id, const TObject *obj)
Store message origin, keep statistics and call Notify().
Bool_t ReadingObject() const
Deprecated (will be removed in next release).
Definition: TROOT.cxx:2117
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
#define gDirectory
Definition: TDirectory.h:218
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
static Int_t RootVersionCode()
Return ROOT version code as defined in RVersion.h.
Definition: TROOT.cxx:2493
static Bool_t MemCheck()
Return kTRUE if the memory leak checker is on.
Definition: TROOT.cxx:2458
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
TString fVersion
Definition: TROOT.h:100
void R__SetZipMode(int)
virtual const char * HomeDirectory(const char *userName=0)
Return the user&#39;s home directory.
Definition: TSystem.cxx:881
#define ROOT_RELEASE_DATE
Definition: RVersion.h:18
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
Definition: TCollection.cxx:57
static void SetObjectStat(Bool_t stat)
Turn on/off tracking of objects in the TObjectTable.
Definition: TObject.cxx:999
This class implements a mutex interface.
Definition: TVirtualMutex.h:34
static const char * filename()
void InitInterpreter()
Initialize the interpreter.
Definition: TROOT.cxx:1721
#define gROOT
Definition: TROOT.h:352
void LoadHandlersFromEnv(TEnv *env)
Load plugin handlers specified in config file, like: Plugin.TFile: ^rfio: TRFIOFile RFI...
TROOT * GetROOT2()
Definition: TROOT.cxx:358
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1817
The TEnv class reads config files, by default named .rootrc.
Definition: TEnv.h:128
Basic string class.
Definition: TString.h:137
void RefreshBrowsers()
Refresh all browsers.
Definition: TROOT.cxx:2156
TString & GetMacroPath()
Definition: TROOT.cxx:379
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
Definition: TInterpreter.h:108
const Bool_t kFALSE
Definition: Rtypes.h:92
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition: TROOT.cxx:2517
#define gInterpreter
Definition: TInterpreter.h:502
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition: TSystem.cxx:1510
Int_t fVersionCode
Definition: TROOT.h:102
Option_t * GetOption() const
Definition: TCollection.h:160
void Reset(Option_t *option="")
Delete all global interpreter objects created since the last call to Reset.
Definition: TROOT.cxx:2284
Definition: Buttons.h:30
void Load()
Load all the DataMembers known to the interpreter for the scope &#39;fClass&#39; into this collection...
TFunction * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
This class registers for all classes their name, id and dictionary function in a hash table...
Definition: TClassTable.h:40
STL namespace.
#define ROOT_VERSION_CODE
Definition: RVersion.h:21
virtual TObject * FindObjectAny(const char *name) const
Return a pointer to the first object with name starting at this folder.
Definition: TFolder.cxx:350
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
virtual void ResetSignals()
Reset signals handlers to previous behaviour.
Definition: TSystem.cxx:588
std::atomic< TApplication * > fApplication
Definition: TROOT.h:111
void SetStyle(const char *stylename="Default")
Change current style to style with name stylename.
Definition: TROOT.cxx:2363
TDataType * GetType(const char *name, Bool_t load=kFALSE) const
Return pointer to type with name.
Definition: TROOT.cxx:1258
TCollection * GetListOfGlobals(Bool_t load=kFALSE)
Return list containing the TGlobals currently defined.
Definition: TROOT.cxx:1473
TString fGitCommit
Definition: TROOT.h:107
TStyle * GetStyle(const char *name) const
Return pointer to style with name.
Definition: TROOT.cxx:1275
void ls(Option_t *option="") const
To list all objects of the application.
Definition: TROOT.cxx:1901
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
Definition: TROOT.cxx:2580
TROOT * GetROOT1()
Definition: TROOT.cxx:351
Bool_t R_ISREG(Int_t mode)
Definition: TSystem.h:129
virtual void AddLast(TObject *obj)
Add object at the end of the list.
Definition: TList.cxx:136
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
TString fCutClassName
Definition: TROOT.h:155
Bool_t & GetReadingObject()
Definition: TROOT.cxx:2109
TListOfFunctions * GetGlobalFunctions()
Internal routine returning, and creating if necessary, the list of global function.
Definition: TROOT.cxx:1348
static Int_t fgDirLevel
Definition: TROOT.h:88
Definition: Buttons.h:30
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition: TROOT.cxx:2395
TInterpreter * fInterpreter
Definition: TROOT.h:112
Int_t fMode
Definition: TSystem.h:138
static TList & GetEarlyRegisteredGlobals()
Definition: TGlobal.cxx:171
const char * GetGitDate()
Return date/time make was run.
Definition: TROOT.cxx:2131
virtual void cd()
Change current style.
Definition: TStyle.cxx:303
AListOfEnums_t fEnums
Definition: TROOT.h:150
TObject * GetFunction(const char *name) const
Return pointer to function with name.
Definition: TROOT.cxx:1283
TSeqCollection * fMappedFiles
Definition: TROOT.h:132
virtual void Delete(Option_t *option="")=0
Delete this object.
#define SafeDelete(p)
Definition: RConfig.h:449
Sequenceable collection abstract base class.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:187
THashTable implements a hash table to store TObject&#39;s.
Definition: THashTable.h:39
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Definition: TVirtualPad.cxx:29
Int_t fVersionInt
Definition: TROOT.h:101
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
void SetEditorMode(const char *mode="")
Set editor mode.
Definition: TROOT.cxx:2337
static Int_t ReadRules()
Read the class.rules files from the default location:.
Definition: TClass.cxx:1718
TSeqCollection * fCleanups
Definition: TROOT.h:142
Int_t fEditorMode
Definition: TROOT.h:122
Bool_t fMustClean
Definition: TROOT.h:116
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition: TROOT.cxx:2450
void EndOfProcessCleanups()
Execute the cleanups necessary at the end of the process, in particular those that must be executed b...
Definition: TROOT.cxx:964
static Bool_t fgRootInit
Definition: TROOT.h:89
virtual TObject * FindObjectAny(const char *name) const
Return a pointer to the first object with name starting at //root.
Definition: TROOT.cxx:1122
Long_t ProcessLineSync(const char *line, Int_t *error=0)
Process interpreter command via TApplication::ProcessLine().
Definition: TROOT.cxx:2041
void Message(Int_t id, const TObject *obj)
Process message id called by obj.
Definition: TROOT.cxx:2001
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1626
static const TString & GetDocDir()
Get the documentation directory in the installation. Static utility function.
Definition: TROOT.cxx:2638
TCollection * GetListOfFunctionTemplates()
Definition: TROOT.cxx:1456
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition: TSystem.cxx:1054
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2220
static Int_t ITIMQQ(const char *time)
Return built time as integer (with min precision), i.e.
Definition: TROOT.cxx:197
virtual void EnableAutoLoading()=0
void SaveContext()
Save the current interpreter context.
Definition: TROOT.cxx:2304
virtual void Close(Option_t *option="")
Delete all objects from memory and directory structure itself.
Definition: TDirectory.cxx:517
ClassInfo_t * GetClassInfo() const
Definition: TClass.h:391
virtual void Delete(Option_t *option="")
Delete all TFunction object files.
TCollection * GetListOfFunctionOverloads(const char *name) const
Return the collection of functions named "name".
Definition: TROOT.cxx:1357
static void at_exit_of_TROOT()
Definition: TROOT.cxx:269
TSeqCollection * fClipboard
Definition: TROOT.h:148
virtual void Initialize()=0
TFolder * AddFolder(const char *name, const char *title, TCollection *collection=0)
Create a new folder and add it to the list of folders of this folder, return a pointer to the created...
Definition: TFolder.cxx:184
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
R__EXTERN TGuiFactory * gGuiFactory
Definition: TGuiFactory.h:68
static void Cleanup()
static function (called by TROOT destructor) to delete all TProcessIDs
Definition: TProcessID.cxx:173
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TPluginManager * gPluginMgr
Definition: Buttons.h:38
Bool_t fEscape
Definition: TROOT.h:120
TSeqCollection * fFiles
Definition: TROOT.h:131
TSeqCollection * GetListOfGeometries() const
Definition: TROOT.h:228
Describes an Operating System directory for the browser.
virtual TObject * FindObject(const char *name) const
Specialize FindObject to do search for the a function just by name or create it if its not already in...
TCollection * fClasses
Definition: TROOT.h:125
A doubly linked list.
Definition: TList.h:47
Long_t Macro(const char *filename, Int_t *error=0, Bool_t padUpdate=kTRUE)
Execute a macro in the interpreter.
Definition: TROOT.cxx:1967
R__EXTERN TVirtualMutex * gGlobalMutex
Definition: TVirtualMutex.h:29
TStyle objects may be created to define special styles.
Definition: TStyle.h:52
R__EXTERN TROOT * gROOTLocal
Definition: TROOT.h:349
Bool_t fEditHistograms
Definition: TROOT.h:114
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
virtual void AddLast(TObject *obj)=0
Bool_t ClassSaved(TClass *cl)
return class status bit kClassSaved for class cl This function is called by the SavePrimitive functio...
Definition: TROOT.cxx:840
Int_t fVersionTime
Definition: TROOT.h:104
static void RegisterModule(const char *modulename, const char **headers, const char **includePaths, const char *payLoadCode, const char *fwdDeclCode, void(*triggerFunc)(), const FwdDeclArgsToKeepCollection_t &fwdDeclsArgToSkip, const char **classesHeaders)
Called by static dictionary initialization to register clang modules for headers. ...
Definition: TROOT.cxx:2179
R__EXTERN TVirtualX * gGXBatch
Definition: TVirtualX.h:365
static Bool_t fgMemCheck
Definition: TROOT.h:90
TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE) const
Return pointer to class with name. Obsolete, use TClass::GetClass directly.
Definition: TROOT.cxx:1214
TSeqCollection * fDataSets
Definition: TROOT.h:149
Definition: Buttons.h:33
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:379
TSeqCollection * fMessageHandlers
Definition: TROOT.h:143
void Browse(TBrowser *b)
Add browsable objects to TBrowser.
Definition: TROOT.cxx:821
virtual Bool_t Init()
Initialize the OS interface.
Definition: TSystem.cxx:186
void AddClassGenerator(TClassGenerator *gen)
Add a class generator.
Definition: TROOT.cxx:812
TString fDefCanvasName
Definition: TROOT.h:156
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
void SetCutClassName(const char *name="TCutG")
Set the default graphical cut class name for the graphics editor By default the graphics editor creat...
Definition: TROOT.cxx:2316
TGlobal * GetGlobal(const char *name, Bool_t load=kFALSE) const
Return pointer to global variable by name.
Definition: TROOT.cxx:1316
Definition: Buttons.h:33
SVector< double, 2 > v
Definition: Dict.h:5
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
Definition: TClassEdit.cxx:787
Basic data type descriptor (datatype information is obtained from CINT).
Definition: TDataType.h:46
Int_t gDebug
Definition: TROOT.cxx:413
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:480
TPluginManager * fPluginManager
Definition: TROOT.h:154
TString fGitBranch
Definition: TROOT.h:108
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the , or until EOF.
Definition: Stringio.cxx:198
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:558
TSeqCollection * fSecContexts
Definition: TROOT.h:146
Collection abstract base class.
Definition: TCollection.h:48
void(* VoidFuncPtr_t)()
Definition: Rtypes.h:74
void SetRefreshFlag(Bool_t flag)
Definition: TBrowser.h:101
static Int_t ConvertVersionCode2Int(Int_t code)
Convert version code to an integer, i.e. 331527 -> 51507.
Definition: TROOT.cxx:2474
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2321
unsigned int UInt_t
Definition: RtypesCore.h:42
void ReadGitInfo()
Read Git commit information and branch name from the etc/gitinfo.txt file.
Definition: TROOT.cxx:2080
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
virtual TObject * FindObject(const char *name) const
Returns address of a ROOT object if it exists.
Definition: TROOT.cxx:1012
Ssiz_t Length() const
Definition: TString.h:390
TObject * GetGeometry(const char *name) const
Return pointer to Geometry with name.
Definition: TROOT.cxx:1432
virtual void RegisterModule(const char *, const char **, const char **, const char *, const char *, void(*)(), const FwdDeclArgsToKeepCollection_t &fwdDeclArgsToKeep, const char **classesHeaders)=0
static void EnableStatistics(int size=-1, int ix=-1)
Enable memory usage statistics gathering.
Definition: TStorage.cxx:433
This class implements a plugin library manager.
static const TString & GetSourceDir()
Get the source directory in the installation. Static utility function.
Definition: TROOT.cxx:2696
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1069
Int_t LoadClass(const char *classname, const char *libname, Bool_t check=kFALSE)
Check if class "classname" is known to the interpreter (in fact, this check is not needed anymore...
Definition: TROOT.cxx:1833
Objects following this interface can be passed onto the TROOT object to implement a user customized w...
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2442
static TProcessID * AddProcessID()
Static function to add a new TProcessID to the list of PIDs.
Definition: TProcessID.cxx:89
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TFile * GetFile() const
Definition: TROOT.h:244
virtual void SaveContext()=0
Global variables class (global variables are obtained from CINT).
Definition: TGlobal.h:29
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition: TClass.cxx:4568
A collection of TDataType designed to hold the typedef information and numerical type information...
Definition: TListOfTypes.h:32
void SetName(const char *name)
Definition: TCollection.h:116
TROOT * GetROOT()
Definition: TROOT.cxx:375
Bool_t IsRootFile(const char *filename) const
Return true if the file is local and is (likely) to be a ROOT file.
Definition: TROOT.cxx:1881
static TInterpreter * Instance()
returns gInterpreter global
void InitSystem()
Initialize operating system interface.
Definition: TROOT.cxx:1645
#define gVirtualX
Definition: TVirtualX.h:362
TSeqCollection * fSpecials
Definition: TROOT.h:141
virtual TObjLink * FirstLink() const
Definition: TList.h:101
#define R__LOCKGUARD2(mutex)
static void CreateApplication()
Static function used to create a default application environment.
static void RemoveClass(TClass *cl)
static: Remove a class from the list and map of classes
Definition: TClass.cxx:476
TString fGitDate
Definition: TROOT.h:109
static void SetDirLevel(Int_t level=0)
Return Indentation level for ls().
Definition: TROOT.cxx:2466
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
The Canvas class.
Definition: TCanvas.h:48
Bool_t IsExecutingMacro() const
Definition: TROOT.h:263
TSeqCollection * GetListOfColors() const
Definition: TROOT.h:216
TListOfFunctions * fGlobalFunctions
Definition: TROOT.h:129
Long_t ProcessLine(const char *line, Int_t *error=0)
Process interpreter command via TApplication::ProcessLine().
Definition: TROOT.cxx:2021
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
TSeqCollection * fCanvases
Definition: TROOT.h:134
static void BuildStyles()
Create some standard styles.
Definition: TStyle.cxx:287
virtual void SetName(const char *newname)
Set the name for directory If the directory name is changed after the directory was written once...
virtual const char * GetTypeName() const
Get type of global variable, e,g.
Definition: TGlobal.cxx:111
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.
Definition: TROOT.cxx:386
TFunction * GetGlobalFunctionWithPrototype(const char *name, const char *proto=0, Bool_t load=kFALSE)
Return pointer to global function by name.
Definition: TROOT.cxx:1403
void SetReadingObject(Bool_t flag=kTRUE)
Definition: TROOT.cxx:2122
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:864
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Definition: TSystem.cxx:1945
TString fConfigOptions
Definition: TROOT.h:98
void InitThreads()
Load and initialize thread library.
Definition: TROOT.cxx:1710
void Unload()
Mark &#39;all func&#39; as being unloaded.
Describe directory structure in memory.
Definition: TDirectory.h:41
static TDirectory *& CurrentDirectory()
Return the current directory for the current thread.
Definition: TDirectory.cxx:316
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
TSeqCollection * GetListOfStyles() const
Definition: TROOT.h:225
static void AddClass(TClass *cl)
static: Add a class to the list and map of classes.
Definition: TClass.cxx:450
TSeqCollection * GetListOfFiles() const
Definition: TROOT.h:221
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition: TROOT.cxx:2601
Definition: Buttons.h:31
Bool_t fFromPopUp
Definition: TROOT.h:115
static RooMathCoreReg dummy
Int_t fTimer
Definition: TROOT.h:110
TCanvas * style()
Definition: style.C:1
static void CallCloseFiles()
Insure that the files, canvases and sockets are closed.
Definition: TROOT.cxx:2166
Bool_t fBatch
Definition: TROOT.h:113
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
Long_t ProcessLineFast(const char *line, Int_t *error=0)
Process interpreter command directly via CINT interpreter.
Definition: TROOT.cxx:2058
void CloseFiles()
Close any files and sockets that gROOT knows about.
Definition: TROOT.cxx:886
virtual ~TROOT()
Clean up and free resources used by ROOT (files, network sockets, shared memory segments, etc.).
Definition: TROOT.cxx:677
#define R__LOCKGUARD(mutex)
The color creation and management class.
Definition: TColor.h:23
TSeqCollection * fStyles
Definition: TROOT.h:135
virtual void Add(TObject *obj)=0
virtual void CleanCompiledMacros()
Remove the shared libs produced by the CompileMacro() function.
Definition: TSystem.cxx:4111
Bool_t fReadingObject
Definition: TROOT.h:117
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:2871
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:348
TCollection * fClassGenerators
Definition: TROOT.h:145
Int_t IgnoreInclude(const char *fname, const char *expandedfname)
Return 1 if the name of the given include file corresponds to a class that is known to ROOT...
Definition: TROOT.cxx:1595
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Definition: TClass.cxx:5359
virtual void Reset()=0
Bool_t IsNull() const
Definition: TString.h:387
virtual void Delete(Option_t *option="")
Delete all TDataMember object files.
#define name(a, b)
Definition: linkTestLib0.cpp:5
static Int_t GetDirLevel()
return directory level
Definition: TROOT.cxx:2387
Int_t fBuiltTime
Definition: TROOT.h:106
Mother of all ROOT objects.
Definition: TObject.h:58
Global functions class (global functions are obtained from CINT).
Definition: TFunction.h:30
This ABC is a factory for GUI components.
Definition: TGuiFactory.h:44
TFunction * GetGlobalFunction(const char *name, const char *params=0, Bool_t load=kFALSE)
Return pointer to global function by name.
Definition: TROOT.cxx:1370
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
Definition: TROOT.h:172
static Int_t ConvertVersionInt2Code(Int_t v)
Convert version as an integer to version code as used in RVersion.h.
Definition: TROOT.cxx:2482
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2434
typedef void((*Func_t)())
TCollection * GetListOfTypes(Bool_t load=kFALSE)
Return a dynamic list giving access to all TDataTypes (typedefs) currently defined.
Definition: TROOT.cxx:1547
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
Definition: TROOT.cxx:2622
Int_t fBuiltDate
Definition: TROOT.h:105
void Unload()
Mark &#39;all func&#39; as being unloaded.
TFunctionTemplate * GetFunctionTemplate(const char *name)
Definition: TROOT.cxx:1303
TColor * GetColor(Int_t color) const
Return address of color with index color.
Definition: TROOT.cxx:1232
void Load()
Load all the functions known to the interpreter for the scope &#39;fClass&#39; into this collection.
TCollection * fFunctions
Definition: TROOT.h:136
const char * FindObjectClassName(const char *name) const
Returns class name of a ROOT object including CINT globals.
Definition: TROOT.cxx:1149
static void SetMacroPath(const char *newpath)
Set or extend the macro search path.
Definition: TROOT.cxx:2421
TROOT *(* GetROOTFun_t)()
Definition: TROOT.cxx:368
static Int_t IDATQQ(const char *date)
Return built date as integer, i.e. "Apr 28 2000" -> 20000428.
Definition: TROOT.cxx:176
virtual void Add(TObject *obj)
Definition: TList.h:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
TListOfDataMembers * fGlobals
Definition: TROOT.h:128
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Definition: TROOT.cxx:2559
R__EXTERN const char * gRootDir
Definition: TSystem.h:233
virtual void ls(Option_t *option="") const
List Directory contents.
Definition: TDirectory.cxx:998
TSeqCollection * fClosedObjects
Definition: TROOT.h:130
TClass * FindSTLClass(const char *name, Bool_t load, Bool_t silent=kFALSE) const
return a TClass object corresponding to &#39;name&#39; assuming it is an STL container.
Definition: TROOT.cxx:1180
#define ROOT_RELEASE
Definition: RVersion.h:17
TF1 * f1
Definition: legend1.C:11
static Int_t IVERSQ()
Return version id as an integer, i.e. "2.22/04" -> 22204.
Definition: TROOT.cxx:166
Int_t fLineIsProcessing
Definition: TROOT.h:86
TSeqCollection * fTasks
Definition: TROOT.h:137
static void CleanUpROOTAtExit()
Clean up at program termination before global objects go out of scope.
Definition: TROOT.cxx:207
TSeqCollection * fColors
Definition: TROOT.h:138
#define NULL
Definition: Rtypes.h:82
Int_t GetNumber() const
Definition: TColor.h:58
TCollection * fTypes
Definition: TROOT.h:126
#define gPad
Definition: TVirtualPad.h:288
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
TSeqCollection * fBrowsers
Definition: TROOT.h:140
static GetROOTFun_t gGetROOT
Definition: TROOT.cxx:370
static const TString & GetTutorialsDir()
Get the tutorials directory in the installation. Static utility function.
Definition: TROOT.cxx:2675
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition: TColor.cxx:1008
virtual TObject * FindObjectAnyFile(const char *name) const
Scan the memory lists of all files for an object with name.
Definition: TROOT.cxx:1132
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2538
double result[121]
TList * fBrowsables
Definition: TROOT.h:153
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TSeqCollection * fSockets
Definition: TROOT.h:133
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:946
TObject * FindSpecialObject(const char *name, void *&where)
Returns address and folder of a ROOT object if it exists.
Definition: TROOT.cxx:1063
R__EXTERN TInterpreter * gCling
Definition: TInterpreter.h:504
R__DLLEXPORT TInterpreter * CreateInterpreter(void *interpLibHandle)
Definition: TCling.cxx:575
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
virtual Int_t GetSize() const
Definition: TCollection.h:95
Bool_t fInterrupt
Definition: TROOT.h:119
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:258
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
void Idle(UInt_t idleTimeInSec, const char *command=0)
Execute command when system has been idle for idleTimeInSec seconds.
Definition: TROOT.cxx:1559
void *(* GlobalFunc_t)()
Definition: TGlobal.h:56
TSeqCollection * GetListOfBrowsers() const
Definition: TROOT.h:229
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1044
#define sym(otri1, otri2)
Definition: triangle.c:932
static TClass * R__GetClassIfKnown(const char *className)
Check whether className is a known class, and only autoload if we can.
Definition: TROOT.cxx:1574
TString fConfigFeatures
Definition: TROOT.h:99
TProcessUUID * fUUIDs
Definition: TROOT.h:151
static void PrintStatistics()
Print memory usage statistics.
Definition: TStorage.cxx:389
const TObject * fPrimitive
Definition: TROOT.h:123
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904
TVirtualPad * fSelectPad
Definition: TROOT.h:124
virtual TObject * First() const =0
virtual TObject * Last() const =0
TDictionary * Get(DeclId_t id)
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
const char * Data() const
Definition: TString.h:349
TROOT()
Default ctor.
Definition: TROOT.cxx:421