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