Logo ROOT   6.10/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 GetSymInLibImt(const char *funcname)
375  {
376  const static bool loadSuccess = dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")? false : 0 <= gSystem->Load("libImt");
377  if (loadSuccess) {
378  if (auto sym = gSystem->DynFindSymbol(nullptr, funcname)) {
379  return sym;
380  } else {
381  Error("GetSymInLibImt", "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::GetSymInLibImt("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::GetSymInLibImt("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::GetSymInLibImt("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::GetSymInLibImt("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::GetSymInLibImt("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::GetSymInLibImt("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 
491  TString &GetMacroPath() {
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::GetSymInLibImt("ROOT_TThread_Initialize");
501  if (sym)
502  sym();
503  }
504 
505  ////////////////////////////////////////////////////////////////////////////////
506  /// @param[in] numthreads Number of threads to use. If not specified or
507  /// set to zero, the number of threads is automatically
508  /// decided by the implementation. Any other value is
509  /// used as a hint.
510  ///
511  /// ROOT must be built with the compilation flag `imt=ON` for this feature to be available.
512  /// The following objects and methods automatically take advantage of
513  /// multi-threading if a call to `EnableImplicitMT` has been made before usage:
514  ///
515  /// - TDataFrame internally runs the event-loop by parallelizing over clusters of entries
516  /// - TTree::GetEntry reads multiple branches in parallel
517  /// - TTree::FlushBaskets writes multiple baskets to disk in parallel
518  ///
519  /// EnableImplicitMT calls in turn EnableThreadSafety.
520  /// The 'numthreads' parameter allows to control the number of threads to
521  /// be used by the implicit multi-threading. However, this parameter is just
522  /// a hint for ROOT: it will try to satisfy the request if the execution
523  /// scenario allows it. For example, if ROOT is configured to use an external
524  /// scheduler, setting a value for 'numthreads' might not have any effect.
525  void EnableImplicitMT(UInt_t numthreads)
526  {
527 #ifdef R__USE_IMT
529  static void (*sym)(UInt_t) = (void(*)(UInt_t))Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableImplicitMT");
530  if (sym)
531  sym(numthreads);
532 #else
533  ::Warning("EnableImplicitMT", "Cannot enable implicit multi-threading with %d threads, please build ROOT with -Dimt=ON", numthreads);
534 #endif
535  }
536 
537  ////////////////////////////////////////////////////////////////////////////////
538  /// Disables the implicit multi-threading in ROOT (see EnableImplicitMT).
540  {
541 #ifdef R__USE_IMT
542  static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_DisableImplicitMT");
543  if (sym)
544  sym();
545 #else
546  ::Warning("DisableImplicitMT", "Cannot disable implicit multi-threading, please build ROOT with -Dimt=ON");
547 #endif
548  }
549 
550  ////////////////////////////////////////////////////////////////////////////////
551  /// Returns true if the implicit multi-threading in ROOT is enabled.
553  {
554 #ifdef R__USE_IMT
555  static Bool_t (*sym)() = (Bool_t(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_IsImplicitMTEnabled");
556  if (sym)
557  return sym();
558  else
559  return kFALSE;
560 #else
561  return kFALSE;
562 #endif
563  }
564 
565  ////////////////////////////////////////////////////////////////////////////////
566  /// Returns the size of the pool used for implicit multi-threading.
568  {
569 #ifdef R__USE_IMT
570  static UInt_t (*sym)() = (UInt_t(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_GetImplicitMTPoolSize");
571  if (sym)
572  return sym();
573  else
574  return 0;
575 #else
576  return 0;
577 #endif
578  }
579 
580 }
581 
583 
584 // Global debug flag (set to > 0 to get debug output).
585 // Can be set either via the interpreter (gDebug is exported to CINT),
586 // via the rootrc resource "Root.Debug", via the shell environment variable
587 // ROOTDEBUG, or via the debugger.
589 
590 
592 
593 ////////////////////////////////////////////////////////////////////////////////
594 /// Default ctor.
595 
597  fLineIsProcessing(0), fVersion(0), fVersionInt(0), fVersionCode(0),
598  fVersionDate(0), fVersionTime(0), fBuiltDate(0), fBuiltTime(0),
599  fTimer(0), fApplication(0), fInterpreter(0), fBatch(kTRUE), fEditHistograms(kTRUE),
600  fFromPopUp(kTRUE),fMustClean(kTRUE),fReadingObject(kFALSE),fForceStyle(kFALSE),
601  fInterrupt(kFALSE),fEscape(kFALSE),fExecutingMacro(kFALSE),fEditorMode(0),
602  fPrimitive(0),fSelectPad(0),fClasses(0),fTypes(0),fGlobals(0),fGlobalFunctions(0),
603  fClosedObjects(0),fFiles(0),fMappedFiles(0),fSockets(0),fCanvases(0),fStyles(0),fFunctions(0),
604  fTasks(0),fColors(0),fGeometries(0),fBrowsers(0),fSpecials(0),fCleanups(0),
605  fMessageHandlers(0),fStreamerInfo(0),fClassGenerators(0),fSecContexts(0),
606  fProofs(0),fClipboard(0),fDataSets(0),fUUIDs(0),fRootFolder(0),fBrowsables(0),
607  fPluginManager(0)
608 {
609 }
610 
611 ////////////////////////////////////////////////////////////////////////////////
612 /// Initialize the ROOT system. The creation of the TROOT object initializes
613 /// the ROOT system. It must be the first ROOT related action that is
614 /// performed by a program. The TROOT object must be created on the stack
615 /// (can not be called via new since "operator new" is protected). The
616 /// TROOT object is either created as a global object (outside the main()
617 /// program), or it is one of the first objects created in main().
618 /// Make sure that the TROOT object stays in scope for as long as ROOT
619 /// related actions are performed. TROOT is a so called singleton so
620 /// only one instance of it can be created. The single TROOT object can
621 /// always be accessed via the global pointer gROOT.
622 /// The name and title arguments can be used to identify the running
623 /// application. The initfunc argument can contain an array of
624 /// function pointers (last element must be 0). These functions are
625 /// executed at the end of the constructor. This way one can easily
626 /// extend the ROOT system without adding permanent dependencies
627 /// (e.g. the graphics system is initialized via such a function).
628 
629 TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc)
630  : TDirectory(), fLineIsProcessing(0), fVersion(0), fVersionInt(0), fVersionCode(0),
631  fVersionDate(0), fVersionTime(0), fBuiltDate(0), fBuiltTime(0),
632  fTimer(0), fApplication(0), fInterpreter(0), fBatch(kTRUE), fEditHistograms(kTRUE),
633  fFromPopUp(kTRUE),fMustClean(kTRUE),fReadingObject(kFALSE),fForceStyle(kFALSE),
634  fInterrupt(kFALSE),fEscape(kFALSE),fExecutingMacro(kFALSE),fEditorMode(0),
635  fPrimitive(0),fSelectPad(0),fClasses(0),fTypes(0),fGlobals(0),fGlobalFunctions(0),
636  fClosedObjects(0),fFiles(0),fMappedFiles(0),fSockets(0),fCanvases(0),fStyles(0),fFunctions(0),
637  fTasks(0),fColors(0),fGeometries(0),fBrowsers(0),fSpecials(0),fCleanups(0),
638  fMessageHandlers(0),fStreamerInfo(0),fClassGenerators(0),fSecContexts(0),
639  fProofs(0),fClipboard(0),fDataSets(0),fUUIDs(0),fRootFolder(0),fBrowsables(0),
640  fPluginManager(0)
641 {
642  if (fgRootInit || ROOT::Internal::gROOTLocal) {
643  //Warning("TROOT", "only one instance of TROOT allowed");
644  return;
645  }
646 
647  R__LOCKGUARD2(gROOTMutex);
648 
649  ROOT::Internal::gROOTLocal = this;
650  gDirectory = 0;
651 
652  // initialize gClassTable is not already done
653  if (!gClassTable) new TClassTable;
654 
655  SetName(name);
656  SetTitle(title);
657 
658  // will be used by global "operator delete" so make sure it is set
659  // before anything is deleted
660  fMappedFiles = 0;
661 
662  // create already here, but only initialize it after gEnv has been created
664 
665  // Initialize Operating System interface
666  InitSystem();
667 
668  // Initialize static directory functions
669  GetRootSys();
670  GetBinDir();
671  GetLibDir();
672  GetIncludeDir();
673  GetEtcDir();
674  GetDataDir();
675  GetDocDir();
676  GetMacroDir();
677  GetTutorialDir();
678  GetSourceDir();
679  GetIconPath();
680  GetTTFFontDir();
681 
682  gRootDir = GetRootSys().Data();
683 
685 
686  // Initialize interface to CINT C++ interpreter
687  fVersionInt = 0; // check in TROOT dtor in case TCling fails
688  fClasses = 0; // might be checked via TCling ctor
689  fEnums = 0;
690 
691  fConfigOptions = R__CONFIGUREOPTIONS;
692  fConfigFeatures = R__CONFIGUREFEATURES;
695  fVersionInt = IVERSQ();
698  fBuiltDate = IDATQQ(__DATE__);
699  fBuiltTime = ITIMQQ(__TIME__);
700 
701  ReadGitInfo();
702 
703  fClasses = new THashTable(800,3);
704  //fIdMap = new IdMap_t;
705  fStreamerInfo = new TObjArray(100);
706  fClassGenerators = new TList;
707 
708  // usedToIdentifyRootClingByDlSym is available when TROOT is part of
709  // rootcling.
710  if (!dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")) {
711  // initialize plugin manager early
713 #if defined(R__MACOSX) && (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
714  if (TARGET_OS_IPHONE | TARGET_IPHONE_SIMULATOR) {
715  TEnv plugins(".plugins-ios");
717  }
718 #endif
719  }
720 
721  TSystemDirectory *workdir = new TSystemDirectory("workdir", gSystem->WorkingDirectory());
722 
723  fTimer = 0;
724  fApplication = 0;
725  fColors = new TObjArray(1000); fColors->SetName("ListOfColors");
726  fTypes = 0;
727  fGlobals = 0;
728  fGlobalFunctions = 0;
729  // fList was created in TDirectory::Build but with different sizing.
730  delete fList;
731  fList = new THashList(1000,3);
732  fClosedObjects = new TList; fClosedObjects->SetName("ClosedFiles");
733  fFiles = new TList; fFiles->SetName("Files");
734  fMappedFiles = new TList; fMappedFiles->SetName("MappedFiles");
735  fSockets = new TList; fSockets->SetName("Sockets");
736  fCanvases = new TList; fCanvases->SetName("Canvases");
737  fStyles = new TList; fStyles->SetName("Styles");
738  fFunctions = new TList; fFunctions->SetName("Functions");
739  fTasks = new TList; fTasks->SetName("Tasks");
740  fGeometries = new TList; fGeometries->SetName("Geometries");
741  fBrowsers = new TList; fBrowsers->SetName("Browsers");
742  fSpecials = new TList; fSpecials->SetName("Specials");
743  fBrowsables = new TList; fBrowsables->SetName("Browsables");
744  fCleanups = new THashList; fCleanups->SetName("Cleanups");
745  fMessageHandlers = new TList; fMessageHandlers->SetName("MessageHandlers");
746  fSecContexts = new TList; fSecContexts->SetName("SecContexts");
747  fProofs = new TList; fProofs->SetName("Proofs");
748  fClipboard = new TList; fClipboard->SetName("Clipboard");
749  fDataSets = new TList; fDataSets->SetName("DataSets");
750  fTypes = new TListOfTypes;
751 
753  fUUIDs = new TProcessUUID();
754 
755  fRootFolder = new TFolder();
756  fRootFolder->SetName("root");
757  fRootFolder->SetTitle("root of all folders");
758  fRootFolder->AddFolder("Classes", "List of Active Classes",fClasses);
759  fRootFolder->AddFolder("Colors", "List of Active Colors",fColors);
760  fRootFolder->AddFolder("MapFiles", "List of MapFiles",fMappedFiles);
761  fRootFolder->AddFolder("Sockets", "List of Socket Connections",fSockets);
762  fRootFolder->AddFolder("Canvases", "List of Canvases",fCanvases);
763  fRootFolder->AddFolder("Styles", "List of Styles",fStyles);
764  fRootFolder->AddFolder("Functions", "List of Functions",fFunctions);
765  fRootFolder->AddFolder("Tasks", "List of Tasks",fTasks);
766  fRootFolder->AddFolder("Geometries","List of Geometries",fGeometries);
767  fRootFolder->AddFolder("Browsers", "List of Browsers",fBrowsers);
768  fRootFolder->AddFolder("Specials", "List of Special Objects",fSpecials);
769  fRootFolder->AddFolder("Handlers", "List of Message Handlers",fMessageHandlers);
770  fRootFolder->AddFolder("Cleanups", "List of RecursiveRemove Collections",fCleanups);
771  fRootFolder->AddFolder("StreamerInfo","List of Active StreamerInfo Classes",fStreamerInfo);
772  fRootFolder->AddFolder("SecContexts","List of Security Contexts",fSecContexts);
773  fRootFolder->AddFolder("PROOF Sessions", "List of PROOF sessions",fProofs);
774  fRootFolder->AddFolder("ROOT Memory","List of Objects in the gROOT Directory",fList);
775  fRootFolder->AddFolder("ROOT Files","List of Connected ROOT Files",fFiles);
776 
777  // by default, add the list of files, tasks, canvases and browsers in the Cleanups list
783 
786  fFromPopUp = kFALSE;
788  fInterrupt = kFALSE;
789  fEscape = kFALSE;
790  fMustClean = kTRUE;
791  fPrimitive = 0;
792  fSelectPad = 0;
793  fEditorMode = 0;
794  fDefCanvasName = "c1";
796  fLineIsProcessing = 1; // This prevents WIN32 "Windows" thread to pick ROOT objects with mouse
797  gDirectory = this;
798  gPad = 0;
799 
800  //set name of graphical cut class for the graphics editor
801  //cannot call SetCutClassName at this point because the TClass of TCutG
802  //is not yet build
803  fCutClassName = "TCutG";
804 
805  // Create a default MessageHandler
806  new TMessageHandler((TClass*)0);
807 
808  // Create some styles
809  gStyle = 0;
811  SetStyle(gEnv->GetValue("Canvas.Style", "Modern"));
812 
813  // Setup default (batch) graphics and GUI environment
816  gGXBatch = new TVirtualX("Batch", "ROOT Interface to batch graphics");
818 
819 #if defined(R__WIN32)
820  fBatch = kFALSE;
821 #elif defined(R__HAS_COCOA)
822  fBatch = kFALSE;
823 #else
824  if (gSystem->Getenv("DISPLAY"))
825  fBatch = kFALSE;
826  else
827  fBatch = kTRUE;
828 #endif
829 
830  int i = 0;
831  while (initfunc && initfunc[i]) {
832  (initfunc[i])();
833  fBatch = kFALSE; // put system in graphics mode (backward compatible)
834  i++;
835  }
836 
837  // Set initial/default list of browsable objects
838  fBrowsables->Add(fRootFolder, "root");
839  fBrowsables->Add(fProofs, "PROOF Sessions");
840  fBrowsables->Add(workdir, gSystem->WorkingDirectory());
841  fBrowsables->Add(fFiles, "ROOT Files");
842 
843  atexit(CleanUpROOTAtExit);
844 
846 }
847 
848 ////////////////////////////////////////////////////////////////////////////////
849 /// Clean up and free resources used by ROOT (files, network sockets,
850 /// shared memory segments, etc.).
851 
853 {
854  using namespace ROOT::Internal;
855 
856  if (gROOTLocal == this) {
857 
858  // If the interpreter has not yet been initialized, don't bother
859  gGetROOT = &GetROOT1;
860 
861  // Mark the object as invalid, so that we can veto some actions
862  // (like autoloading) while we are in the destructor.
864 
865  // Turn-off the global mutex to avoid recreating mutexes that have
866  // already been deleted during the destruction phase
867  gGlobalMutex = 0;
868 
869  // Return when error occurred in TCling, i.e. when setup file(s) are
870  // out of date
871  if (!fVersionInt) return;
872 
873  // ATTENTION!!! Order is important!
874 
875 #ifdef R__COMPLETE_MEM_TERMINATION
878  fSpecials->Delete(); SafeDelete(fSpecials); // delete special objects : PostScript, Minuit, Html
879 #endif
880  fClosedObjects->Delete("slow"); // and closed files
881  fFiles->Delete("slow"); // and files
883  fSecContexts->Delete("slow"); SafeDelete(fSecContexts); // and security contexts
884  fSockets->Delete(); SafeDelete(fSockets); // and sockets
885  fMappedFiles->Delete("slow"); // and mapped files
886  delete fUUIDs;
887  TProcessID::Cleanup(); // and list of ProcessIDs
888  TSeqCollection *tl = fMappedFiles; fMappedFiles = 0; delete tl;
889 
891 
892  fFunctions->Delete(); SafeDelete(fFunctions); // etc..
895 #ifdef R__COMPLETE_MEM_TERMINATION
897 #endif
900 
901 #ifdef R__COMPLETE_MEM_TERMINATION
906 #endif
907 
908  // Stop emitting signals
910 
912 
913 #ifdef R__COMPLETE_MEM_TERMINATION
919 
920  fCleanups->Clear();
922  delete gClassTable; gClassTable = 0;
923  delete gEnv; gEnv = 0;
924 
925  if (fTypes) fTypes->Delete();
927  if (fGlobals) fGlobals->Delete();
931  fEnums->Delete();
932  fClasses->Delete(); SafeDelete(fClasses); // TClass'es must be deleted last
933 #endif
934 
935  // Remove shared libraries produced by the TSystem::CompileMacro() call
937 
938  // Cleanup system class
939  delete gSystem;
940 
941  // ROOT-6022:
942  // if (gInterpreterLib) dlclose(gInterpreterLib);
943 #ifdef R__COMPLETE_MEM_TERMINATION
944  // On some 'newer' platform (Fedora Core 17+, Ubuntu 12), the
945  // initialization order is (by default?) is 'wrong' and so we can't
946  // delete the interpreter now .. because any of the static in the
947  // interpreter's library have already been deleted.
948  // On the link line, we must list the most dependent .o file
949  // and end with the least dependent (LLVM libraries), unfortunately,
950  // Fedora Core 17+ or Ubuntu 12 will also execute the initialization
951  // in the same order (hence doing libCore's before LLVM's and
952  // vice et versa for both the destructor. We worked around the
953  // initialization order by delay the TROOT creation until first use.
954  // We can not do the same for destruction as we have no way of knowing
955  // the last access ...
956  // So for now, let's avoid delete TCling except in the special build
957  // checking the completeness of the termination deletion.
958  gDestroyCling(fInterpreter);
959 #endif
960 
961 #ifdef R__COMPLETE_MEM_TERMINATION
963 #endif
964 
965  // Prints memory stats
967 
968  gROOTLocal = 0;
969  fgRootInit = kFALSE;
970  }
971 }
972 
973 ////////////////////////////////////////////////////////////////////////////////
974 /// Add a class to the list and map of classes.
975 /// This routine is deprecated, use TClass::AddClass directly.
976 
978 {
979  TClass::AddClass(cl);
980 }
981 
982 ////////////////////////////////////////////////////////////////////////////////
983 /// Add a class generator. This generator will be called by TClass::GetClass
984 /// in case its does not find a loaded rootcint dictionary to request the
985 /// creation of a TClass object.
986 
988 {
989  if (!generator) return;
990  fClassGenerators->Add(generator);
991 }
992 
993 ////////////////////////////////////////////////////////////////////////////////
994 /// Add browsable objects to TBrowser.
995 
997 {
998  TObject *obj;
999  TIter next(fBrowsables);
1000 
1001  while ((obj = (TObject *) next())) {
1002  const char *opt = next.GetOption();
1003  if (opt && strlen(opt))
1004  b->Add(obj, opt);
1005  else
1006  b->Add(obj, obj->GetName());
1007  }
1008 }
1009 
1010 ////////////////////////////////////////////////////////////////////////////////
1011 /// return class status bit kClassSaved for class cl
1012 /// This function is called by the SavePrimitive functions writing
1013 /// the C++ code for an object.
1014 
1016 {
1017  if (cl == 0) return kFALSE;
1018  if (cl->TestBit(TClass::kClassSaved)) return kTRUE;
1020  return kFALSE;
1021 }
1022 
1023 namespace {
1024  static void R__ListSlowClose(TList *files)
1025  {
1026  // Routine to close a list of files using the 'slow' techniques
1027  // that also for the deletion ot update the list itself.
1028 
1029  static TObject harmless;
1030  TObjLink *cursor = files->FirstLink();
1031  while (cursor) {
1032  TDirectory *dir = static_cast<TDirectory*>( cursor->GetObject() );
1033  if (dir) {
1034  // In order for the iterator to stay valid, we must
1035  // prevent the removal of the object (dir) from the list
1036  // (which is done in TFile::Close). We can also can not
1037  // just move to the next iterator since the Close might
1038  // also (indirectly) remove that file.
1039  // So we SetObject to a harmless value, so that 'dir'
1040  // is not seen as part of the list.
1041  // We will later, remove all the object (see files->Clear()
1042  cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
1043  dir->Close();
1044  // Put it back
1045  cursor->SetObject(dir);
1046  }
1047  cursor = cursor->Next();
1048  };
1049  // Now were done, clear the list but do not delete the objects as
1050  // they have been moved to the list of closed objects and must be
1051  // deleted from there in order to avoid a double delete from a
1052  // use objects (on the interpreter stack).
1053  files->Clear("nodelete");
1054  }
1055 }
1056 
1057 ////////////////////////////////////////////////////////////////////////////////
1058 /// Close any files and sockets that gROOT knows about.
1059 /// This can be used to insures that the files and sockets are closed before any library is unloaded!
1060 
1062 {
1063  if (fFiles && fFiles->First()) {
1064  R__ListSlowClose(static_cast<TList*>(fFiles));
1065  }
1066  // and Close TROOT itself.
1067  Close();
1068  // Now sockets.
1069  if (fSockets && fSockets->First()) {
1070  if (0==fCleanups->FindObject(fSockets) ) {
1073  }
1074  CallFunc_t *socketCloser = gInterpreter->CallFunc_Factory();
1075  Long_t offset = 0;
1076  TClass *socketClass = TClass::GetClass("TSocket");
1077  gInterpreter->CallFunc_SetFuncProto(socketCloser, socketClass->GetClassInfo(), "Close", "", &offset);
1078  if (gInterpreter->CallFunc_IsValid(socketCloser)) {
1079  static TObject harmless;
1080  TObjLink *cursor = static_cast<TList*>(fSockets)->FirstLink();
1081  TList notclosed;
1082  while (cursor) {
1083  TObject *socket = cursor->GetObject();
1084  // In order for the iterator to stay valid, we must
1085  // prevent the removal of the object (dir) from the list
1086  // (which is done in TFile::Close). We can also can not
1087  // just move to the next iterator since the Close might
1088  // also (indirectly) remove that file.
1089  // So we SetObject to a harmless value, so that 'dir'
1090  // is not seen as part of the list.
1091  // We will later, remove all the object (see files->Clear()
1092  cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
1093 
1094  if (socket->IsA()->InheritsFrom(socketClass)) {
1095  gInterpreter->CallFunc_Exec(socketCloser, ((char*)socket)+offset);
1096  // Put the object in the closed list for later deletion.
1097  socket->SetBit(kMustCleanup);
1098  fClosedObjects->AddLast(socket);
1099  } else {
1100  // Crap ... this is not a socket, likely Proof or something, let's try to find a Close
1101  Long_t other_offset;
1102  CallFunc_t *otherCloser = gInterpreter->CallFunc_Factory();
1103  gInterpreter->CallFunc_SetFuncProto(otherCloser, socket->IsA()->GetClassInfo(), "Close", "", &other_offset);
1104  if (gInterpreter->CallFunc_IsValid(otherCloser)) {
1105  gInterpreter->CallFunc_Exec(otherCloser, ((char*)socket)+other_offset);
1106  // Put the object in the closed list for later deletion.
1107  socket->SetBit(kMustCleanup);
1108  fClosedObjects->AddLast(socket);
1109  } else {
1110  notclosed.AddLast(socket);
1111  }
1112  gInterpreter->CallFunc_Delete(otherCloser);
1113  // Put it back
1114  cursor->SetObject(socket);
1115  }
1116  cursor = cursor->Next();
1117  }
1118  // Now were done, clear the list
1119  fSockets->Clear();
1120  // Read the one we did not close
1121  cursor = notclosed.FirstLink();
1122  while (cursor) {
1123  static_cast<TList*>(fSockets)->AddLast(cursor->GetObject());
1124  cursor = cursor->Next();
1125  }
1126  }
1127  gInterpreter->CallFunc_Delete(socketCloser);
1128  }
1129  if (fMappedFiles && fMappedFiles->First()) {
1130  R__ListSlowClose(static_cast<TList*>(fMappedFiles));
1131  }
1132 
1133 }
1134 
1135 ////////////////////////////////////////////////////////////////////////////////
1136 /// Execute the cleanups necessary at the end of the process, in particular
1137 /// those that must be executed before the library start being unloaded.
1138 
1140 {
1141  CloseFiles();
1142 
1143  if (gInterpreter) {
1144  gInterpreter->ResetGlobals();
1145  }
1146 
1147  // Now a set of simpler things to delete. See the same ordering in
1148  // TROOT::~TROOT
1149  fFunctions->Delete();
1150  fGeometries->Delete();
1151  fBrowsers->Delete();
1152  fCanvases->Delete();
1153  fColors->Delete();
1154  fStyles->Delete();
1155 }
1156 
1157 
1158 ////////////////////////////////////////////////////////////////////////////////
1159 /// Find an object in one Root folder
1160 
1162 {
1163  Error("FindObject","Not yet implemented");
1164  return 0;
1165 }
1166 
1167 ////////////////////////////////////////////////////////////////////////////////
1168 /// Returns address of a ROOT object if it exists
1169 ///
1170 /// If name contains at least one "/" the function calls FindObjectany
1171 /// else
1172 /// This function looks in the following order in the ROOT lists:
1173 /// - List of files
1174 /// - List of memory mapped files
1175 /// - List of functions
1176 /// - List of geometries
1177 /// - List of canvases
1178 /// - List of styles
1179 /// - List of specials
1180 /// - List of materials in current geometry
1181 /// - List of shapes in current geometry
1182 /// - List of matrices in current geometry
1183 /// - List of Nodes in current geometry
1184 /// - Current Directory in memory
1185 /// - Current Directory on file
1186 
1187 TObject *TROOT::FindObject(const char *name) const
1188 {
1189  if (name && strstr(name,"/")) return FindObjectAny(name);
1190 
1191  TObject *temp = 0;
1192 
1193  temp = fFiles->FindObject(name); if (temp) return temp;
1194  temp = fMappedFiles->FindObject(name); if (temp) return temp;
1195  {
1196  R__LOCKGUARD2(gROOTMutex);
1197  temp = fFunctions->FindObject(name);if (temp) return temp;
1198  }
1199  temp = fGeometries->FindObject(name); if (temp) return temp;
1200  temp = fCanvases->FindObject(name); if (temp) return temp;
1201  temp = fStyles->FindObject(name); if (temp) return temp;
1202  {
1203  R__LOCKGUARD2(gROOTMutex);
1204  temp = fSpecials->FindObject(name); if (temp) return temp;
1205  }
1206  TIter next(fGeometries);
1207  TObject *obj;
1208  while ((obj=next())) {
1209  temp = obj->FindObject(name); if (temp) return temp;
1210  }
1211  if (gDirectory) temp = gDirectory->Get(name);
1212  if (temp) return temp;
1213  if (gPad) {
1214  TVirtualPad *canvas = gPad->GetVirtCanvas();
1215  if (fCanvases->FindObject(canvas)) { //this check in case call from TCanvas ctor
1216  temp = canvas->FindObject(name);
1217  if (!temp && canvas != gPad) temp = gPad->FindObject(name);
1218  }
1219  }
1220  return temp;
1221 }
1222 
1223 ////////////////////////////////////////////////////////////////////////////////
1224 /// Returns address and folder of a ROOT object if it exists
1225 ///
1226 /// This function looks in the following order in the ROOT lists:
1227 /// - List of files
1228 /// - List of memory mapped files
1229 /// - List of functions
1230 /// - List of geometries
1231 /// - List of canvases
1232 /// - List of styles
1233 /// - List of specials
1234 /// - List of materials in current geometry
1235 /// - List of shapes in current geometry
1236 /// - List of matrices in current geometry
1237 /// - List of Nodes in current geometry
1238 /// - Current Directory in memory
1239 /// - Current Directory on file
1240 
1241 TObject *TROOT::FindSpecialObject(const char *name, void *&where)
1242 {
1243  TObject *temp = 0;
1244  where = 0;
1245 
1246  if (!temp) {
1247  temp = fFiles->FindObject(name);
1248  where = fFiles;
1249  }
1250  if (!temp) {
1251  temp = fMappedFiles->FindObject(name);
1252  where = fMappedFiles;
1253  }
1254  if (!temp) {
1255  R__LOCKGUARD2(gROOTMutex);
1256  temp = fFunctions->FindObject(name);
1257  where = fFunctions;
1258  }
1259  if (!temp) {
1260  temp = fCanvases->FindObject(name);
1261  where = fCanvases;
1262  }
1263  if (!temp) {
1264  temp = fStyles->FindObject(name);
1265  where = fStyles;
1266  }
1267  if (!temp) {
1268  temp = fSpecials->FindObject(name);
1269  where = fSpecials;
1270  }
1271  if (!temp) {
1272  TObject *glast = fGeometries->Last();
1273  if (glast) {where = glast; temp = glast->FindObject(name);}
1274  }
1275  if (!temp && gDirectory) {
1276  temp = gDirectory->Get(name);
1277  where = gDirectory;
1278  }
1279  if (!temp && gPad) {
1280  TVirtualPad *canvas = gPad->GetVirtCanvas();
1281  if (fCanvases->FindObject(canvas)) { //this check in case call from TCanvas ctor
1282  temp = canvas->FindObject(name);
1283  where = canvas;
1284  if (!temp && canvas != gPad) {
1285  temp = gPad->FindObject(name);
1286  where = gPad;
1287  }
1288  }
1289  }
1290  if (!temp) return 0;
1291  if (temp->TestBit(kNotDeleted)) return temp;
1292  return 0;
1293 }
1294 
1295 ////////////////////////////////////////////////////////////////////////////////
1296 /// Return a pointer to the first object with name starting at //root.
1297 /// This function scans the list of all folders.
1298 /// if no object found in folders, it scans the memory list of all files.
1299 
1300 TObject *TROOT::FindObjectAny(const char *name) const
1301 {
1302  TObject *obj = fRootFolder->FindObjectAny(name);
1303  if (obj) return obj;
1304  return gDirectory->FindObjectAnyFile(name);
1305 }
1306 
1307 ////////////////////////////////////////////////////////////////////////////////
1308 /// Scan the memory lists of all files for an object with name
1309 
1311 {
1312  R__LOCKGUARD(gROOTMutex);
1313  TDirectory *d;
1314  TIter next(GetListOfFiles());
1315  while ((d = (TDirectory*)next())) {
1316  // Call explicitly TDirectory::FindObject to restrict the search to the
1317  // already in memory object.
1318  TObject *obj = d->TDirectory::FindObject(name);
1319  if (obj) return obj;
1320  }
1321  return 0;
1322 }
1323 
1324 ////////////////////////////////////////////////////////////////////////////////
1325 /// Returns class name of a ROOT object including CINT globals.
1326 
1327 const char *TROOT::FindObjectClassName(const char *name) const
1328 {
1329  // Search first in the list of "standard" objects
1330  TObject *obj = FindObject(name);
1331  if (obj) return obj->ClassName();
1332 
1333  // Is it a global variable?
1334  TGlobal *g = GetGlobal(name);
1335  if (g) return g->GetTypeName();
1336 
1337  return 0;
1338 }
1339 
1340 ////////////////////////////////////////////////////////////////////////////////
1341 /// Return path name of obj somewhere in the //root/... path.
1342 /// The function returns the first occurence of the object in the list
1343 /// of folders. The returned string points to a static char array in TROOT.
1344 /// If this function is called in a loop or recursively, it is the
1345 /// user's responsibility to copy this string in their area.
1346 
1347 const char *TROOT::FindObjectPathName(const TObject *) const
1348 {
1349  Error("FindObjectPathName","Not yet implemented");
1350  return "??";
1351 }
1352 
1353 ////////////////////////////////////////////////////////////////////////////////
1354 /// return a TClass object corresponding to 'name' assuming it is an STL container.
1355 /// In particular we looking for possible alternative name (default template
1356 /// parameter, typedefs template arguments, typedefed name).
1357 
1358 TClass *TROOT::FindSTLClass(const char *name, Bool_t load, Bool_t silent) const
1359 {
1360  // Example of inputs are
1361  // vector<int> (*)
1362  // vector<Int_t>
1363  // vector<long long>
1364  // vector<Long_64_t> (*)
1365  // vector<int, allocator<int> >
1366  // vector<Int_t, allocator<int> >
1367  //
1368  // One of the possibly expensive operation is the resolving of the typedef
1369  // which can provoke the parsing of the header files (and/or the loading
1370  // of clang pcms information).
1371 
1373 
1374  // Remove std::, allocator, typedef, add Long64_t, etc. in just one call.
1375  std::string normalized;
1376  TClassEdit::GetNormalizedName(normalized, name);
1377 
1378  TClass *cl = 0;
1379  if (normalized != name) cl = TClass::GetClass(normalized.c_str(),load,silent);
1380 
1381  if (load && cl==0) {
1382  // Create an Emulated class for this container.
1383  cl = gInterpreter->GenerateTClass(normalized.c_str(), kTRUE, silent);
1384  }
1385 
1386  return cl;
1387 }
1388 
1389 ////////////////////////////////////////////////////////////////////////////////
1390 /// Return pointer to class with name. Obsolete, use TClass::GetClass directly
1391 
1392 TClass *TROOT::GetClass(const char *name, Bool_t load, Bool_t silent) const
1393 {
1394  return TClass::GetClass(name,load,silent);
1395 }
1396 
1397 
1398 ////////////////////////////////////////////////////////////////////////////////
1399 /// Return pointer to class from its name. Obsolete, use TClass::GetClass directly
1400 /// See TClass::GetClass
1401 
1402 TClass *TROOT::GetClass(const std::type_info& typeinfo, Bool_t load, Bool_t silent) const
1403 {
1404  return TClass::GetClass(typeinfo,load,silent);
1405 }
1406 
1407 ////////////////////////////////////////////////////////////////////////////////
1408 /// Return address of color with index color.
1409 
1411 {
1413  TObjArray *lcolors = (TObjArray*) GetListOfColors();
1414  if (!lcolors) return 0;
1415  if (color < 0 || color >= lcolors->GetSize()) return 0;
1416  TColor *col = (TColor*)lcolors->At(color);
1417  if (col && col->GetNumber() == color) return col;
1418  TIter next(lcolors);
1419  while ((col = (TColor *) next()))
1420  if (col->GetNumber() == color) return col;
1421 
1422  return 0;
1423 }
1424 
1425 ////////////////////////////////////////////////////////////////////////////////
1426 /// Return a default canvas.
1427 
1429 {
1430  return (TCanvas*)gROOT->ProcessLine("TCanvas::MakeDefCanvas();");
1431 }
1432 
1433 ////////////////////////////////////////////////////////////////////////////////
1434 /// Return pointer to type with name.
1435 
1436 TDataType *TROOT::GetType(const char *name, Bool_t /* load */) const
1437 {
1438  return (TDataType*)gROOT->GetListOfTypes()->FindObject(name);
1439 }
1440 
1441 ////////////////////////////////////////////////////////////////////////////////
1442 /// Return pointer to file with name.
1443 
1444 TFile *TROOT::GetFile(const char *name) const
1445 {
1446  R__LOCKGUARD(gROOTMutex);
1447  return (TFile*)GetListOfFiles()->FindObject(name);
1448 }
1449 
1450 ////////////////////////////////////////////////////////////////////////////////
1451 /// Return pointer to style with name
1452 
1453 TStyle *TROOT::GetStyle(const char *name) const
1454 {
1455  return (TStyle*)GetListOfStyles()->FindObject(name);
1456 }
1457 
1458 ////////////////////////////////////////////////////////////////////////////////
1459 /// Return pointer to function with name.
1460 
1461 TObject *TROOT::GetFunction(const char *name) const
1462 {
1463  if (name == 0 || name[0] == 0) {
1464  return 0;
1465  }
1466 
1467  {
1468  R__LOCKGUARD2(gROOTMutex);
1469  TObject *f1 = fFunctions->FindObject(name);
1470  if (f1) return f1;
1471  }
1472 
1473  gROOT->ProcessLine("TF1::InitStandardFunctions();");
1474 
1475  R__LOCKGUARD2(gROOTMutex);
1476  return fFunctions->FindObject(name);
1477 }
1478 
1479 ////////////////////////////////////////////////////////////////////////////////
1480 
1482 {
1483  if (!gInterpreter) return 0;
1484 
1486 
1487  return (TFunctionTemplate*)fFuncTemplate->FindObject(name);
1488 }
1489 
1490 ////////////////////////////////////////////////////////////////////////////////
1491 /// Return pointer to global variable by name. If load is true force
1492 /// reading of all currently defined globals from CINT (more expensive).
1493 
1494 TGlobal *TROOT::GetGlobal(const char *name, Bool_t load) const
1495 {
1496  return (TGlobal *)gROOT->GetListOfGlobals(load)->FindObject(name);
1497 }
1498 
1499 ////////////////////////////////////////////////////////////////////////////////
1500 /// Return pointer to global variable with address addr.
1501 
1502 TGlobal *TROOT::GetGlobal(const TObject *addr, Bool_t /* load */) const
1503 {
1504  if (addr == 0 || ((Long_t)addr) == -1) return 0;
1505 
1506  TInterpreter::DeclId_t decl = gInterpreter->GetDataMemberAtAddr(addr);
1507  if (decl) {
1508  TListOfDataMembers *globals = ((TListOfDataMembers*)(gROOT->GetListOfGlobals(kFALSE)));
1509  return (TGlobal*)globals->Get(decl);
1510  }
1511  // If we are actually looking for a global that is held by a global
1512  // pointer (for example gRandom), we need to find a pointer with the
1513  // correct value.
1514  decl = gInterpreter->GetDataMemberWithValue(addr);
1515  if (decl) {
1516  TListOfDataMembers *globals = ((TListOfDataMembers*)(gROOT->GetListOfGlobals(kFALSE)));
1517  return (TGlobal*)globals->Get(decl);
1518  }
1519  return 0;
1520 }
1521 
1522 ////////////////////////////////////////////////////////////////////////////////
1523 /// Internal routine returning, and creating if necessary, the list
1524 /// of global function.
1525 
1527 {
1529  return fGlobalFunctions;
1530 }
1531 
1532 ////////////////////////////////////////////////////////////////////////////////
1533 /// Return the collection of functions named "name".
1534 
1536 {
1537  return ((TListOfFunctions*)fFunctions)->GetListForObject(name);
1538 }
1539 
1540 ////////////////////////////////////////////////////////////////////////////////
1541 /// Return pointer to global function by name.
1542 /// If params != 0 it will also resolve overloading other it returns the first
1543 /// name match.
1544 /// If params == 0 and load is true force reading of all currently defined
1545 /// global functions from Cling.
1546 /// The param string must be of the form: "3189,\"aap\",1.3".
1547 
1548 TFunction *TROOT::GetGlobalFunction(const char *function, const char *params,
1549  Bool_t load)
1550 {
1551  if (!params) {
1552  R__LOCKGUARD2(gROOTMutex);
1553  return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
1554  } else {
1555  if (!fInterpreter)
1556  Fatal("GetGlobalFunction", "fInterpreter not initialized");
1557 
1558  R__LOCKGUARD2(gROOTMutex);
1559  TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithValues(0,
1560  function, params,
1561  false);
1562 
1563  if (!decl) return 0;
1564 
1565  TFunction *f = GetGlobalFunctions()->Get(decl);
1566  if (f) return f;
1567 
1568  Error("GetGlobalFunction",
1569  "\nDid not find matching TFunction <%s> with \"%s\".",
1570  function,params);
1571  return 0;
1572  }
1573 }
1574 
1575 ////////////////////////////////////////////////////////////////////////////////
1576 /// Return pointer to global function by name. If proto != 0
1577 /// it will also resolve overloading. If load is true force reading
1578 /// of all currently defined global functions from CINT (more expensive).
1579 /// The proto string must be of the form: "int, char*, float".
1580 
1582  const char *proto, Bool_t load)
1583 {
1584  if (!proto) {
1585  R__LOCKGUARD2(gROOTMutex);
1586  return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
1587  } else {
1588  if (!fInterpreter)
1589  Fatal("GetGlobalFunctionWithPrototype", "fInterpreter not initialized");
1590 
1591  R__LOCKGUARD2(gROOTMutex);
1592  TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithPrototype(0,
1593  function, proto);
1594 
1595  if (!decl) return 0;
1596 
1597  TFunction *f = GetGlobalFunctions()->Get(decl);
1598  if (f) return f;
1599 
1600  Error("GetGlobalFunctionWithPrototype",
1601  "\nDid not find matching TFunction <%s> with \"%s\".",
1602  function,proto);
1603  return 0;
1604  }
1605 }
1606 
1607 ////////////////////////////////////////////////////////////////////////////////
1608 /// Return pointer to Geometry with name
1609 
1610 TObject *TROOT::GetGeometry(const char *name) const
1611 {
1612  return GetListOfGeometries()->FindObject(name);
1613 }
1614 
1615 ////////////////////////////////////////////////////////////////////////////////
1616 
1618 {
1619  if(!fEnums.load()) {
1620  R__LOCKGUARD2(gROOTMutex);
1621  // Test again just in case, another thread did the work while we were
1622  // waiting.
1623  if (!fEnums.load()) fEnums = new TListOfEnumsWithLock(0);
1624  }
1625  if (load) {
1626  R__LOCKGUARD2(gROOTMutex);
1627  (*fEnums).Load(); // Refresh the list of enums.
1628  }
1629  return fEnums.load();
1630 }
1631 
1632 ////////////////////////////////////////////////////////////////////////////////
1633 
1635 {
1636  R__LOCKGUARD2(gROOTMutex);
1637  if(!fFuncTemplate) {
1639  }
1640  return fFuncTemplate;
1641 }
1642 
1643 ////////////////////////////////////////////////////////////////////////////////
1644 /// Return list containing the TGlobals currently defined.
1645 /// Since globals are created and deleted during execution of the
1646 /// program, we need to update the list of globals every time we
1647 /// execute this method. However, when calling this function in
1648 /// a (tight) loop where no interpreter symbols will be created
1649 /// you can set load=kFALSE (default).
1650 
1652 {
1653  if (!fGlobals) {
1654  // We add to the list the "funcky-fake" globals.
1655  fGlobals = new TListOfDataMembers(0);
1656  fGlobals->Add(new TGlobalMappedFunction("gROOT", "TROOT*",
1658  fGlobals->Add(new TGlobalMappedFunction("gPad", "TVirtualPad*",
1660  fGlobals->Add(new TGlobalMappedFunction("gInterpreter", "TInterpreter*",
1662  fGlobals->Add(new TGlobalMappedFunction("gVirtualX", "TTVirtualX*",
1664  fGlobals->Add(new TGlobalMappedFunction("gDirectory", "TDirectory*",
1666  // Don't let TGlobalMappedFunction delete our globals, now that we take them.
1670  }
1671 
1672  if (!fInterpreter)
1673  Fatal("GetListOfGlobals", "fInterpreter not initialized");
1674 
1675  if (load) fGlobals->Load();
1676 
1677  return fGlobals;
1678 }
1679 
1680 ////////////////////////////////////////////////////////////////////////////////
1681 /// Return list containing the TFunctions currently defined.
1682 /// Since functions are created and deleted during execution of the
1683 /// program, we need to update the list of functions every time we
1684 /// execute this method. However, when calling this function in
1685 /// a (tight) loop where no interpreter symbols will be created
1686 /// you can set load=kFALSE (default).
1687 
1689 {
1690  R__LOCKGUARD2(gROOTMutex);
1691 
1692  if (!fGlobalFunctions) {
1694  }
1695 
1696  if (!fInterpreter)
1697  Fatal("GetListOfGlobalFunctions", "fInterpreter not initialized");
1698 
1699  // A thread that calls with load==true and a thread that calls with load==false
1700  // will conflict here (the load==true will be updating the list while the
1701  // other is reading it). To solve the problem, we could use a read-write lock
1702  // inside the list itself.
1703  if (load) fGlobalFunctions->Load();
1704 
1705  return fGlobalFunctions;
1706 }
1707 
1708 ////////////////////////////////////////////////////////////////////////////////
1709 /// Return a dynamic list giving access to all TDataTypes (typedefs)
1710 /// currently defined.
1711 ///
1712 /// The list is populated on demand. Calling
1713 /// ~~~ {.cpp}
1714 /// gROOT->GetListOfTypes()->FindObject(nameoftype);
1715 /// ~~~
1716 /// will return the TDataType corresponding to 'nameoftype'. If the
1717 /// TDataType is not already in the list itself and the type does exist,
1718 /// a new TDataType will be created and added to the list.
1719 ///
1720 /// Calling
1721 /// ~~~ {.cpp}
1722 /// gROOT->GetListOfTypes()->ls(); // or Print()
1723 /// ~~~
1724 /// list only the typedefs that have been previously accessed through the
1725 /// list (plus the builtins types).
1726 
1728 {
1729  if (!fInterpreter)
1730  Fatal("GetListOfTypes", "fInterpreter not initialized");
1731 
1732  return fTypes;
1733 }
1734 
1735 
1736 ////////////////////////////////////////////////////////////////////////////////
1737 /// Execute command when system has been idle for idleTimeInSec seconds.
1738 
1739 void TROOT::Idle(UInt_t idleTimeInSec, const char *command)
1740 {
1741  if (!fApplication.load())
1743 
1744  if (idleTimeInSec <= 0)
1745  (*fApplication).RemoveIdleTimer();
1746  else
1747  (*fApplication).SetIdleTimer(idleTimeInSec, command);
1748 }
1749 
1750 ////////////////////////////////////////////////////////////////////////////////
1751 /// Check whether className is a known class, and only autoload
1752 /// if we can. Helper function for TROOT::IgnoreInclude().
1753 
1754 static TClass* R__GetClassIfKnown(const char* className)
1755 {
1756  // Check whether the class is available for auto-loading first:
1757  const char* libsToLoad = gInterpreter->GetClassSharedLibs(className);
1758  TClass* cla = 0;
1759  if (libsToLoad) {
1760  // trigger autoload, and only create TClass in this case.
1761  return TClass::GetClass(className);
1762  } else if (gROOT->GetListOfClasses()
1763  && (cla = (TClass*)gROOT->GetListOfClasses()->FindObject(className))) {
1764  // cla assigned in if statement
1765  } else if (gClassTable->FindObject(className)) {
1766  return TClass::GetClass(className);
1767  }
1768  return cla;
1769 }
1770 
1771 ////////////////////////////////////////////////////////////////////////////////
1772 /// Return 1 if the name of the given include file corresponds to a class that
1773 /// is known to ROOT, e.g. "TLorentzVector.h" versus TLorentzVector.
1774 
1775 Int_t TROOT::IgnoreInclude(const char *fname, const char * /*expandedfname*/)
1776 {
1777  if (fname == 0) return 0;
1778 
1779  TString stem(fname);
1780  // Remove extension if any, ignore files with extension not being .h*
1781  Int_t where = stem.Last('.');
1782  if (where != kNPOS) {
1783  if (stem.EndsWith(".so") || stem.EndsWith(".sl") ||
1784  stem.EndsWith(".dl") || stem.EndsWith(".a") ||
1785  stem.EndsWith(".dll", TString::kIgnoreCase))
1786  return 0;
1787  stem.Remove(where);
1788  }
1789 
1790  TString className = gSystem->BaseName(stem);
1791  TClass* cla = R__GetClassIfKnown(className);
1792  if (!cla) {
1793  // Try again with modifications to the file name:
1794  className = stem;
1795  className.ReplaceAll("/", "::");
1796  className.ReplaceAll("\\", "::");
1797  if (className.Contains(":::")) {
1798  // "C:\dir" becomes "C:::dir".
1799  // fname corresponds to whatever is stated after #include and
1800  // a full path name usually means that it's not a regular #include
1801  // but e.g. a ".L", so we can assume that this is not a header of
1802  // a class in a namespace (a global-namespace class would have been
1803  // detected already before).
1804  return 0;
1805  }
1806  cla = R__GetClassIfKnown(className);
1807  }
1808 
1809  if (!cla) {
1810  return 0;
1811  }
1812 
1813  // cla is valid, check wether it's actually in the header of the same name:
1814  if (cla->GetDeclFileLine() <= 0) return 0; // to a void an error with VisualC++
1815  TString decfile = gSystem->BaseName(cla->GetDeclFileName());
1816  if (decfile != gSystem->BaseName(fname)) {
1817  return 0;
1818  }
1819  return 1;
1820 }
1821 
1822 ////////////////////////////////////////////////////////////////////////////////
1823 /// Initialize operating system interface.
1824 
1826 {
1827  if (gSystem == 0) {
1828 #if defined(R__UNIX)
1829 #if defined(R__HAS_COCOA)
1830  gSystem = new TMacOSXSystem;
1831 #else
1832  gSystem = new TUnixSystem;
1833 #endif
1834 #elif defined(R__WIN32)
1835  gSystem = new TWinNTSystem;
1836 #else
1837  gSystem = new TSystem;
1838 #endif
1839 
1840  if (gSystem->Init())
1841  fprintf(stderr, "Fatal in <TROOT::InitSystem>: can't init operating system layer\n");
1842 
1843  if (!gSystem->HomeDirectory()) {
1844  fprintf(stderr, "Fatal in <TROOT::InitSystem>: HOME directory not set\n");
1845  fprintf(stderr, "Fix this by defining the HOME shell variable\n");
1846  }
1847 
1848  // read default files
1849  gEnv = new TEnv(".rootrc");
1850 
1851  gDebug = gEnv->GetValue("Root.Debug", 0);
1852 
1853  if (!gEnv->GetValue("Root.ErrorHandlers", 1))
1854  gSystem->ResetSignals();
1855 
1856  // by default the zipmode is 1 (see Bits.h)
1857  Int_t zipmode = gEnv->GetValue("Root.ZipMode", 1);
1858  if (zipmode != 1) R__SetZipMode(zipmode);
1859 
1860  const char *sdeb;
1861  if ((sdeb = gSystem->Getenv("ROOTDEBUG")))
1862  gDebug = atoi(sdeb);
1863 
1864  if (gDebug > 0 && isatty(2))
1865  fprintf(stderr, "Info in <TROOT::InitSystem>: running with gDebug = %d\n", gDebug);
1866 
1867  if (gEnv->GetValue("Root.MemStat", 0))
1869  int msize = gEnv->GetValue("Root.MemStat.size", -1);
1870  int mcnt = gEnv->GetValue("Root.MemStat.cnt", -1);
1871  if (msize != -1 || mcnt != -1)
1872  TStorage::EnableStatistics(msize, mcnt);
1873 
1874  fgMemCheck = gEnv->GetValue("Root.MemCheck", 0);
1875 
1876 #if defined(R__HAS_COCOA)
1877  // create and delete a dummy TUrl so that TObjectStat table does not contain
1878  // objects that are deleted after recording is turned-off (in next line),
1879  // like the TUrl::fgSpecialProtocols list entries which are created in the
1880  // TMacOSXSystem ctor.
1881  { TUrl dummy("/dummy"); }
1882 #endif
1883  TObject::SetObjectStat(gEnv->GetValue("Root.ObjectStat", 0));
1884  }
1885 }
1886 
1887 ////////////////////////////////////////////////////////////////////////////////
1888 /// Load and initialize thread library.
1889 
1891 {
1892  if (gEnv->GetValue("Root.UseThreads", 0) || gEnv->GetValue("Root.EnableThreadSafety", 0)) {
1894  }
1895 }
1896 
1897 ////////////////////////////////////////////////////////////////////////////////
1898 /// Initialize the interpreter. Should be called only after main(),
1899 /// to make sure LLVM/Clang is fully initialized.
1900 
1902 {
1903  // usedToIdentifyRootClingByDlSym is available when TROOT is part of
1904  // rootcling.
1905  if (!dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")
1906  && !dlsym(RTLD_DEFAULT, "usedToIdentifyStaticRoot")) {
1907  // Make sure no llvm symbols are visible before loading libCling. If they
1908  // exist libCling will use those and not ours, causing havoc in the
1909  // interpreter. Look for an extern "C" symbol to avoid mangling; look for a
1910  // symbol from llvm because clang builds on top, so users would likely
1911  // have also their own llvm symbols when providing their own clang.
1912  void *LLVMEnablePrettyStackTraceAddr = 0;
1913  // Can't use gSystem->DynFindSymbol() because that iterates over all *known*
1914  // libraries which is not the same!
1915  LLVMEnablePrettyStackTraceAddr = dlsym(RTLD_DEFAULT, "LLVMEnablePrettyStackTrace");
1916  if (LLVMEnablePrettyStackTraceAddr) {
1917  Error("InitInterpreter()", "LLVM SYMBOLS ARE EXPOSED TO CLING! "
1918  "This will cause problems; please hide them or dlopen() them "
1919  "after the call to TROOT::InitInterpreter()!");
1920  }
1921 
1922  char *libRIO = gSystem->DynamicPathName("libRIO");
1923  void *libRIOHandle = dlopen(libRIO, RTLD_NOW|RTLD_GLOBAL);
1924  delete [] libRIO;
1925  if (!libRIOHandle) {
1926  TString err = dlerror();
1927  fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load library %s\n", err.Data());
1928  exit(1);
1929  }
1930 
1931  char *libcling = gSystem->DynamicPathName("libCling");
1932  gInterpreterLib = dlopen(libcling, RTLD_LAZY|RTLD_LOCAL);
1933  delete [] libcling;
1934 
1935  if (!gInterpreterLib) {
1936  TString err = dlerror();
1937  fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load library %s\n", err.Data());
1938  exit(1);
1939  }
1940  dlerror(); // reset error message
1941  } else {
1942  gInterpreterLib = RTLD_DEFAULT;
1943  }
1944  CreateInterpreter_t *CreateInterpreter = (CreateInterpreter_t*) dlsym(gInterpreterLib, "CreateInterpreter");
1945  if (!CreateInterpreter) {
1946  TString err = dlerror();
1947  fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load symbol %s\n", err.Data());
1948  exit(1);
1949  }
1950  // Schedule the destruction of TROOT.
1951  atexit(at_exit_of_TROOT);
1952 
1953  gDestroyInterpreter = (DestroyInterpreter_t*) dlsym(gInterpreterLib, "DestroyInterpreter");
1954  if (!gDestroyInterpreter) {
1955  TString err = dlerror();
1956  fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load symbol %s\n", err.Data());
1957  exit(1);
1958  }
1959 
1960  fInterpreter = CreateInterpreter(gInterpreterLib);
1961 
1964 
1965  fgRootInit = kTRUE;
1966 
1967  // Initialize all registered dictionaries.
1968  for (std::vector<ModuleHeaderInfo_t>::const_iterator
1969  li = GetModuleHeaderInfoBuffer().begin(),
1970  le = GetModuleHeaderInfoBuffer().end(); li != le; ++li) {
1971  // process buffered module registrations
1972  fInterpreter->RegisterModule(li->fModuleName,
1973  li->fHeaders,
1974  li->fIncludePaths,
1975  li->fPayloadCode,
1976  li->fFwdDeclCode,
1977  li->fTriggerFunc,
1978  li->fFwdNargsToKeepColl,
1979  li->fClassesHeaders,
1980  kTRUE /*lateRegistration*/);
1981  }
1982  GetModuleHeaderInfoBuffer().clear();
1983 
1985 
1986  // Read the rules before enabling the auto loading to not inadvertently
1987  // load the libraries for the classes concerned even-though the user is
1988  // *not* using them.
1989  TClass::ReadRules(); // Read the default customization rules ...
1990 
1991  // Enable autoloading
1993 }
1994 
1995 ////////////////////////////////////////////////////////////////////////////////
1996 /// Helper function used by TClass::GetClass().
1997 /// This function attempts to load the dictionary for 'classname'
1998 /// either from the TClassTable or from the list of generator.
1999 /// If silent is 'true', do not warn about missing dictionary for the class.
2000 /// (typically used for class that are used only for transient members)
2001 ///
2002 /// The 'requestedname' is expected to be already normalized.
2003 
2004 TClass *TROOT::LoadClass(const char *requestedname, Bool_t silent) const
2005 {
2006  return TClass::LoadClass(requestedname, silent);
2007 }
2008 
2009 ////////////////////////////////////////////////////////////////////////////////
2010 /// Check if class "classname" is known to the interpreter (in fact,
2011 /// this check is not needed anymore, so classname is ignored). If
2012 /// not it will load library "libname". If the library name does
2013 /// not start with "lib", "lib" will be prepended and a search will
2014 /// be made in the DynamicPath (see .rootrc). If not found a search
2015 /// will be made on libname (without "lib" prepended) and if not found
2016 /// a direct try of libname will be made (in case it contained an
2017 /// absolute path).
2018 /// If check is true it will only check if libname exists and is
2019 /// readable.
2020 /// Returns 0 on successful loading, -1 in case libname does not
2021 /// exist or in case of error and -2 in case of version mismatch.
2022 
2023 Int_t TROOT::LoadClass(const char * /*classname*/, const char *libname,
2024  Bool_t check)
2025 {
2026  Int_t err = -1;
2027 
2028  char *path;
2029  TString lib = libname;
2030  if (!lib.BeginsWith("lib"))
2031  lib = "lib" + lib;
2032  if ((path = gSystem->DynamicPathName(lib, kTRUE))) {
2033  if (check)
2034  err = 0;
2035  else {
2036  err = gSystem->Load(path, 0, kTRUE);
2037  }
2038  delete [] path;
2039  } else {
2040  if (check) {
2041  FileStat_t stat;
2042  if (!gSystem->GetPathInfo(libname, stat)) {
2043  if (R_ISREG(stat.fMode) &&
2045  err = 0;
2046  else
2047  err = -1;
2048  } else
2049  err = -1;
2050  } else {
2051  err = gSystem->Load(libname, 0, kTRUE);
2052  }
2053  }
2054 
2055  if (err == -1) {
2056  //Error("LoadClass", "library %s could not be loaded", libname);
2057  }
2058 
2059  if (err == 1) {
2060  //Error("LoadClass", "library %s already loaded, but class %s unknown",
2061  // libname, classname);
2062  err = 0;
2063  }
2064 
2065  return err;
2066 }
2067 
2068 ////////////////////////////////////////////////////////////////////////////////
2069 /// Return true if the file is local and is (likely) to be a ROOT file
2070 
2071 Bool_t TROOT::IsRootFile(const char *filename) const
2072 {
2073  Bool_t result = kFALSE;
2074  FILE *mayberootfile = fopen(filename,"rb");
2075  if (mayberootfile) {
2076  char header[5];
2077  if (fgets(header,5,mayberootfile)) {
2078  result = strncmp(header,"root",4)==0;
2079  }
2080  fclose(mayberootfile);
2081  }
2082  return result;
2083 }
2084 
2085 ////////////////////////////////////////////////////////////////////////////////
2086 /// To list all objects of the application.
2087 /// Loop on all objects created in the ROOT linked lists.
2088 /// Objects may be files and windows or any other object directly
2089 /// attached to the ROOT linked list.
2090 
2091 void TROOT::ls(Option_t *option) const
2092 {
2093 // TObject::SetDirLevel();
2094 // GetList()->R__FOR_EACH(TObject,ls)(option);
2095  TDirectory::ls(option);
2096 }
2097 
2098 ////////////////////////////////////////////////////////////////////////////////
2099 /// Load a macro in the interpreter's memory. Equivalent to the command line
2100 /// command ".L filename". If the filename has "+" or "++" appended
2101 /// the macro will be compiled by ACLiC. The filename must have the format:
2102 /// [path/]macro.C[+|++[g|O]].
2103 /// The possible error codes are defined by TInterpreter::EErrorCode.
2104 /// If check is true it will only check if filename exists and is
2105 /// readable.
2106 /// Returns 0 on successful loading and -1 in case filename does not
2107 /// exist or in case of error.
2108 
2109 Int_t TROOT::LoadMacro(const char *filename, int *error, Bool_t check)
2110 {
2111  Int_t err = -1;
2112  Int_t lerr, *terr;
2113  if (error)
2114  terr = error;
2115  else
2116  terr = &lerr;
2117 
2118  if (fInterpreter) {
2119  TString aclicMode;
2120  TString arguments;
2121  TString io;
2122  TString fname = gSystem->SplitAclicMode(filename, aclicMode, arguments, io);
2123 
2124  if (arguments.Length()) {
2125  Warning("LoadMacro", "argument(%s) ignored in %s", arguments.Data(), GetMacroPath());
2126  }
2127  char *mac = gSystem->Which(GetMacroPath(), fname, kReadPermission);
2128  if (!mac) {
2129  if (!check)
2130  Error("LoadMacro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
2131  *terr = TInterpreter::kFatal;
2132  } else {
2133  err = 0;
2134  if (!check) {
2135  fname = mac;
2136  fname += aclicMode;
2137  fname += io;
2138  gInterpreter->LoadMacro(fname.Data(), (TInterpreter::EErrorCode*)terr);
2139  if (*terr)
2140  err = -1;
2141  }
2142  }
2143  delete [] mac;
2144  }
2145  return err;
2146 }
2147 
2148 ////////////////////////////////////////////////////////////////////////////////
2149 /// Execute a macro in the interpreter. Equivalent to the command line
2150 /// command ".x filename". If the filename has "+" or "++" appended
2151 /// the macro will be compiled by ACLiC. The filename must have the format:
2152 /// [path/]macro.C[+|++[g|O]][(args)].
2153 /// The possible error codes are defined by TInterpreter::EErrorCode.
2154 /// If padUpdate is true (default) update the current pad.
2155 /// Returns the macro return value.
2156 
2157 Long_t TROOT::Macro(const char *filename, Int_t *error, Bool_t padUpdate)
2158 {
2159  Long_t result = 0;
2160 
2161  if (fInterpreter) {
2162  TString aclicMode;
2163  TString arguments;
2164  TString io;
2165  TString fname = gSystem->SplitAclicMode(filename, aclicMode, arguments, io);
2166 
2167  char *mac = gSystem->Which(GetMacroPath(), fname, kReadPermission);
2168  if (!mac) {
2169  Error("Macro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
2170  if (error)
2171  *error = TInterpreter::kFatal;
2172  } else {
2173  fname = mac;
2174  fname += aclicMode;
2175  fname += arguments;
2176  fname += io;
2177  result = gInterpreter->ExecuteMacro(fname, (TInterpreter::EErrorCode*)error);
2178  }
2179  delete [] mac;
2180 
2181  if (padUpdate && gPad)
2182  gPad->Update();
2183  }
2184 
2185  return result;
2186 }
2187 
2188 ////////////////////////////////////////////////////////////////////////////////
2189 /// Process message id called by obj.
2190 
2191 void TROOT::Message(Int_t id, const TObject *obj)
2192 {
2193  TIter next(fMessageHandlers);
2194  TMessageHandler *mh;
2195  while ((mh = (TMessageHandler*)next())) {
2196  mh->HandleMessage(id,obj);
2197  }
2198 }
2199 
2200 ////////////////////////////////////////////////////////////////////////////////
2201 /// Process interpreter command via TApplication::ProcessLine().
2202 /// On Win32 the line will be processed asynchronously by sending
2203 /// it to the CINT interpreter thread. For explicit synchronous processing
2204 /// use ProcessLineSync(). On non-Win32 platforms there is no difference
2205 /// between ProcessLine() and ProcessLineSync().
2206 /// The possible error codes are defined by TInterpreter::EErrorCode. In
2207 /// particular, error will equal to TInterpreter::kProcessing until the
2208 /// CINT interpreted thread has finished executing the line.
2209 /// Returns the result of the command, cast to a Long_t.
2210 
2211 Long_t TROOT::ProcessLine(const char *line, Int_t *error)
2212 {
2213  TString sline = line;
2214  sline = sline.Strip(TString::kBoth);
2215 
2216  if (!fApplication.load())
2218 
2219  return (*fApplication).ProcessLine(sline, kFALSE, error);
2220 }
2221 
2222 ////////////////////////////////////////////////////////////////////////////////
2223 /// Process interpreter command via TApplication::ProcessLine().
2224 /// On Win32 the line will be processed synchronously (i.e. it will
2225 /// only return when the CINT interpreter thread has finished executing
2226 /// the line). On non-Win32 platforms there is no difference between
2227 /// ProcessLine() and ProcessLineSync().
2228 /// The possible error codes are defined by TInterpreter::EErrorCode.
2229 /// Returns the result of the command, cast to a Long_t.
2230 
2232 {
2233  TString sline = line;
2234  sline = sline.Strip(TString::kBoth);
2235 
2236  if (!fApplication.load())
2238 
2239  return (*fApplication).ProcessLine(sline, kTRUE, error);
2240 }
2241 
2242 ////////////////////////////////////////////////////////////////////////////////
2243 /// Process interpreter command directly via CINT interpreter.
2244 /// Only executable statements are allowed (no variable declarations),
2245 /// In all other cases use TROOT::ProcessLine().
2246 /// The possible error codes are defined by TInterpreter::EErrorCode.
2247 
2249 {
2250  TString sline = line;
2251  sline = sline.Strip(TString::kBoth);
2252 
2253  if (!fApplication.load())
2255 
2256  Long_t result = 0;
2257 
2258  if (fInterpreter) {
2260  result = gInterpreter->Calc(sline, code);
2261  }
2262 
2263  return result;
2264 }
2265 
2266 ////////////////////////////////////////////////////////////////////////////////
2267 /// Read Git commit information and branch name from the
2268 /// etc/gitinfo.txt file.
2269 
2271 {
2272 #ifdef ROOT_GIT_COMMIT
2273  fGitCommit = ROOT_GIT_COMMIT;
2274 #endif
2275 #ifdef ROOT_GIT_BRANCH
2276  fGitBranch = ROOT_GIT_BRANCH;
2277 #endif
2278 
2279  TString gitinfo = "gitinfo.txt";
2280  char *filename = gSystem->ConcatFileName(TROOT::GetEtcDir(), gitinfo);
2281 
2282  FILE *fp = fopen(filename, "r");
2283  if (fp) {
2284  TString s;
2285  // read branch name
2286  s.Gets(fp);
2287  fGitBranch = s;
2288  // read commit SHA1
2289  s.Gets(fp);
2290  fGitCommit = s;
2291  // read date/time make was run
2292  s.Gets(fp);
2293  fGitDate = s;
2294  fclose(fp);
2295  }
2296  delete [] filename;
2297 }
2298 
2300  TTHREAD_TLS(Bool_t) fgReadingObject = false;
2301  return fgReadingObject;
2302 }
2303 
2304 ////////////////////////////////////////////////////////////////////////////////
2305 /// Deprecated (will be removed in next release).
2306 
2308 {
2309  return GetReadingObject();
2310 }
2311 
2313 {
2314  GetReadingObject() = flag;
2315 }
2316 
2317 
2318 ////////////////////////////////////////////////////////////////////////////////
2319 /// Return date/time make was run.
2320 
2321 const char *TROOT::GetGitDate()
2322 {
2323  if (fGitDate == "") {
2324  Int_t iday,imonth,iyear, ihour, imin;
2325  static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
2326  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
2327  Int_t idate = gROOT->GetBuiltDate();
2328  Int_t itime = gROOT->GetBuiltTime();
2329  iday = idate%100;
2330  imonth = (idate/100)%100;
2331  iyear = idate/10000;
2332  ihour = itime/100;
2333  imin = itime%100;
2334  fGitDate.Form("%s %02d %4d, %02d:%02d:00", months[imonth-1], iday, iyear, ihour, imin);
2335  }
2336  return fGitDate;
2337 }
2338 
2339 ////////////////////////////////////////////////////////////////////////////////
2340 /// Refresh all browsers. Call this method when some command line
2341 /// command or script has changed the browser contents. Not needed
2342 /// for objects that have the kMustCleanup bit set. Most useful to
2343 /// update browsers that show the file system or other objects external
2344 /// to the running ROOT session.
2345 
2347 {
2348  TIter next(GetListOfBrowsers());
2349  TBrowser *b;
2350  while ((b = (TBrowser*) next()))
2351  b->SetRefreshFlag(kTRUE);
2352 }
2353 ////////////////////////////////////////////////////////////////////////////////
2354 /// Insure that the files, canvases and sockets are closed.
2355 
2356 static void CallCloseFiles()
2357 {
2358  if (TROOT::Initialized() && ROOT::Internal::gROOTLocal) {
2359  gROOT->CloseFiles();
2360  }
2361 }
2362 
2363 ////////////////////////////////////////////////////////////////////////////////
2364 /// Called by static dictionary initialization to register clang modules
2365 /// for headers. Calls TCling::RegisterModule() unless gCling
2366 /// is NULL, i.e. during startup, where the information is buffered in
2367 /// the static GetModuleHeaderInfoBuffer().
2368 
2369 void TROOT::RegisterModule(const char* modulename,
2370  const char** headers,
2371  const char** includePaths,
2372  const char* payloadCode,
2373  const char* fwdDeclCode,
2374  void (*triggerFunc)(),
2375  const TInterpreter::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
2376  const char** classesHeaders)
2377 {
2378 
2379  // First a side track to insure proper end of process behavior.
2380 
2381  // Register for each loaded dictionary (and thus for each library),
2382  // that we need to Close the ROOT files as soon as this library
2383  // might start being unloaded after main.
2384  //
2385  // By calling atexit here (rather than directly from within the
2386  // library) we make sure that this is not called if the library is
2387  // 'only' dlclosed.
2388 
2389  // On Ubuntu the linker strips the unused libraries. Eventhough
2390  // stressHistogram is explicitly linked against libNet, it is not
2391  // retained and thus is loaded only as needed in the middle part of
2392  // the execution. Concretely this also means that it is loaded
2393  // *after* the construction of the TApplication object and thus
2394  // after the registration (atexit) of the EndOfProcessCleanups
2395  // routine. Consequently, after the end of main, libNet is
2396  // unloaded before EndOfProcessCleanups is called. When
2397  // EndOfProcessCleanups is executed it indirectly needs the TClass
2398  // for TSocket and its search will use resources that have already
2399  // been unloaded (technically the function static in TUnixSystem's
2400  // DynamicPath and the dictionary from libNet).
2401 
2402  // Similarly, the ordering (before this commit) was broken in the
2403  // following case:
2404 
2405  // TApplication creation (EndOfProcessCleanups registration)
2406  // load UserLibrary
2407  // create TFile
2408  // Append UserObject to TFile
2409 
2410  // and after the end of main the order of execution was
2411 
2412  // unload UserLibrary
2413  // call EndOfProcessCleanups
2414  // Write the TFile
2415  // attempt to write the user object.
2416  // ....
2417 
2418  // where what we need is to have the files closen/written before
2419  // the unloading of the library.
2420 
2421  // To solve the problem we now register an atexit function for
2422  // every dictionary thus making sure there is at least one executed
2423  // before the first library tear down after main.
2424 
2425  // If atexit is called directly within a library's code, the
2426  // function will called *either* when the library is 'dlclose'd or
2427  // after then end of main (whichever comes first). We do *not*
2428  // want the files to be closed whenever a library is unloaded via
2429  // dlclose. To avoid this, we add the function (CallCloseFiles)
2430  // from the dictionary indirectly (via ROOT::RegisterModule). In
2431  // this case the function will only only be called either when
2432  // libCore is 'dlclose'd or right after the end of main.
2433 
2434  atexit(CallCloseFiles);
2435 
2436  // Now register with TCling.
2437  if (gCling) {
2438  gCling->RegisterModule(modulename, headers, includePaths, payloadCode, fwdDeclCode,
2439  triggerFunc, fwdDeclsArgToSkip, classesHeaders);
2440  } else {
2441  GetModuleHeaderInfoBuffer()
2442  .push_back(ModuleHeaderInfo_t (modulename, headers, includePaths, payloadCode, fwdDeclCode,
2443  triggerFunc, fwdDeclsArgToSkip,classesHeaders));
2444  }
2445 }
2446 
2447 ////////////////////////////////////////////////////////////////////////////////
2448 /// Remove a class from the list and map of classes.
2449 /// This routine is deprecated, use TClass::RemoveClass directly.
2450 
2452 {
2453  TClass::RemoveClass(oldcl);
2454 }
2455 
2456 ////////////////////////////////////////////////////////////////////////////////
2457 /// Delete all global interpreter objects created since the last call to Reset
2458 ///
2459 /// If option="a" is set reset to startup context (i.e. unload also
2460 /// all loaded files, classes, structs, typedefs, etc.).
2461 ///
2462 /// This function is typically used at the beginning (or end) of an unnamed macro
2463 /// to clean the environment.
2464 ///
2465 /// IMPORTANT WARNING:
2466 /// Do not use this call from within any function (neither compiled nor
2467 /// interpreted. This should only be used from a unnamed macro
2468 /// (which starts with a { (curly braces) ). For example, using TROOT::Reset
2469 /// from within an interpreted function will lead to the unloading of the
2470 /// dictionary and source file, including the one defining the function being
2471 /// executed.
2472 ///
2473 
2474 void TROOT::Reset(Option_t *option)
2475 {
2476  if (IsExecutingMacro()) return; //True when TMacro::Exec runs
2477  if (fInterpreter) {
2478  if (!strncmp(option, "a", 1)) {
2479  fInterpreter->Reset();
2481  } else
2482  gInterpreter->ResetGlobals();
2483 
2484  if (fGlobals) fGlobals->Unload();
2486 
2487  SaveContext();
2488  }
2489 }
2490 
2491 ////////////////////////////////////////////////////////////////////////////////
2492 /// Save the current interpreter context.
2493 
2495 {
2496  if (fInterpreter)
2497  gInterpreter->SaveGlobalsContext();
2498 }
2499 
2500 ////////////////////////////////////////////////////////////////////////////////
2501 /// Set the default graphical cut class name for the graphics editor
2502 /// By default the graphics editor creates an instance of a class TCutG.
2503 /// This function may be called to specify a different class that MUST
2504 /// derive from TCutG
2505 
2506 void TROOT::SetCutClassName(const char *name)
2507 {
2508  if (!name) {
2509  Error("SetCutClassName","Invalid class name");
2510  return;
2511  }
2512  TClass *cl = TClass::GetClass(name);
2513  if (!cl) {
2514  Error("SetCutClassName","Unknown class:%s",name);
2515  return;
2516  }
2517  if (!cl->InheritsFrom("TCutG")) {
2518  Error("SetCutClassName","Class:%s does not derive from TCutG",name);
2519  return;
2520  }
2521  fCutClassName = name;
2522 }
2523 
2524 ////////////////////////////////////////////////////////////////////////////////
2525 /// Set editor mode
2526 
2527 void TROOT::SetEditorMode(const char *mode)
2528 {
2529  fEditorMode = 0;
2530  if (!mode[0]) return;
2531  if (!strcmp(mode,"Arc")) {fEditorMode = kArc; return;}
2532  if (!strcmp(mode,"Line")) {fEditorMode = kLine; return;}
2533  if (!strcmp(mode,"Arrow")) {fEditorMode = kArrow; return;}
2534  if (!strcmp(mode,"Button")) {fEditorMode = kButton; return;}
2535  if (!strcmp(mode,"Diamond")) {fEditorMode = kDiamond; return;}
2536  if (!strcmp(mode,"Ellipse")) {fEditorMode = kEllipse; return;}
2537  if (!strcmp(mode,"Pad")) {fEditorMode = kPad; return;}
2538  if (!strcmp(mode,"Pave")) {fEditorMode = kPave; return;}
2539  if (!strcmp(mode,"PaveLabel")){fEditorMode = kPaveLabel; return;}
2540  if (!strcmp(mode,"PaveText")) {fEditorMode = kPaveText; return;}
2541  if (!strcmp(mode,"PavesText")){fEditorMode = kPavesText; return;}
2542  if (!strcmp(mode,"PolyLine")) {fEditorMode = kPolyLine; return;}
2543  if (!strcmp(mode,"CurlyLine")){fEditorMode = kCurlyLine; return;}
2544  if (!strcmp(mode,"CurlyArc")) {fEditorMode = kCurlyArc; return;}
2545  if (!strcmp(mode,"Text")) {fEditorMode = kText; return;}
2546  if (!strcmp(mode,"Marker")) {fEditorMode = kMarker; return;}
2547  if (!strcmp(mode,"CutG")) {fEditorMode = kCutG; return;}
2548 }
2549 
2550 ////////////////////////////////////////////////////////////////////////////////
2551 /// Change current style to style with name stylename
2552 
2553 void TROOT::SetStyle(const char *stylename)
2554 {
2555  TString style_name = stylename;
2556 
2557  TStyle *style = GetStyle(style_name);
2558  if (style) style->cd();
2559  else Error("SetStyle","Unknown style:%s",style_name.Data());
2560 }
2561 
2562 
2563 //-------- Static Member Functions ---------------------------------------------
2564 
2565 
2566 ////////////////////////////////////////////////////////////////////////////////
2567 /// Decrease the indentation level for ls().
2568 
2570 {
2571  return --fgDirLevel;
2572 }
2573 
2574 ////////////////////////////////////////////////////////////////////////////////
2575 ///return directory level
2576 
2578 {
2579  return fgDirLevel;
2580 }
2581 
2582 ////////////////////////////////////////////////////////////////////////////////
2583 /// Get macro search path. Static utility function.
2584 
2585 const char *TROOT::GetMacroPath()
2586 {
2587  TString &macroPath = ROOT::GetMacroPath();
2588 
2589  if (macroPath.Length() == 0) {
2590  macroPath = gEnv->GetValue("Root.MacroPath", (char*)0);
2591 #if defined(R__WIN32)
2592  macroPath.ReplaceAll("; ", ";");
2593 #else
2594  macroPath.ReplaceAll(": ", ":");
2595 #endif
2596  if (macroPath.Length() == 0)
2597 #if !defined(R__WIN32)
2598  macroPath = ".:" + TROOT::GetMacroDir();
2599 #else
2600  macroPath = ".;" + TROOT::GetMacroDir();
2601 #endif
2602  }
2603 
2604  return macroPath;
2605 }
2606 
2607 ////////////////////////////////////////////////////////////////////////////////
2608 /// Set or extend the macro search path. Static utility function.
2609 /// If newpath=0 or "" reset to value specified in the rootrc file.
2610 
2611 void TROOT::SetMacroPath(const char *newpath)
2612 {
2613  TString &macroPath = ROOT::GetMacroPath();
2614 
2615  if (!newpath || !*newpath)
2616  macroPath = "";
2617  else
2618  macroPath = newpath;
2619 }
2620 
2621 ////////////////////////////////////////////////////////////////////////////////
2622 /// Increase the indentation level for ls().
2623 
2625 {
2626  return ++fgDirLevel;
2627 }
2628 
2629 ////////////////////////////////////////////////////////////////////////////////
2630 /// Functions used by ls() to indent an object hierarchy.
2631 
2633 {
2634  for (int i = 0; i < fgDirLevel; i++) std::cout.put(' ');
2635 }
2636 
2637 ////////////////////////////////////////////////////////////////////////////////
2638 /// Return kTRUE if the TROOT object has been initialized.
2639 
2641 {
2642  return fgRootInit;
2643 }
2644 
2645 ////////////////////////////////////////////////////////////////////////////////
2646 /// Return kTRUE if the memory leak checker is on.
2647 
2649 {
2650  return fgMemCheck;
2651 }
2652 
2653 ////////////////////////////////////////////////////////////////////////////////
2654 /// Return Indentation level for ls().
2655 
2657 {
2658  fgDirLevel = level;
2659 }
2660 
2661 ////////////////////////////////////////////////////////////////////////////////
2662 /// Convert version code to an integer, i.e. 331527 -> 51507.
2663 
2665 {
2666  return 10000*(code>>16) + 100*((code&65280)>>8) + (code&255);
2667 }
2668 
2669 ////////////////////////////////////////////////////////////////////////////////
2670 /// Convert version as an integer to version code as used in RVersion.h.
2671 
2673 {
2674  int a = v/10000;
2675  int b = (v - a*10000)/100;
2676  int c = v - a*10000 - b*100;
2677  return (a << 16) + (b << 8) + c;
2678 }
2679 
2680 ////////////////////////////////////////////////////////////////////////////////
2681 /// Return ROOT version code as defined in RVersion.h.
2682 
2684 {
2685  return ROOT_VERSION_CODE;
2686 }
2687 
2688 ////////////////////////////////////////////////////////////////////////////////
2689 
2691  static const char** extraInterpArgs = 0;
2692  return extraInterpArgs;
2693 }
2694 
2695 ////////////////////////////////////////////////////////////////////////////////
2696 
2697 #ifdef ROOTPREFIX
2698 static Bool_t IgnorePrefix() {
2699  static Bool_t ignorePrefix = gSystem->Getenv("ROOTIGNOREPREFIX");
2700  return ignorePrefix;
2701 }
2702 #endif
2703 
2704 ////////////////////////////////////////////////////////////////////////////////
2705 /// Get the rootsys directory in the installation. Static utility function.
2706 
2707 const TString& TROOT::GetRootSys() {
2708 #ifdef ROOTPREFIX
2709  if (IgnorePrefix()) {
2710 #endif
2711  static TString rootsys;
2712  if (rootsys.IsNull())
2713  rootsys = gSystem->Getenv("ROOTSYS");
2714  if (rootsys.IsNull())
2715  rootsys = gRootDir;
2716  return rootsys;
2717 #ifdef ROOTPREFIX
2718  } else {
2719  const static TString rootsys = ROOTPREFIX;
2720  return rootsys;
2721  }
2722 #endif
2723 }
2724 
2725 ////////////////////////////////////////////////////////////////////////////////
2726 /// Get the binary directory in the installation. Static utility function.
2727 
2728 const TString& TROOT::GetBinDir() {
2729 #ifdef ROOTBINDIR
2730  if (IgnorePrefix()) {
2731 #endif
2732  static TString rootbindir;
2733  if (rootbindir.IsNull()) {
2734  rootbindir = "bin";
2735  gSystem->PrependPathName(GetRootSys(), rootbindir);
2736  }
2737  return rootbindir;
2738 #ifdef ROOTBINDIR
2739  } else {
2740  const static TString rootbindir = ROOTBINDIR;
2741  return rootbindir;
2742  }
2743 #endif
2744 }
2745 
2746 ////////////////////////////////////////////////////////////////////////////////
2747 /// Get the library directory in the installation. Static utility function.
2748 
2749 const TString& TROOT::GetLibDir() {
2750 #ifdef ROOTLIBDIR
2751  if (IgnorePrefix()) {
2752 #endif
2753  static TString rootlibdir;
2754  if (rootlibdir.IsNull()) {
2755  rootlibdir = "lib";
2756  gSystem->PrependPathName(GetRootSys(), rootlibdir);
2757  }
2758  return rootlibdir;
2759 #ifdef ROOTLIBDIR
2760  } else {
2761  const static TString rootlibdir = ROOTLIBDIR;
2762  return rootlibdir;
2763  }
2764 #endif
2765 }
2766 
2767 ////////////////////////////////////////////////////////////////////////////////
2768 /// Get the include directory in the installation. Static utility function.
2769 
2770 const TString& TROOT::GetIncludeDir() {
2771 #ifdef ROOTINCDIR
2772  if (IgnorePrefix()) {
2773 #endif
2774  static TString rootincdir;
2775  if (rootincdir.IsNull()) {
2776  rootincdir = "include";
2777  gSystem->PrependPathName(GetRootSys(), rootincdir);
2778  }
2779  return rootincdir;
2780 #ifdef ROOTINCDIR
2781  } else {
2782  const static TString rootincdir = ROOTINCDIR;
2783  return rootincdir;
2784  }
2785 #endif
2786 }
2787 
2788 ////////////////////////////////////////////////////////////////////////////////
2789 /// Get the sysconfig directory in the installation. Static utility function.
2790 
2791 const TString& TROOT::GetEtcDir() {
2792 #ifdef ROOTETCDIR
2793  if (IgnorePrefix()) {
2794 #endif
2795  static TString rootetcdir;
2796  if (rootetcdir.IsNull()) {
2797  rootetcdir = "etc";
2798  gSystem->PrependPathName(GetRootSys(), rootetcdir);
2799  }
2800  return rootetcdir;
2801 #ifdef ROOTETCDIR
2802  } else {
2803  const static TString rootetcdir = ROOTETCDIR;
2804  return rootetcdir;
2805  }
2806 #endif
2807 }
2808 
2809 ////////////////////////////////////////////////////////////////////////////////
2810 /// Get the data directory in the installation. Static utility function.
2811 
2812 const TString& TROOT::GetDataDir() {
2813 #ifdef ROOTDATADIR
2814  if (IgnorePrefix()) {
2815 #endif
2816  return GetRootSys();
2817 #ifdef ROOTDATADIR
2818  } else {
2819  const static TString rootdatadir = ROOTDATADIR;
2820  return rootdatadir;
2821  }
2822 #endif
2823 }
2824 
2825 ////////////////////////////////////////////////////////////////////////////////
2826 /// Get the documentation directory in the installation. Static utility function.
2827 
2828 const TString& TROOT::GetDocDir() {
2829 #ifdef ROOTDOCDIR
2830  if (IgnorePrefix()) {
2831 #endif
2832  return GetRootSys();
2833 #ifdef ROOTDOCDIR
2834  } else {
2835  const static TString rootdocdir = ROOTDOCDIR;
2836  return rootdocdir;
2837  }
2838 #endif
2839 }
2840 
2841 ////////////////////////////////////////////////////////////////////////////////
2842 /// Get the macro directory in the installation. Static utility function.
2843 
2844 const TString& TROOT::GetMacroDir() {
2845 #ifdef ROOTMACRODIR
2846  if (IgnorePrefix()) {
2847 #endif
2848  static TString rootmacrodir;
2849  if (rootmacrodir.IsNull()) {
2850  rootmacrodir = "macros";
2851  gSystem->PrependPathName(GetRootSys(), rootmacrodir);
2852  }
2853  return rootmacrodir;
2854 #ifdef ROOTMACRODIR
2855  } else {
2856  const static TString rootmacrodir = ROOTMACRODIR;
2857  return rootmacrodir;
2858  }
2859 #endif
2860 }
2861 
2862 ////////////////////////////////////////////////////////////////////////////////
2863 /// Get the tutorials directory in the installation. Static utility function.
2864 
2865 const TString& TROOT::GetTutorialDir() {
2866 #ifdef ROOTTUTDIR
2867  if (IgnorePrefix()) {
2868 #endif
2869  static TString roottutdir;
2870  if (roottutdir.IsNull()) {
2871  roottutdir = "tutorials";
2872  gSystem->PrependPathName(GetRootSys(), roottutdir);
2873  }
2874  return roottutdir;
2875 #ifdef ROOTTUTDIR
2876  } else {
2877  const static TString roottutdir = ROOTTUTDIR;
2878  return roottutdir;
2879  }
2880 #endif
2881 }
2882 
2883 ////////////////////////////////////////////////////////////////////////////////
2884 /// Get the source directory in the installation. Static utility function.
2885 
2886 const TString& TROOT::GetSourceDir() {
2887 #ifdef ROOTSRCDIR
2888  if (IgnorePrefix()) {
2889 #endif
2890  static TString rootsrcdir;
2891  if (rootsrcdir.IsNull()) {
2892  rootsrcdir = "src";
2893  gSystem->PrependPathName(GetRootSys(), rootsrcdir);
2894  }
2895  return rootsrcdir;
2896 #ifdef ROOTSRCDIR
2897  } else {
2898  const static TString rootsrcdir = ROOTSRCDIR;
2899  return rootsrcdir;
2900  }
2901 #endif
2902 }
2903 
2904 ////////////////////////////////////////////////////////////////////////////////
2905 /// Get the icon path in the installation. Static utility function.
2906 
2907 const TString& TROOT::GetIconPath() {
2908 #ifdef ROOTICONPATH
2909  if (IgnorePrefix()) {
2910 #endif
2911  static TString rooticonpath;
2912  if (rooticonpath.IsNull()) {
2913  rooticonpath = "icons";
2914  gSystem->PrependPathName(GetRootSys(), rooticonpath);
2915  }
2916  return rooticonpath;
2917 #ifdef ROOTICONPATH
2918  } else {
2919  const static TString rooticonpath = ROOTICONPATH;
2920  return rooticonpath;
2921  }
2922 #endif
2923 }
2924 
2925 ////////////////////////////////////////////////////////////////////////////////
2926 /// Get the fonts directory in the installation. Static utility function.
2927 
2928 const TString& TROOT::GetTTFFontDir() {
2929 #ifdef TTFFONTDIR
2930  if (IgnorePrefix()) {
2931 #endif
2932  static TString ttffontdir;
2933  if (ttffontdir.IsNull()) {
2934  ttffontdir = "fonts";
2935  gSystem->PrependPathName(GetRootSys(), ttffontdir);
2936  }
2937  return ttffontdir;
2938 #ifdef TTFFONTDIR
2939  } else {
2940  const static TString ttffontdir = TTFFONTDIR;
2941  return ttffontdir;
2942  }
2943 #endif
2944 }
2945 
2946 ////////////////////////////////////////////////////////////////////////////////
2947 /// Get the tutorials directory in the installation. Static utility function.
2948 /// Backward compatibility function - do not use for new code
2949 
2950 const char *TROOT::GetTutorialsDir() {
2951  return GetTutorialDir();
2952 }
TSeqCollection * fStreamerInfo
Definition: TROOT.h:164
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:261
const char * FindObjectPathName(const TObject *obj) const
Return path name of obj somewhere in the //root/...
Definition: TROOT.cxx:1347
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:931
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:1272
Bool_t fExecutingMacro
Definition: TROOT.h:141
void AddClass(TClass *cl)
Add a class to the list and map of classes.
Definition: TROOT.cxx:977
virtual void RegisterModule(const char *, const char **, const char **, const char *, const char *, void(*)(), const FwdDeclArgsToKeepCollection_t &fwdDeclArgsToKeep, const char **classesHeaders, Bool_t lateRegistration=false)=0
virtual void Add(TObject *obj)
TListOfFunctionTemplates * fFuncTemplate
Definition: TROOT.h:147
object has not been deleted
Definition: TObject.h:71
UInt_t GetImplicitMTPoolSize()
Returns the size of the pool used for implicit multi-threading.
Definition: TROOT.cxx:567
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition: TROOT.cxx:2928
TInterpreter * CreateInterpreter_t(void *shlibHandle)
Definition: TInterpreter.h:495
A TFolder object is a collection of objects and folders.
Definition: TFolder.h:30
TCanvas * MakeDefCanvas() const
Return a default canvas.
Definition: TROOT.cxx:1428
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition: TGuiFactory.h:67
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:58
An array of TObjects.
Definition: TObjArray.h:37
virtual void Clear(Option_t *option="")=0
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2569
static Bool_t BlockAllSignals(Bool_t b)
Block or unblock all signals. Returns the previous block status.
Definition: TQObject.cxx:1055
TFolder * fRootFolder
Definition: TROOT.h:172
TCollection * GetListOfEnums(Bool_t load=kFALSE)
Definition: TROOT.cxx:1617
ROOT top level object description.
Definition: TROOT.h:100
static const TString & GetMacroDir()
Get the macro directory in the installation. Static utility function.
Definition: TROOT.cxx:2844
void * DestroyInterpreter_t(TInterpreter *)
Definition: TInterpreter.h:496
This class is a specialized TProcessID managing the list of UUIDs.
Definition: TProcessUUID.h:32
TSeqCollection * fProofs
Definition: TROOT.h:167
static const TString & GetTutorialDir()
Get the tutorials directory in the installation. Static utility function.
Definition: TROOT.cxx:2865
const char * GetDeclFileName() const
Definition: TClass.h:376
void RemoveClass(TClass *)
Remove a class from the list and map of classes.
Definition: TROOT.cxx:2451
TCollection * GetListOfGlobalFunctions(Bool_t load=kFALSE)
Return list containing the TFunctions currently defined.
Definition: TROOT.cxx:1688
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:868
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:2109
virtual void Build(TFile *motherFile=0, TDirectory *motherDir=0)
Initialise directory to defaults.
Definition: TDirectory.cxx:200
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
static const char **& GetExtraInterpreterArgs()
Definition: TROOT.cxx:2690
TLine * line
TSeqCollection * fGeometries
Definition: TROOT.h:159
R__EXTERN TClassTable * gClassTable
Definition: TClassTable.h:93
Handle messages that might be generated by the system.
TDictionary::DeclId_t DeclId_t
Definition: TInterpreter.h:233
const char Option_t
Definition: RtypesCore.h:62
Dictionary for function template This class describes one single function template.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form: ~~~ {.cpp} [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)]...
Definition: TSystem.cxx:4071
void DisableImplicitMT()
Disables the implicit multi-threading in ROOT (see EnableImplicitMT).
Definition: TROOT.cxx:539
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...
Short_t GetDeclFileLine() const
Definition: TClass.h:377
#define ROOT_RELEASE_TIME
Definition: RVersion.h:19
TList * fList
Definition: TDirectory.h:89
static const TString & GetIconPath()
Get the icon path in the installation. Static utility function.
Definition: TROOT.cxx:2907
R__EXTERN TVirtualMutex * gInterpreterMutex
Definition: TInterpreter.h:40
const Ssiz_t kNPOS
Definition: RtypesCore.h:115
This class represents a WWW compatible URL.
Definition: TUrl.h:35
Int_t fVersionDate
Definition: TROOT.h:123
Definition: Buttons.h:33
R__EXTERN TStyle * gStyle
Definition: TStyle.h:402
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:1370
Bool_t fForceStyle
Definition: TROOT.h:138
virtual void HandleMessage(Int_t id, const TObject *obj)
Store message origin, keep statistics and call Notify().
Bool_t ReadingObject() const
Deprecated (will be removed in next release).
Definition: TROOT.cxx:2307
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:159
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:2683
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
static Bool_t MemCheck()
Return kTRUE if the memory leak checker is on.
Definition: TROOT.cxx:2648
TString fVersion
Definition: TROOT.h:120
void R__SetZipMode(int)
virtual const char * HomeDirectory(const char *userName=0)
Return the user&#39;s home directory.
Definition: TSystem.cxx:884
#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:954
This class implements a mutex interface.
Definition: TVirtualMutex.h:32
void DisableParTreeProcessing()
Globally disables the IMT use case of parallel branch processing, deactivating the corresponding lock...
Definition: TROOT.cxx:458
void InitInterpreter()
Initialize the interpreter.
Definition: TROOT.cxx:1901
#define gROOT
Definition: TROOT.h:375
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:1825
The TEnv class reads config files, by default named .rootrc.
Definition: TEnv.h:124
void RefreshBrowsers()
Refresh all browsers.
Definition: TROOT.cxx:2346
static Func_t GetSymInLibImt(const char *funcname)
Definition: TROOT.cxx:374
TString & GetMacroPath()
Definition: TROOT.cxx:491
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
Definition: TInterpreter.h:105
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition: TROOT.cxx:2707
#define gInterpreter
Definition: TInterpreter.h:499
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition: TSystem.cxx:1518
Int_t fVersionCode
Definition: TROOT.h:122
Option_t * GetOption() const
Definition: TCollection.h:155
void Reset(Option_t *option="")
Delete all global interpreter objects created since the last call to Reset.
Definition: TROOT.cxx:2474
Definition: Buttons.h:30
void Load()
Load all the DataMembers known to the interpreter for the scope &#39;fClass&#39; into this collection...
TFunction * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
This class registers for all classes their name, id and dictionary function in a hash table...
Definition: TClassTable.h:36
STL namespace.
#define ROOT_VERSION_CODE
Definition: RVersion.h:21
#define NULL
Definition: RtypesCore.h:88
virtual TObject * FindObjectAny(const char *name) const
Return a pointer to the first object with name starting at this folder.
Definition: TFolder.cxx:352
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
virtual void ResetSignals()
Reset signals handlers to previous behaviour.
Definition: TSystem.cxx:591
std::atomic< TApplication * > fApplication
Definition: TROOT.h:131
void SetStyle(const char *stylename="Default")
Change current style to style with name stylename.
Definition: TROOT.cxx:2553
TDataType * GetType(const char *name, Bool_t load=kFALSE) const
Return pointer to type with name.
Definition: TROOT.cxx:1436
TCollection * GetListOfGlobals(Bool_t load=kFALSE)
Return list containing the TGlobals currently defined.
Definition: TROOT.cxx:1651
TString fGitCommit
Definition: TROOT.h:127
TStyle * GetStyle(const char *name) const
Return pointer to style with name.
Definition: TROOT.cxx:1453
void ls(Option_t *option="") const
To list all objects of the application.
Definition: TROOT.cxx:2091
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
Definition: TROOT.cxx:2770
TROOT * GetROOT1()
Definition: TROOT.cxx:353
Bool_t R_ISREG(Int_t mode)
Definition: TSystem.h:119
virtual void AddLast(TObject *obj)
Add object at the end of the list.
Definition: TList.cxx:141
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:687
TString fCutClassName
Definition: TROOT.h:175
Bool_t & GetReadingObject()
Definition: TROOT.cxx:2299
static const char * GetTutorialsDir()
Get the tutorials directory in the installation.
Definition: TROOT.cxx:2950
TListOfFunctions * GetGlobalFunctions()
Internal routine returning, and creating if necessary, the list of global function.
Definition: TROOT.cxx:1526
static Int_t fgDirLevel
Definition: TROOT.h:108
Definition: Buttons.h:30
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition: TROOT.cxx:2585
TInterpreter * fInterpreter
Definition: TROOT.h:132
Int_t fMode
Definition: TSystem.h:128
static TList & GetEarlyRegisteredGlobals()
Definition: TGlobal.cxx:171
const char * GetGitDate()
Return date/time make was run.
Definition: TROOT.cxx:2321
virtual void cd()
Change current style.
Definition: TStyle.cxx:306
AListOfEnums_t fEnums
Definition: TROOT.h:170
TObject * GetFunction(const char *name) const
Return pointer to function with name.
Definition: TROOT.cxx:1461
TSeqCollection * fMappedFiles
Definition: TROOT.h:152
virtual void Delete(Option_t *option="")=0
Delete this object.
#define SafeDelete(p)
Definition: RConfig.h:499
Sequenceable collection abstract base class.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:135
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:35
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Definition: TVirtualPad.cxx:32
Int_t fVersionInt
Definition: TROOT.h:121
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
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:2527
static Int_t ReadRules()
Read the class.rules files from the default location:.
Definition: TClass.cxx:1732
TSeqCollection * fCleanups
Definition: TROOT.h:162
Int_t fEditorMode
Definition: TROOT.h:142
Bool_t fMustClean
Definition: TROOT.h:136
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition: TROOT.cxx:2640
void EndOfProcessCleanups()
Execute the cleanups necessary at the end of the process, in particular those that must be executed b...
Definition: TROOT.cxx:1139
static Bool_t fgRootInit
Definition: TROOT.h:109
virtual TObject * FindObjectAny(const char *name) const
Return a pointer to the first object with name starting at //root.
Definition: TROOT.cxx:1300
Long_t ProcessLineSync(const char *line, Int_t *error=0)
Process interpreter command via TApplication::ProcessLine().
Definition: TROOT.cxx:2231
void Message(Int_t id, const TObject *obj)
Process message id called by obj.
Definition: TROOT.cxx:2191
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:1634
static const TString & GetDocDir()
Get the documentation directory in the installation. Static utility function.
Definition: TROOT.cxx:2828
TCollection * GetListOfFunctionTemplates()
Definition: TROOT.cxx:1634
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition: TSystem.cxx:1061
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:2494
virtual void Close(Option_t *option="")
Delete all objects from memory and directory structure itself.
Definition: TDirectory.cxx:519
ClassInfo_t * GetClassInfo() const
Definition: TClass.h:381
virtual void Delete(Option_t *option="")
Delete all TFunction object files.
TCollection * GetListOfFunctionOverloads(const char *name) const
Return the collection of functions named "name".
Definition: TROOT.cxx:1535
static void at_exit_of_TROOT()
Definition: TROOT.cxx:271
TSeqCollection * fClipboard
Definition: TROOT.h:168
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:49
R__EXTERN TGuiFactory * gGuiFactory
Definition: TGuiFactory.h:66
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:140
TSeqCollection * fFiles
Definition: TROOT.h:151
TSeqCollection * GetListOfGeometries() const
Definition: TROOT.h:248
Describes an Operating System directory for the browser.
virtual TObject * FindObject(const char *name) const
Specialize FindObject to do search for the a function just by name or create it if its not already in...
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT&#39;s implicit multi-threading for all objects and methods that provide an internal paralleli...
Definition: TROOT.cxx:525
TCollection * fClasses
Definition: TROOT.h:145
A doubly linked list.
Definition: TList.h:43
Long_t Macro(const char *filename, Int_t *error=0, Bool_t padUpdate=kTRUE)
Execute a macro in the interpreter.
Definition: TROOT.cxx:2157
R__EXTERN TVirtualMutex * gGlobalMutex
Definition: TVirtualMutex.h:27
TStyle objects may be created to define special styles.
Definition: TStyle.h:27
R__EXTERN TROOT * gROOTLocal
Definition: TROOT.h:372
Bool_t fEditHistograms
Definition: TROOT.h:134
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
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:1015
Int_t fVersionTime
Definition: TROOT.h:124
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:2369
R__EXTERN TVirtualX * gGXBatch
Definition: TVirtualX.h:353
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:1392
static Bool_t fgMemCheck
Definition: TROOT.h:110
Bool_t IsParBranchProcessingEnabled()
Returns true if parallel branch processing is enabled.
Definition: TROOT.cxx:422
TSeqCollection * fDataSets
Definition: TROOT.h:169
Definition: Buttons.h:33
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:328
TSeqCollection * fMessageHandlers
Definition: TROOT.h:163
void Browse(TBrowser *b)
Add browsable objects to TBrowser.
Definition: TROOT.cxx:996
virtual Bool_t Init()
Initialize the OS interface.
Definition: TSystem.cxx:189
void AddClassGenerator(TClassGenerator *gen)
Add a class generator.
Definition: TROOT.cxx:987
TString fDefCanvasName
Definition: TROOT.h:176
R__EXTERN TSystem * gSystem
Definition: TSystem.h:539
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:2506
TGlobal * GetGlobal(const char *name, Bool_t load=kFALSE) const
Return pointer to global variable by name.
Definition: TROOT.cxx:1494
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:65
Basic data type descriptor (datatype information is obtained from CINT).
Definition: TDataType.h:44
Int_t gDebug
Definition: TROOT.cxx:588
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:482
TPluginManager * fPluginManager
Definition: TROOT.h:174
TString fGitBranch
Definition: TROOT.h:128
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:436
TSeqCollection * fSecContexts
Definition: TROOT.h:166
Collection abstract base class.
Definition: TCollection.h:42
void(* VoidFuncPtr_t)()
Definition: Rtypes.h:69
void SetRefreshFlag(Bool_t flag)
Definition: TBrowser.h:97
static Int_t ConvertVersionCode2Int(Int_t code)
Convert version code to an integer, i.e. 331527 -> 51507.
Definition: TROOT.cxx:2664
unsigned int UInt_t
Definition: RtypesCore.h:42
void ReadGitInfo()
Read Git commit information and branch name from the etc/gitinfo.txt file.
Definition: TROOT.cxx:2270
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
virtual TObject * FindObject(const char *name) const
Returns address of a ROOT object if it exists.
Definition: TROOT.cxx:1187
TObject * GetGeometry(const char *name) const
Return pointer to Geometry with name.
Definition: TROOT.cxx:1610
static void EnableStatistics(int size=-1, int ix=-1)
Enable memory usage statistics gathering.
Definition: TStorage.cxx:450
This class implements a plugin library manager.
static const TString & GetSourceDir()
Get the source directory in the installation. Static utility function.
Definition: TROOT.cxx:2886
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:2023
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:2632
static TProcessID * AddProcessID()
Static function to add a new TProcessID to the list of PIDs.
Definition: TProcessID.cxx:100
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
TFile * GetFile() const
Definition: TROOT.h:264
virtual void SaveContext()=0
Global variables class (global variables are obtained from CINT).
Definition: TGlobal.h:27
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition: TClass.cxx:4602
A collection of TDataType designed to hold the typedef information and numerical type information...
Definition: TListOfTypes.h:30
void SetName(const char *name)
Definition: TCollection.h:111
TROOT * GetROOT()
Definition: TROOT.cxx:487
void Warning(const char *location, const char *msgfmt,...)
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:2071
static TInterpreter * Instance()
returns gInterpreter global
void InitSystem()
Initialize operating system interface.
Definition: TROOT.cxx:1825
if object destructor must call RecursiveRemove()
Definition: TObject.h:59
#define gVirtualX
Definition: TVirtualX.h:350
TSeqCollection * fSpecials
Definition: TROOT.h:161
virtual TObjLink * FirstLink() const
Definition: TList.h:97
#define R__LOCKGUARD2(mutex)
const Bool_t kFALSE
Definition: RtypesCore.h:92
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
TString fGitDate
Definition: TROOT.h:129
static void SetDirLevel(Int_t level=0)
Return Indentation level for ls().
Definition: TROOT.cxx:2656
long Long_t
Definition: RtypesCore.h:50
The Canvas class.
Definition: TCanvas.h:31
Bool_t IsExecutingMacro() const
Definition: TROOT.h:283
TSeqCollection * GetListOfColors() const
Definition: TROOT.h:236
TListOfFunctions * fGlobalFunctions
Definition: TROOT.h:149
Long_t ProcessLine(const char *line, Int_t *error=0)
Process interpreter command via TApplication::ProcessLine().
Definition: TROOT.cxx:2211
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
TSeqCollection * fCanvases
Definition: TROOT.h:154
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...
virtual const char * GetTypeName() const
Get type of global variable, e,g.
Definition: TGlobal.cxx:111
#define ClassImp(name)
Definition: Rtypes.h:336
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:1581
static DestroyInterpreter_t * gDestroyInterpreter
Definition: TROOT.cxx:155
void SetReadingObject(Bool_t flag=kTRUE)
Definition: TROOT.cxx:2312
virtual Func_t DynFindSymbol(const char *module, const char *entry)
Find specific entry point in specified library.
Definition: TSystem.cxx:1977
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Definition: TSystem.cxx:1953
TString fConfigOptions
Definition: TROOT.h:118
void InitThreads()
Load and initialize thread library.
Definition: TROOT.cxx:1890
void Unload()
Mark &#39;all func&#39; as being unloaded.
Describe directory structure in memory.
Definition: TDirectory.h:34
static TDirectory *& CurrentDirectory()
Return the current directory for the current thread.
Definition: TDirectory.cxx:318
R__EXTERN TEnv * gEnv
Definition: TEnv.h:170
TSeqCollection * GetListOfStyles() const
Definition: TROOT.h:245
static void AddClass(TClass *cl)
static: Add a class to the list and map of classes.
Definition: TClass.cxx:461
TSeqCollection * GetListOfFiles() const
Definition: TROOT.h:241
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition: TROOT.cxx:2791
Definition: Buttons.h:31
Bool_t fFromPopUp
Definition: TROOT.h:135
static RooMathCoreReg dummy
Int_t fTimer
Definition: TROOT.h:130
TCanvas * style()
Definition: style.C:1
static void CallCloseFiles()
Insure that the files, canvases and sockets are closed.
Definition: TROOT.cxx:2356
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:133
Long_t ProcessLineFast(const char *line, Int_t *error=0)
Process interpreter command directly via CINT interpreter.
Definition: TROOT.cxx:2248
void CloseFiles()
Close any files and sockets that gROOT knows about.
Definition: TROOT.cxx:1061
virtual ~TROOT()
Clean up and free resources used by ROOT (files, network sockets, shared memory segments, etc.).
Definition: TROOT.cxx:852
#define R__LOCKGUARD(mutex)
The color creation and management class.
Definition: TColor.h:19
TSeqCollection * fStyles
Definition: TROOT.h:155
virtual void Add(TObject *obj)=0
virtual void CleanCompiledMacros()
Remove the shared libs produced by the CompileMacro() function.
Definition: TSystem.cxx:4156
Bool_t fReadingObject
Definition: TROOT.h:137
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:2885
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:353
TCollection * fClassGenerators
Definition: TROOT.h:165
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:1775
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Definition: TClass.cxx:5393
virtual void Reset()=0
virtual void Delete(Option_t *option="")
Delete all TDataMember object files.
static Int_t GetDirLevel()
return directory level
Definition: TROOT.cxx:2577
Int_t fBuiltTime
Definition: TROOT.h:126
Mother of all ROOT objects.
Definition: TObject.h:37
Global functions class (global functions are obtained from CINT).
Definition: TFunction.h:28
This ABC is a factory for GUI components.
Definition: TGuiFactory.h:42
TFunction * GetGlobalFunction(const char *name, const char *params=0, Bool_t load=kFALSE)
Return pointer to global function by name.
Definition: TROOT.cxx:1548
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
Definition: TROOT.h:192
static Int_t ConvertVersionInt2Code(Int_t v)
Convert version as an integer to version code as used in RVersion.h.
Definition: TROOT.cxx:2672
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2624
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:1727
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
Definition: TROOT.cxx:2812
Int_t fBuiltDate
Definition: TROOT.h:125
void Unload()
Mark &#39;all func&#39; as being unloaded.
TFunctionTemplate * GetFunctionTemplate(const char *name)
Definition: TROOT.cxx:1481
TColor * GetColor(Int_t color) const
Return address of color with index color.
Definition: TROOT.cxx:1410
void Load()
Load all the functions known to the interpreter for the scope &#39;fClass&#39; into this collection.
TCollection * fFunctions
Definition: TROOT.h:156
const char * FindObjectClassName(const char *name) const
Returns class name of a ROOT object including CINT globals.
Definition: TROOT.cxx:1327
static void SetMacroPath(const char *newpath)
Set or extend the macro search path.
Definition: TROOT.cxx:2611
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:77
TListOfDataMembers * fGlobals
Definition: TROOT.h:148
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Definition: TROOT.cxx:2749
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
Definition: TROOT.cxx:552
R__EXTERN const char * gRootDir
Definition: TSystem.h:223
virtual void ls(Option_t *option="") const
List Directory contents.
TSeqCollection * fClosedObjects
Definition: TROOT.h:150
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:1358
#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:106
TSeqCollection * fTasks
Definition: TROOT.h:157
static void CleanUpROOTAtExit()
Clean up at program termination before global objects go out of scope.
Definition: TROOT.cxx:209
TSeqCollection * fColors
Definition: TROOT.h:158
Int_t GetNumber() const
Definition: TColor.h:54
TCollection * fTypes
Definition: TROOT.h:146
#define gPad
Definition: TVirtualPad.h:284
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
const char * proto
Definition: civetweb.c:11652
TSeqCollection * fBrowsers
Definition: TROOT.h:160
static GetROOTFun_t gGetROOT
Definition: TROOT.cxx:372
#define gDirectory
Definition: TDirectory.h:211
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition: TColor.cxx:1049
virtual TObject * FindObjectAnyFile(const char *name) const
Scan the memory lists of all files for an object with name.
Definition: TROOT.cxx:1310
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2728
double result[121]
TList * fBrowsables
Definition: TROOT.h:173
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TSeqCollection * fSockets
Definition: TROOT.h:153
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:901
TObject * FindSpecialObject(const char *name, void *&where)
Returns address and folder of a ROOT object if it exists.
Definition: TROOT.cxx:1241
R__EXTERN TInterpreter * gCling
Definition: TInterpreter.h:501
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:364
virtual Int_t GetSize() const
Definition: TCollection.h:89
Bool_t fInterrupt
Definition: TROOT.h:139
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:248
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:1739
void *(* GlobalFunc_t)()
Definition: TGlobal.h:54
TSeqCollection * GetListOfBrowsers() const
Definition: TROOT.h:249
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1051
#define sym(otri1, otri2)
Definition: triangle.c:932
static TClass * R__GetClassIfKnown(const char *className)
Check whether className is a known class, and only autoload if we can.
Definition: TROOT.cxx:1754
TString fConfigFeatures
Definition: TROOT.h:119
TProcessUUID * fUUIDs
Definition: TROOT.h:171
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:406
const TObject * fPrimitive
Definition: TROOT.h:143
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:859
TVirtualPad * fSelectPad
Definition: TROOT.h:144
virtual TObject * First() const =0
virtual TObject * Last() const =0
TDictionary * Get(DeclId_t id)
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
TROOT()
Default ctor.
Definition: TROOT.cxx:596