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