Logo ROOT  
Reference Guide
TROOT.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Rene Brun 08/12/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TROOT
13\ingroup Base
14
15ROOT top level object description.
16
17The TROOT object is the entry point to the ROOT system.
18The single instance of TROOT is accessible via the global gROOT.
19Using the gROOT pointer one has access to basically every object
20created in a ROOT based program. The TROOT object is essentially a
21container of several lists pointing to the main ROOT objects.
22
23The 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
45The 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
49The ROOT object must be created as a static object. An example
50of 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 <ROOT/RConfig.hxx>
71#include "RConfigure.h"
72#include "RConfigOptions.h"
73#include "RVersion.h"
74#include "RGitCommit.h"
75#include <string>
76#include <map>
77#include <cstdlib>
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)
86char *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}
93FARPROC dlsym(void *library, const char *function_name)
94{
95 HMODULE hMods[1024];
96 DWORD cbNeeded;
97 FARPROC address = NULL;
98 unsigned int i;
99 if (library == RTLD_DEFAULT) {
100 if (EnumProcessModules(::GetCurrentProcess(), hMods, sizeof(hMods), &cbNeeded)) {
101 for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
102 address = ::GetProcAddress((HMODULE)hMods[i], function_name);
103 if (address)
104 return address;
105 }
106 }
107 return address;
108 } else {
109 return ::GetProcAddress((HMODULE)library, function_name);
110 }
111}
112#else
113#include <dlfcn.h>
114#endif
115
116#include <iostream>
118#include "TROOT.h"
119#include "TClass.h"
120#include "TClassEdit.h"
121#include "TClassGenerator.h"
122#include "TDataType.h"
123#include "TStyle.h"
124#include "TObjectTable.h"
125#include "TClassTable.h"
126#include "TSystem.h"
127#include "THashList.h"
128#include "TObjArray.h"
129#include "TEnv.h"
130#include "TError.h"
131#include "TColor.h"
132#include "TGlobal.h"
133#include "TFunction.h"
134#include "TVirtualPad.h"
135#include "TBrowser.h"
136#include "TSystemDirectory.h"
137#include "TApplication.h"
138#include "TInterpreter.h"
139#include "TGuiFactory.h"
140#include "TMessageHandler.h"
141#include "TFolder.h"
142#include "TQObject.h"
143#include "TProcessUUID.h"
144#include "TPluginManager.h"
145#include "TVirtualMutex.h"
146#include "TListOfTypes.h"
147#include "TListOfDataMembers.h"
148#include "TListOfEnumsWithLock.h"
149#include "TListOfFunctions.h"
151#include "TFunctionTemplate.h"
152#include "ThreadLocalStorage.h"
153#include "TVirtualRWMutex.h"
154#include "TVirtualX.h"
155
156#if defined(R__UNIX)
157#if defined(R__HAS_COCOA)
158#include "TMacOSXSystem.h"
159#include "TUrl.h"
160#else
161#include "TUnixSystem.h"
162#endif
163#elif defined(R__WIN32)
164#include "TWinNTSystem.h"
165#endif
166
167extern "C" void R__SetZipMode(int);
168
170static void *gInterpreterLib = nullptr;
171
172// Mutex for protection of concurrent gROOT access
175
176// For accessing TThread::Tsd indirectly.
177void **(*gThreadTsd)(void*,Int_t) = nullptr;
178
179//-------- Names of next three routines are a small homage to CMZ --------------
180////////////////////////////////////////////////////////////////////////////////
181/// Return version id as an integer, i.e. "2.22/04" -> 22204.
182
183static Int_t IVERSQ()
184{
185 Int_t maj, min, cycle;
186 sscanf(ROOT_RELEASE, "%d.%d/%d", &maj, &min, &cycle);
187 return 10000*maj + 100*min + cycle;
188}
189
190////////////////////////////////////////////////////////////////////////////////
191/// Return built date as integer, i.e. "Apr 28 2000" -> 20000428.
192
193static Int_t IDATQQ(const char *date)
194{
195 static const char *months[] = {"Jan","Feb","Mar","Apr","May",
196 "Jun","Jul","Aug","Sep","Oct",
197 "Nov","Dec"};
198
199 char sm[12];
200 Int_t yy, mm=0, dd;
201 sscanf(date, "%s %d %d", sm, &dd, &yy);
202 for (int i = 0; i < 12; i++)
203 if (!strncmp(sm, months[i], 3)) {
204 mm = i+1;
205 break;
206 }
207 return 10000*yy + 100*mm + dd;
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Return built time as integer (with min precision), i.e.
212/// "17:32:37" -> 1732.
213
214static Int_t ITIMQQ(const char *time)
215{
216 Int_t hh, mm, ss;
217 sscanf(time, "%d:%d:%d", &hh, &mm, &ss);
218 return 100*hh + mm;
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Clean up at program termination before global objects go out of scope.
223
224static void CleanUpROOTAtExit()
225{
226 if (gROOT) {
228
229 if (gROOT->GetListOfFiles())
230 gROOT->GetListOfFiles()->Delete("slow");
231 if (gROOT->GetListOfSockets())
232 gROOT->GetListOfSockets()->Delete();
233 if (gROOT->GetListOfMappedFiles())
234 gROOT->GetListOfMappedFiles()->Delete("slow");
235 if (gROOT->GetListOfClosedObjects())
236 gROOT->GetListOfClosedObjects()->Delete("slow");
237 }
238}
239
240////////////////////////////////////////////////////////////////////////////////
241/// A module and its headers. Intentionally not a copy:
242/// If these strings end up in this struct they are
243/// long lived by definition because they get passed in
244/// before initialization of TCling.
245
246namespace {
247 struct ModuleHeaderInfo_t {
248 ModuleHeaderInfo_t(const char* moduleName,
249 const char** headers,
250 const char** includePaths,
251 const char* payloadCode,
252 const char* fwdDeclCode,
253 void (*triggerFunc)(),
254 const TROOT::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
255 const char **classesHeaders,
256 bool hasCxxModule):
257 fModuleName(moduleName),
258 fHeaders(headers),
259 fPayloadCode(payloadCode),
260 fFwdDeclCode(fwdDeclCode),
261 fIncludePaths(includePaths),
262 fTriggerFunc(triggerFunc),
263 fClassesHeaders(classesHeaders),
264 fFwdNargsToKeepColl(fwdDeclsArgToSkip),
265 fHasCxxModule(hasCxxModule) {}
266
267 const char* fModuleName; // module name
268 const char** fHeaders; // 0-terminated array of header files
269 const char* fPayloadCode; // Additional code to be given to cling at library load
270 const char* fFwdDeclCode; // Additional code to let cling know about selected classes and functions
271 const char** fIncludePaths; // 0-terminated array of header files
272 void (*fTriggerFunc)(); // Pointer to the dict initialization used to find the library name
273 const char** fClassesHeaders; // 0-terminated list of classes and related header files
274 const TROOT::FwdDeclArgsToKeepCollection_t fFwdNargsToKeepColl; // Collection of
275 // pairs of template fwd decls and number of
276 bool fHasCxxModule; // Whether this module has a C++ module alongside it.
277 };
278
279 std::vector<ModuleHeaderInfo_t>& GetModuleHeaderInfoBuffer() {
280 static std::vector<ModuleHeaderInfo_t> moduleHeaderInfoBuffer;
281 return moduleHeaderInfoBuffer;
282 }
283}
284
287
288static void at_exit_of_TROOT() {
291}
292
293// This local static object initializes the ROOT system
294namespace ROOT {
295namespace Internal {
297 // Simple wrapper to separate, time-wise, the call to the
298 // TROOT destructor and the actual free-ing of the memory.
299 //
300 // Since the interpreter implementation (currently TCling) is
301 // loaded via dlopen by libCore, the destruction of its global
302 // variable (i.e. in particular clang's) is scheduled before
303 // those in libCore so we need to schedule the call to the TROOT
304 // destructor before that *but* we want to make sure the memory
305 // stay around until libCore itself is unloaded so that code
306 // using gROOT can 'properly' check for validity.
307 //
308 // The order of loading for is:
309 // libCore.so
310 // libRint.so
311 // ... anything other library hard linked to the executable ...
312 // ... for example libEvent
313 // libCling.so
314 // ... other libraries like libTree for example ....
315 // and the destruction order is (of course) the reverse.
316 // By default the unloading of the dictionary, does use
317 // the service of the interpreter ... which of course
318 // fails if libCling is already unloaded by that information
319 // has not been registered per se.
320 //
321 // To solve this problem, we now schedule the destruction
322 // of the TROOT object to happen _just_ before the
323 // unloading/destruction of libCling so that we can
324 // maximize the amount of clean-up we can do correctly
325 // and we can still allocate the TROOT object's memory
326 // statically.
327 //
328 union {
330 char fHolder[sizeof(TROOT)];
331 };
332 public:
333 TROOTAllocator(): fObj("root", "The ROOT of EVERYTHING")
334 {}
335
337 if (gROOTLocal) {
339 }
340 }
341 };
342
343 // The global gROOT is defined to be a function (ROOT::GetROOT())
344 // which itself is dereferencing a function pointer.
345
346 // Initially this function pointer's value is & GetROOT1 whose role is to
347 // create and initialize the TROOT object itself.
348 // At the very end of the TROOT constructor the value of the function pointer
349 // is switch to & GetROOT2 whose role is to initialize the interpreter.
350
351 // This mechanism was primarily intended to fix the issues with order in which
352 // global TROOT and LLVM globals are initialized. TROOT was initializing
353 // Cling, but Cling could not be used yet due to LLVM globals not being
354 // Initialized yet. The solution is to delay initializing the interpreter in
355 // TROOT till after main() when all LLVM globals are initialized.
356
357 // Technically, the mechanism used actually delay the interpreter
358 // initialization until the first use of gROOT *after* the end of the
359 // TROOT constructor.
360
361 // So to delay until after the start of main, we also made sure that none
362 // of the ROOT code (mostly the dictionary code) used during library loading
363 // is using gROOT (directly or indirectly).
364
365 // In practice, the initialization of the interpreter is now delayed until
366 // the first use gROOT (or gInterpreter) after the start of main (but user
367 // could easily break this by using gROOT in their library initialization
368 // code).
369
370 extern TROOT *gROOTLocal;
371
373 if (gROOTLocal)
374 return gROOTLocal;
375 static TROOTAllocator alloc;
376 return gROOTLocal;
377 }
378
380 static Bool_t initInterpreter = kFALSE;
381 if (!initInterpreter) {
382 initInterpreter = kTRUE;
384 // Load and init threads library
386 }
387 return gROOTLocal;
388 }
389 typedef TROOT *(*GetROOTFun_t)();
390
392
393 static Func_t GetSymInLibImt(const char *funcname)
394 {
395 const static bool loadSuccess = dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")? false : 0 <= gSystem->Load("libImt");
396 if (loadSuccess) {
397 if (auto sym = gSystem->DynFindSymbol(nullptr, funcname)) {
398 return sym;
399 } else {
400 Error("GetSymInLibImt", "Cannot get symbol %s.", funcname);
401 }
402 }
403 return nullptr;
404 }
405
406 //////////////////////////////////////////////////////////////////////////////
407 /// Globally enables the parallel branch processing, which is a case of
408 /// implicit multi-threading (IMT) in ROOT, activating the required locks.
409 /// This IMT use case, implemented in TTree::GetEntry, spawns a task for
410 /// each branch of the tree. Therefore, a task takes care of the reading,
411 /// decompression and deserialisation of a given branch.
413 {
414#ifdef R__USE_IMT
415 static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableParBranchProcessing");
416 if (sym)
417 sym();
418#else
419 ::Warning("EnableParBranchProcessing", "Cannot enable parallel branch processing, please build ROOT with -Dimt=ON");
420#endif
421 }
422
423 //////////////////////////////////////////////////////////////////////////////
424 /// Globally disables the IMT use case of parallel branch processing,
425 /// deactivating the corresponding locks.
427 {
428#ifdef R__USE_IMT
429 static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_DisableParBranchProcessing");
430 if (sym)
431 sym();
432#else
433 ::Warning("DisableParBranchProcessing", "Cannot disable parallel branch processing, please build ROOT with -Dimt=ON");
434#endif
435 }
436
437 //////////////////////////////////////////////////////////////////////////////
438 /// Returns true if parallel branch processing is enabled.
440 {
441#ifdef R__USE_IMT
442 static Bool_t (*sym)() = (Bool_t(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_IsParBranchProcessingEnabled");
443 if (sym)
444 return sym();
445 else
446 return kFALSE;
447#else
448 return kFALSE;
449#endif
450 }
451
452 ////////////////////////////////////////////////////////////////////////////////
453 /// Keeps track of the status of ImplicitMT w/o resorting to the load of
454 /// libImt
456 {
457 static Bool_t isImplicitMTEnabled = kFALSE;
458 return isImplicitMTEnabled;
459 }
460
461} // end of Internal sub namespace
462// back to ROOT namespace
463
465 return (*Internal::gGetROOT)();
466 }
467
469 static TString macroPath;
470 return macroPath;
471 }
472
473 // clang-format off
474 ////////////////////////////////////////////////////////////////////////////////
475 /// Enables the global mutex to make ROOT thread safe/aware.
476 ///
477 /// The following becomes safe:
478 /// - concurrent construction and destruction of TObjects, including the ones registered in ROOT's global lists (e.g. gROOT->GetListOfCleanups(), gROOT->GetListOfFiles())
479 /// - concurrent usage of _different_ ROOT objects from different threads, including ones with global state (e.g. TFile, TTree, TChain) with the exception of graphics classes (e.g. TCanvas)
480 /// - concurrent calls to ROOT's type system classes, e.g. TClass and TEnum
481 /// - concurrent calls to the interpreter through gInterpreter
482 /// - concurrent loading of ROOT plug-ins
483 ///
484 /// In addition, gDirectory, gFile and gPad become a thread-local variable.
485 /// In all threads, gDirectory defaults to gROOT, a singleton which supports thread-safe insertion and deletion of contents.
486 /// gFile and gPad default to nullptr, as it is for single-thread programs.
487 ///
488 /// The ROOT graphics subsystem is not made thread-safe by this method. In particular drawing or printing different
489 /// canvases from different threads (and analogous operations such as invoking `Draw` on a `TObject`) is not thread-safe.
490 ///
491 /// Note that there is no `DisableThreadSafety()`. ROOT's thread-safety features cannot be disabled once activated.
492 // clang-format on
494 {
495 static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TThread_Initialize");
496 if (sym)
497 sym();
498 }
499
500 ////////////////////////////////////////////////////////////////////////////////
501 /// @param[in] numthreads Number of threads to use. If not specified or
502 /// set to zero, the number of threads is automatically
503 /// decided by the implementation. Any other value is
504 /// used as a hint.
505 ///
506 /// ROOT must be built with the compilation flag `imt=ON` for this feature to be available.
507 /// The following objects and methods automatically take advantage of
508 /// multi-threading if a call to `EnableImplicitMT` has been made before usage:
509 ///
510 /// - RDataFrame internally runs the event-loop by parallelizing over clusters of entries
511 /// - TTree::GetEntry reads multiple branches in parallel
512 /// - TTree::FlushBaskets writes multiple baskets to disk in parallel
513 /// - TTreeCacheUnzip decompresses the baskets contained in a TTreeCache in parallel
514 /// - THx::Fit performs in parallel the evaluation of the objective function over the data
515 /// - TMVA::DNN trains the deep neural networks in parallel
516 /// - TMVA::BDT trains the classifier in parallel and multiclass BDTs are evaluated in parallel
517 ///
518 /// EnableImplicitMT calls in turn EnableThreadSafety.
519 /// The 'numthreads' parameter allows to control the number of threads to
520 /// be used by the implicit multi-threading. However, this parameter is just
521 /// a hint for ROOT: it will try to satisfy the request if the execution
522 /// scenario allows it. For example, if ROOT is configured to use an external
523 /// scheduler, setting a value for 'numthreads' might not have any effect.
524 void EnableImplicitMT(UInt_t numthreads)
525 {
526#ifdef R__USE_IMT
528 return;
530 static void (*sym)(UInt_t) = (void(*)(UInt_t))Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableImplicitMT");
531 if (sym)
532 sym(numthreads);
534#else
535 ::Warning("EnableImplicitMT", "Cannot enable implicit multi-threading with %d threads, please build ROOT with -Dimt=ON", numthreads);
536#endif
537 }
538
539 ////////////////////////////////////////////////////////////////////////////////
540 /// Disables the implicit multi-threading in ROOT (see EnableImplicitMT).
542 {
543#ifdef R__USE_IMT
544 static void (*sym)() = (void(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_DisableImplicitMT");
545 if (sym)
546 sym();
548#else
549 ::Warning("DisableImplicitMT", "Cannot disable implicit multi-threading, please build ROOT with -Dimt=ON");
550#endif
551 }
552
553 ////////////////////////////////////////////////////////////////////////////////
554 /// Returns true if the implicit multi-threading in ROOT is enabled.
556 {
558 }
559
560 ////////////////////////////////////////////////////////////////////////////////
561 /// Returns the size of ROOT's thread pool
563 {
564#ifdef R__USE_IMT
565 static UInt_t (*sym)() = (UInt_t(*)())Internal::GetSymInLibImt("ROOT_MT_GetThreadPoolSize");
566 if (sym)
567 return sym();
568 else
569 return 0;
570#else
571 return 0;
572#endif
573 }
574
575 ////////////////////////////////////////////////////////////////////////////////
576 /// Returns the size of the pool used for implicit multi-threading.
578 {
579 return GetThreadPoolSize();
580 }
581} // end of ROOT namespace
582
584
585// Global debug flag (set to > 0 to get debug output).
586// Can be set either via the interpreter (gDebug is exported to CINT),
587// via the rootrc resource "Root.Debug", via the shell environment variable
588// ROOTDEBUG, or via the debugger.
590
591
593
594////////////////////////////////////////////////////////////////////////////////
595/// Default ctor.
596
598 fLineIsProcessing(0), fVersion(0), fVersionInt(0), fVersionCode(0),
599 fVersionDate(0), fVersionTime(0), fBuiltDate(0), fBuiltTime(0),
600 fTimer(0), fApplication(nullptr), fInterpreter(nullptr), fBatch(kTRUE),
601 fIsWebDisplay(kFALSE), fIsWebDisplayBatch(kFALSE), fEditHistograms(kTRUE),
602 fFromPopUp(kTRUE),fMustClean(kTRUE),fForceStyle(kFALSE),
603 fInterrupt(kFALSE),fEscape(kFALSE),fExecutingMacro(kFALSE),fEditorMode(0),
604 fPrimitive(nullptr),fSelectPad(nullptr),fClasses(nullptr),fTypes(nullptr),fGlobals(nullptr),fGlobalFunctions(nullptr),
605 fClosedObjects(nullptr),fFiles(nullptr),fMappedFiles(nullptr),fSockets(nullptr),fCanvases(nullptr),fStyles(nullptr),fFunctions(nullptr),
606 fTasks(nullptr),fColors(nullptr),fGeometries(nullptr),fBrowsers(nullptr),fSpecials(nullptr),fCleanups(nullptr),
607 fMessageHandlers(nullptr),fStreamerInfo(nullptr),fClassGenerators(nullptr),fSecContexts(nullptr),
608 fProofs(nullptr),fClipboard(nullptr),fDataSets(nullptr),fUUIDs(nullptr),fRootFolder(nullptr),fBrowsables(nullptr),
609 fPluginManager(nullptr)
610{
611}
612
613////////////////////////////////////////////////////////////////////////////////
614/// Initialize the ROOT system. The creation of the TROOT object initializes
615/// the ROOT system. It must be the first ROOT related action that is
616/// performed by a program. The TROOT object must be created on the stack
617/// (can not be called via new since "operator new" is protected). The
618/// TROOT object is either created as a global object (outside the main()
619/// program), or it is one of the first objects created in main().
620/// Make sure that the TROOT object stays in scope for as long as ROOT
621/// related actions are performed. TROOT is a so called singleton so
622/// only one instance of it can be created. The single TROOT object can
623/// always be accessed via the global pointer gROOT.
624/// The name and title arguments can be used to identify the running
625/// application. The initfunc argument can contain an array of
626/// function pointers (last element must be 0). These functions are
627/// executed at the end of the constructor. This way one can easily
628/// extend the ROOT system without adding permanent dependencies
629/// (e.g. the graphics system is initialized via such a function).
630
631TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc)
632 : TDirectory(), fLineIsProcessing(0), fVersion(0), fVersionInt(0), fVersionCode(0),
633 fVersionDate(0), fVersionTime(0), fBuiltDate(0), fBuiltTime(0),
634 fTimer(0), fApplication(nullptr), fInterpreter(nullptr), fBatch(kTRUE),
635 fIsWebDisplay(kFALSE), fIsWebDisplayBatch(kFALSE), fEditHistograms(kTRUE),
636 fFromPopUp(kTRUE),fMustClean(kTRUE),fForceStyle(kFALSE),
637 fInterrupt(kFALSE),fEscape(kFALSE),fExecutingMacro(kFALSE),fEditorMode(0),
638 fPrimitive(nullptr),fSelectPad(nullptr),fClasses(nullptr),fTypes(nullptr),fGlobals(nullptr),fGlobalFunctions(nullptr),
639 fClosedObjects(nullptr),fFiles(nullptr),fMappedFiles(nullptr),fSockets(nullptr),fCanvases(nullptr),fStyles(nullptr),fFunctions(nullptr),
640 fTasks(nullptr),fColors(nullptr),fGeometries(nullptr),fBrowsers(nullptr),fSpecials(nullptr),fCleanups(nullptr),
641 fMessageHandlers(nullptr),fStreamerInfo(nullptr),fClassGenerators(nullptr),fSecContexts(nullptr),
642 fProofs(nullptr),fClipboard(nullptr),fDataSets(nullptr),fUUIDs(nullptr),fRootFolder(nullptr),fBrowsables(nullptr),
643 fPluginManager(nullptr)
644{
646 //Warning("TROOT", "only one instance of TROOT allowed");
647 return;
648 }
649
651
653 gDirectory = nullptr;
654
655 SetName(name);
656 SetTitle(title);
657
658 // will be used by global "operator delete" so make sure it is set
659 // before anything is deleted
660 fMappedFiles = nullptr;
661
662 // create already here, but only initialize it after gEnv has been created
664
665 // Initialize Operating System interface
666 InitSystem();
667
668 // Initialize static directory functions
669 GetRootSys();
670 GetBinDir();
671 GetLibDir();
673 GetEtcDir();
674 GetDataDir();
675 GetDocDir();
676 GetMacroDir();
678 GetSourceDir();
679 GetIconPath();
681
683
684 TDirectory::BuildDirectory(nullptr, nullptr);
685
686 // Initialize interface to CINT C++ interpreter
687 fVersionInt = 0; // check in TROOT dtor in case TCling fails
688 fClasses = nullptr; // might be checked via TCling ctor
689 fEnums = nullptr;
690
691 fConfigOptions = R__CONFIGUREOPTIONS;
692 fConfigFeatures = R__CONFIGUREFEATURES;
698 fBuiltDate = IDATQQ(__DATE__);
699 fBuiltTime = ITIMQQ(__TIME__);
700
701 ReadGitInfo();
702
703 fClasses = new THashTable(800,3); fClasses->UseRWLock();
704 //fIdMap = new IdMap_t;
707
708 // usedToIdentifyRootClingByDlSym is available when TROOT is part of
709 // rootcling.
710 if (!dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")) {
711 // initialize plugin manager early
713 }
714
715 TSystemDirectory *workdir = new TSystemDirectory("workdir", gSystem->WorkingDirectory());
716
717 auto setNameLocked = [](TSeqCollection *l, const char *collection_name) {
718 l->SetName(collection_name);
719 l->UseRWLock();
720 return l;
721 };
722
723 fTimer = 0;
724 fApplication = nullptr;
725 fColors = setNameLocked(new TObjArray(1000), "ListOfColors");
726 fTypes = nullptr;
727 fGlobals = nullptr;
728 fGlobalFunctions = nullptr;
729 // fList was created in TDirectory::Build but with different sizing.
730 delete fList;
731 fList = new THashList(1000,3); fList->UseRWLock();
732 fClosedObjects = setNameLocked(new TList, "ClosedFiles");
733 fFiles = setNameLocked(new TList, "Files");
734 fMappedFiles = setNameLocked(new TList, "MappedFiles");
735 fSockets = setNameLocked(new TList, "Sockets");
736 fCanvases = setNameLocked(new TList, "Canvases");
737 fStyles = setNameLocked(new TList, "Styles");
738 fFunctions = setNameLocked(new TList, "Functions");
739 fTasks = setNameLocked(new TList, "Tasks");
740 fGeometries = setNameLocked(new TList, "Geometries");
741 fBrowsers = setNameLocked(new TList, "Browsers");
742 fSpecials = setNameLocked(new TList, "Specials");
743 fBrowsables = (TList*)setNameLocked(new TList, "Browsables");
744 fCleanups = setNameLocked(new THashList, "Cleanups");
745 fMessageHandlers = setNameLocked(new TList, "MessageHandlers");
746 fSecContexts = setNameLocked(new TList, "SecContexts");
747 fProofs = setNameLocked(new TList, "Proofs");
748 fClipboard = setNameLocked(new TList, "Clipboard");
749 fDataSets = setNameLocked(new TList, "DataSets");
751
753 fUUIDs = new TProcessUUID();
754
755 fRootFolder = new TFolder();
756 fRootFolder->SetName("root");
757 fRootFolder->SetTitle("root of all folders");
758 fRootFolder->AddFolder("Classes", "List of Active Classes",fClasses);
759 fRootFolder->AddFolder("Colors", "List of Active Colors",fColors);
760 fRootFolder->AddFolder("MapFiles", "List of MapFiles",fMappedFiles);
761 fRootFolder->AddFolder("Sockets", "List of Socket Connections",fSockets);
762 fRootFolder->AddFolder("Canvases", "List of Canvases",fCanvases);
763 fRootFolder->AddFolder("Styles", "List of Styles",fStyles);
764 fRootFolder->AddFolder("Functions", "List of Functions",fFunctions);
765 fRootFolder->AddFolder("Tasks", "List of Tasks",fTasks);
766 fRootFolder->AddFolder("Geometries","List of Geometries",fGeometries);
767 fRootFolder->AddFolder("Browsers", "List of Browsers",fBrowsers);
768 fRootFolder->AddFolder("Specials", "List of Special Objects",fSpecials);
769 fRootFolder->AddFolder("Handlers", "List of Message Handlers",fMessageHandlers);
770 fRootFolder->AddFolder("Cleanups", "List of RecursiveRemove Collections",fCleanups);
771 fRootFolder->AddFolder("StreamerInfo","List of Active StreamerInfo Classes",fStreamerInfo);
772 fRootFolder->AddFolder("SecContexts","List of Security Contexts",fSecContexts);
773 fRootFolder->AddFolder("PROOF Sessions", "List of PROOF sessions",fProofs);
774 fRootFolder->AddFolder("ROOT Memory","List of Objects in the gROOT Directory",fList);
775 fRootFolder->AddFolder("ROOT Files","List of Connected ROOT Files",fFiles);
776
777 // by default, add the list of files, tasks, canvases and browsers in the Cleanups list
783 // And add TROOT's TDirectory personality
785
790 fEscape = kFALSE;
792 fPrimitive = nullptr;
793 fSelectPad = nullptr;
794 fEditorMode = 0;
795 fDefCanvasName = "c1";
797 fLineIsProcessing = 1; // This prevents WIN32 "Windows" thread to pick ROOT objects with mouse
798 gDirectory = this;
799 gPad = nullptr;
800
801 //set name of graphical cut class for the graphics editor
802 //cannot call SetCutClassName at this point because the TClass of TCutG
803 //is not yet build
804 fCutClassName = "TCutG";
805
806 // Create a default MessageHandler
807 new TMessageHandler((TClass*)nullptr);
808
809 // Create some styles
810 gStyle = nullptr;
812 SetStyle(gEnv->GetValue("Canvas.Style", "Modern"));
813
814 // Setup default (batch) graphics and GUI environment
817 gGXBatch = new TVirtualX("Batch", "ROOT Interface to batch graphics");
819
820#if defined(R__WIN32)
821 fBatch = kFALSE;
822#elif defined(R__HAS_COCOA)
823 fBatch = kFALSE;
824#else
825 if (gSystem->Getenv("DISPLAY"))
826 fBatch = kFALSE;
827 else
828 fBatch = kTRUE;
829#endif
830
831 int i = 0;
832 while (initfunc && initfunc[i]) {
833 (initfunc[i])();
834 fBatch = kFALSE; // put system in graphics mode (backward compatible)
835 i++;
836 }
837
838 // Set initial/default list of browsable objects
839 fBrowsables->Add(fRootFolder, "root");
840 fBrowsables->Add(fProofs, "PROOF Sessions");
842 fBrowsables->Add(fFiles, "ROOT Files");
843
844 atexit(CleanUpROOTAtExit);
845
847}
848
849////////////////////////////////////////////////////////////////////////////////
850/// Clean up and free resources used by ROOT (files, network sockets,
851/// shared memory segments, etc.).
852
854{
855 using namespace ROOT::Internal;
856
857 if (gROOTLocal == this) {
858
859 // If the interpreter has not yet been initialized, don't bother
861
862 // Mark the object as invalid, so that we can veto some actions
863 // (like autoloading) while we are in the destructor.
865
866 // Turn-off the global mutex to avoid recreating mutexes that have
867 // already been deleted during the destruction phase
868 if (gGlobalMutex) {
870 gGlobalMutex = nullptr;
871 delete m;
872 }
873
874 // Return when error occurred in TCling, i.e. when setup file(s) are
875 // out of date
876 if (!fVersionInt) return;
877
878 // ATTENTION!!! Order is important!
879
881
882 // FIXME: Causes rootcling to deadlock, debug and uncomment
883 // SafeDelete(fRootFolder);
884
885#ifdef R__COMPLETE_MEM_TERMINATION
886 fSpecials->Delete(); SafeDelete(fSpecials); // delete special objects : PostScript, Minuit, Html
887#endif
888
889 fClosedObjects->Delete("slow"); // and closed files
890 fFiles->Delete("slow"); // and files
892 fSecContexts->Delete("slow"); SafeDelete(fSecContexts); // and security contexts
893 fSockets->Delete(); SafeDelete(fSockets); // and sockets
894 fMappedFiles->Delete("slow"); // and mapped files
895 TSeqCollection *tl = fMappedFiles; fMappedFiles = nullptr; delete tl;
896
898
899 delete fUUIDs;
900 TProcessID::Cleanup(); // and list of ProcessIDs
901
908
909#ifdef R__COMPLETE_MEM_TERMINATION
914#endif
915
916 // Stop emitting signals
918
920
921#ifdef R__COMPLETE_MEM_TERMINATION
927
928 fCleanups->Clear();
930 delete gClassTable; gClassTable = 0;
931 delete gEnv; gEnv = 0;
932
933 if (fTypes) fTypes->Delete();
935 if (fGlobals) fGlobals->Delete();
939 fEnums.load()->Delete();
940
941 // FIXME: Causes segfault in rootcling, debug and uncomment
942 // fClasses->Delete(); SafeDelete(fClasses); // TClass'es must be deleted last
943#endif
944
945 // Remove shared libraries produced by the TSystem::CompileMacro() call
947
948 // Cleanup system class
952 delete gSystem;
953
954 // ROOT-6022:
955 // if (gInterpreterLib) dlclose(gInterpreterLib);
956#ifdef R__COMPLETE_MEM_TERMINATION
957 // On some 'newer' platform (Fedora Core 17+, Ubuntu 12), the
958 // initialization order is (by default?) is 'wrong' and so we can't
959 // delete the interpreter now .. because any of the static in the
960 // interpreter's library have already been deleted.
961 // On the link line, we must list the most dependent .o file
962 // and end with the least dependent (LLVM libraries), unfortunately,
963 // Fedora Core 17+ or Ubuntu 12 will also execute the initialization
964 // in the same order (hence doing libCore's before LLVM's and
965 // vice et versa for both the destructor. We worked around the
966 // initialization order by delay the TROOT creation until first use.
967 // We can not do the same for destruction as we have no way of knowing
968 // the last access ...
969 // So for now, let's avoid delete TCling except in the special build
970 // checking the completeness of the termination deletion.
971
972 // TODO: Should we do more cleanup here than just call delete?
973 // Segfaults rootcling in some cases, debug and uncomment:
974 //
975 // delete fInterpreter;
976
977 // We cannot delete fCleanups because of the logic in atexit which needs it.
979#endif
980
981#ifdef _MSC_VER
982 // usedToIdentifyRootClingByDlSym is available when TROOT is part of rootcling.
983 if (dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")) {
984 // deleting the interpreter makes things crash at exit in some cases
985 delete fInterpreter;
986 }
987#else
988 // deleting the interpreter makes things crash at exit in some cases
989 delete fInterpreter;
990#endif
991
992 // Prints memory stats
994
995 gROOTLocal = nullptr;
997 }
998}
999
1000////////////////////////////////////////////////////////////////////////////////
1001/// Add a class to the list and map of classes.
1002/// This routine is deprecated, use TClass::AddClass directly.
1003
1005{
1006 TClass::AddClass(cl);
1007}
1008
1009////////////////////////////////////////////////////////////////////////////////
1010/// Add a class generator. This generator will be called by TClass::GetClass
1011/// in case its does not find a loaded rootcint dictionary to request the
1012/// creation of a TClass object.
1013
1015{
1016 if (!generator) return;
1017 fClassGenerators->Add(generator);
1018}
1019
1020////////////////////////////////////////////////////////////////////////////////
1021/// Append object to this directory.
1022///
1023/// If replace is true:
1024/// remove any existing objects with the same same (if the name is not "")
1025
1026void TROOT::Append(TObject *obj, Bool_t replace /* = kFALSE */)
1027{
1029 TDirectory::Append(obj,replace);
1030}
1031
1032////////////////////////////////////////////////////////////////////////////////
1033/// Add browsable objects to TBrowser.
1034
1036{
1037 TObject *obj;
1038 TIter next(fBrowsables);
1039
1040 while ((obj = (TObject *) next())) {
1041 const char *opt = next.GetOption();
1042 if (opt && strlen(opt))
1043 b->Add(obj, opt);
1044 else
1045 b->Add(obj, obj->GetName());
1046 }
1047}
1048
1049////////////////////////////////////////////////////////////////////////////////
1050/// return class status bit kClassSaved for class cl
1051/// This function is called by the SavePrimitive functions writing
1052/// the C++ code for an object.
1053
1055{
1056 if (cl == nullptr) return kFALSE;
1057 if (cl->TestBit(TClass::kClassSaved)) return kTRUE;
1059 return kFALSE;
1060}
1061
1062namespace {
1063 static void R__ListSlowClose(TList *files)
1064 {
1065 // Routine to close a list of files using the 'slow' techniques
1066 // that also for the deletion ot update the list itself.
1067
1068 static TObject harmless;
1069 TObjLink *cursor = files->FirstLink();
1070 while (cursor) {
1071 TDirectory *dir = static_cast<TDirectory*>( cursor->GetObject() );
1072 if (dir) {
1073 // In order for the iterator to stay valid, we must
1074 // prevent the removal of the object (dir) from the list
1075 // (which is done in TFile::Close). We can also can not
1076 // just move to the next iterator since the Close might
1077 // also (indirectly) remove that file.
1078 // So we SetObject to a harmless value, so that 'dir'
1079 // is not seen as part of the list.
1080 // We will later, remove all the object (see files->Clear()
1081 cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
1082 // See related comment at the files->Clear("nodelete");
1083 dir->Close("nodelete");
1084 // Put it back
1085 cursor->SetObject(dir);
1086 }
1087 cursor = cursor->Next();
1088 };
1089 // Now were done, clear the list but do not delete the objects as
1090 // they have been moved to the list of closed objects and must be
1091 // deleted from there in order to avoid a double delete from a
1092 // use objects (on the interpreter stack).
1093 files->Clear("nodelete");
1094 }
1095
1096 static void R__ListSlowDeleteContent(TList *files)
1097 {
1098 // Routine to delete the content of list of files using the 'slow' techniques
1099
1100 static TObject harmless;
1101 TObjLink *cursor = files->FirstLink();
1102 while (cursor) {
1103 TDirectory *dir = dynamic_cast<TDirectory*>( cursor->GetObject() );
1104 if (dir) {
1105 // In order for the iterator to stay valid, we must
1106 // prevent the removal of the object (dir) from the list
1107 // (which is done in TFile::Close). We can also can not
1108 // just move to the next iterator since the Close might
1109 // also (indirectly) remove that file.
1110 // So we SetObject to a harmless value, so that 'dir'
1111 // is not seen as part of the list.
1112 // We will later, remove all the object (see files->Clear()
1113 cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
1114 // See related comment at the files->Clear("nodelete");
1115 dir->GetList()->Delete("slow");
1116 // Put it back
1117 cursor->SetObject(dir);
1118 }
1119 cursor = cursor->Next();
1120 };
1121 }
1122}
1123
1124////////////////////////////////////////////////////////////////////////////////
1125/// Close any files and sockets that gROOT knows about.
1126/// This can be used to insures that the files and sockets are closed before any library is unloaded!
1127
1129{
1130 if (fFiles && fFiles->First()) {
1131 R__ListSlowClose(static_cast<TList*>(fFiles));
1132 }
1133 // and Close TROOT itself.
1134 Close("slow");
1135 // Now sockets.
1136 if (fSockets && fSockets->First()) {
1137 if (nullptr==fCleanups->FindObject(fSockets) ) {
1140 }
1141 CallFunc_t *socketCloser = gInterpreter->CallFunc_Factory();
1142 Longptr_t offset = 0;
1143 TClass *socketClass = TClass::GetClass("TSocket");
1144 gInterpreter->CallFunc_SetFuncProto(socketCloser, socketClass->GetClassInfo(), "Close", "", &offset);
1145 if (gInterpreter->CallFunc_IsValid(socketCloser)) {
1146 static TObject harmless;
1147 TObjLink *cursor = static_cast<TList*>(fSockets)->FirstLink();
1148 TList notclosed;
1149 while (cursor) {
1150 TObject *socket = cursor->GetObject();
1151 // In order for the iterator to stay valid, we must
1152 // prevent the removal of the object (dir) from the list
1153 // (which is done in TFile::Close). We can also can not
1154 // just move to the next iterator since the Close might
1155 // also (indirectly) remove that file.
1156 // So we SetObject to a harmless value, so that 'dir'
1157 // is not seen as part of the list.
1158 // We will later, remove all the object (see files->Clear()
1159 cursor->SetObject(&harmless); // this must not be zero otherwise things go wrong.
1160
1161 if (socket->IsA()->InheritsFrom(socketClass)) {
1162 gInterpreter->CallFunc_Exec(socketCloser, ((char*)socket)+offset);
1163 // Put the object in the closed list for later deletion.
1164 socket->SetBit(kMustCleanup);
1166 } else {
1167 // Crap ... this is not a socket, likely Proof or something, let's try to find a Close
1168 Longptr_t other_offset;
1169 CallFunc_t *otherCloser = gInterpreter->CallFunc_Factory();
1170 gInterpreter->CallFunc_SetFuncProto(otherCloser, socket->IsA()->GetClassInfo(), "Close", "", &other_offset);
1171 if (gInterpreter->CallFunc_IsValid(otherCloser)) {
1172 gInterpreter->CallFunc_Exec(otherCloser, ((char*)socket)+other_offset);
1173 // Put the object in the closed list for later deletion.
1174 socket->SetBit(kMustCleanup);
1176 } else {
1177 notclosed.AddLast(socket);
1178 }
1179 gInterpreter->CallFunc_Delete(otherCloser);
1180 // Put it back
1181 cursor->SetObject(socket);
1182 }
1183 cursor = cursor->Next();
1184 }
1185 // Now were done, clear the list
1186 fSockets->Clear();
1187 // Read the one we did not close
1188 cursor = notclosed.FirstLink();
1189 while (cursor) {
1190 static_cast<TList*>(fSockets)->AddLast(cursor->GetObject());
1191 cursor = cursor->Next();
1192 }
1193 }
1194 gInterpreter->CallFunc_Delete(socketCloser);
1195 }
1196 if (fMappedFiles && fMappedFiles->First()) {
1197 R__ListSlowClose(static_cast<TList*>(fMappedFiles));
1198 }
1199
1200}
1201
1202////////////////////////////////////////////////////////////////////////////////
1203/// Execute the cleanups necessary at the end of the process, in particular
1204/// those that must be executed before the library start being unloaded.
1205
1207{
1208 // This will not delete the objects 'held' by the TFiles so that
1209 // they can still be 'reacheable' when ResetGlobals is run.
1210 CloseFiles();
1211
1212 if (gInterpreter) {
1213 gInterpreter->ResetGlobals();
1214 }
1215
1216 // Now delete the objects 'held' by the TFiles so that it
1217 // is done before the tear down of the libraries.
1219 R__ListSlowDeleteContent(static_cast<TList*>(fClosedObjects));
1220 }
1221
1222 // Now a set of simpler things to delete. See the same ordering in
1223 // TROOT::~TROOT
1224 fFunctions->Delete();
1226 fBrowsers->Delete();
1227 fCanvases->Delete("slow");
1228 fColors->Delete();
1229 fStyles->Delete();
1230
1232
1233 if (gInterpreter) {
1234 gInterpreter->ShutDown();
1235 }
1236}
1237
1238
1239////////////////////////////////////////////////////////////////////////////////
1240/// Find an object in one Root folder
1241
1243{
1244 Error("FindObject","Not yet implemented");
1245 return nullptr;
1246}
1247
1248////////////////////////////////////////////////////////////////////////////////
1249/// Returns address of a ROOT object if it exists
1250///
1251/// If name contains at least one "/" the function calls FindObjectany
1252/// else
1253/// This function looks in the following order in the ROOT lists:
1254/// - List of files
1255/// - List of memory mapped files
1256/// - List of functions
1257/// - List of geometries
1258/// - List of canvases
1259/// - List of styles
1260/// - List of specials
1261/// - List of materials in current geometry
1262/// - List of shapes in current geometry
1263/// - List of matrices in current geometry
1264/// - List of Nodes in current geometry
1265/// - Current Directory in memory
1266/// - Current Directory on file
1267
1268TObject *TROOT::FindObject(const char *name) const
1269{
1270 if (name && strstr(name,"/")) return FindObjectAny(name);
1271
1272 TObject *temp = nullptr;
1273
1274 temp = fFiles->FindObject(name); if (temp) return temp;
1275 temp = fMappedFiles->FindObject(name); if (temp) return temp;
1276 {
1278 temp = fFunctions->FindObject(name);if (temp) return temp;
1279 }
1280 temp = fGeometries->FindObject(name); if (temp) return temp;
1281 temp = fCanvases->FindObject(name); if (temp) return temp;
1282 temp = fStyles->FindObject(name); if (temp) return temp;
1283 {
1285 temp = fSpecials->FindObject(name); if (temp) return temp;
1286 }
1287 TIter next(fGeometries);
1288 TObject *obj;
1289 while ((obj=next())) {
1290 temp = obj->FindObject(name); if (temp) return temp;
1291 }
1292 if (gDirectory) temp = gDirectory->Get(name);
1293 if (temp) return temp;
1294 if (gPad) {
1295 TVirtualPad *canvas = gPad->GetVirtCanvas();
1296 if (fCanvases->FindObject(canvas)) { //this check in case call from TCanvas ctor
1297 temp = canvas->FindObject(name);
1298 if (!temp && canvas != gPad) temp = gPad->FindObject(name);
1299 }
1300 }
1301 return temp;
1302}
1303
1304////////////////////////////////////////////////////////////////////////////////
1305/// Returns address and folder of a ROOT object if it exists
1306///
1307/// This function looks in the following order in the ROOT lists:
1308/// - List of files
1309/// - List of memory mapped files
1310/// - List of functions
1311/// - List of geometries
1312/// - List of canvases
1313/// - List of styles
1314/// - List of specials
1315/// - List of materials in current geometry
1316/// - List of shapes in current geometry
1317/// - List of matrices in current geometry
1318/// - List of Nodes in current geometry
1319/// - Current Directory in memory
1320/// - Current Directory on file
1321
1322TObject *TROOT::FindSpecialObject(const char *name, void *&where)
1323{
1324 TObject *temp = nullptr;
1325 where = nullptr;
1326
1327 if (!temp) {
1328 temp = fFiles->FindObject(name);
1329 where = fFiles;
1330 }
1331 if (!temp) {
1332 temp = fMappedFiles->FindObject(name);
1333 where = fMappedFiles;
1334 }
1335 if (!temp) {
1337 temp = fFunctions->FindObject(name);
1338 where = fFunctions;
1339 }
1340 if (!temp) {
1341 temp = fCanvases->FindObject(name);
1342 where = fCanvases;
1343 }
1344 if (!temp) {
1345 temp = fStyles->FindObject(name);
1346 where = fStyles;
1347 }
1348 if (!temp) {
1349 temp = fSpecials->FindObject(name);
1350 where = fSpecials;
1351 }
1352 if (!temp) {
1353 TObject *glast = fGeometries->Last();
1354 if (glast) {where = glast; temp = glast->FindObject(name);}
1355 }
1356 if (!temp && gDirectory) {
1357 temp = gDirectory->Get(name);
1358 where = gDirectory;
1359 }
1360 if (!temp && gPad) {
1361 TVirtualPad *canvas = gPad->GetVirtCanvas();
1362 if (fCanvases->FindObject(canvas)) { //this check in case call from TCanvas ctor
1363 temp = canvas->FindObject(name);
1364 where = canvas;
1365 if (!temp && canvas != gPad) {
1366 temp = gPad->FindObject(name);
1367 where = gPad;
1368 }
1369 }
1370 }
1371 if (!temp) return nullptr;
1372 if (temp->TestBit(kNotDeleted)) return temp;
1373 return nullptr;
1374}
1375
1376////////////////////////////////////////////////////////////////////////////////
1377/// Return a pointer to the first object with name starting at //root.
1378/// This function scans the list of all folders.
1379/// if no object found in folders, it scans the memory list of all files.
1380
1382{
1384 if (obj) return obj;
1385 return gDirectory->FindObjectAnyFile(name);
1386}
1387
1388////////////////////////////////////////////////////////////////////////////////
1389/// Scan the memory lists of all files for an object with name
1390
1392{
1394 TDirectory *d;
1395 TIter next(GetListOfFiles());
1396 while ((d = (TDirectory*)next())) {
1397 // Call explicitly TDirectory::FindObject to restrict the search to the
1398 // already in memory object.
1399 TObject *obj = d->TDirectory::FindObject(name);
1400 if (obj) return obj;
1401 }
1402 return nullptr;
1403}
1404
1405////////////////////////////////////////////////////////////////////////////////
1406/// Returns class name of a ROOT object including CINT globals.
1407
1408const char *TROOT::FindObjectClassName(const char *name) const
1409{
1410 // Search first in the list of "standard" objects
1411 TObject *obj = FindObject(name);
1412 if (obj) return obj->ClassName();
1413
1414 // Is it a global variable?
1415 TGlobal *g = GetGlobal(name);
1416 if (g) return g->GetTypeName();
1417
1418 return nullptr;
1419}
1420
1421////////////////////////////////////////////////////////////////////////////////
1422/// Return path name of obj somewhere in the //root/... path.
1423/// The function returns the first occurence of the object in the list
1424/// of folders. The returned string points to a static char array in TROOT.
1425/// If this function is called in a loop or recursively, it is the
1426/// user's responsibility to copy this string in their area.
1427
1428const char *TROOT::FindObjectPathName(const TObject *) const
1429{
1430 Error("FindObjectPathName","Not yet implemented");
1431 return "??";
1432}
1433
1434////////////////////////////////////////////////////////////////////////////////
1435/// return a TClass object corresponding to 'name' assuming it is an STL container.
1436/// In particular we looking for possible alternative name (default template
1437/// parameter, typedefs template arguments, typedefed name).
1438
1439TClass *TROOT::FindSTLClass(const char *name, Bool_t load, Bool_t silent) const
1440{
1441 // Example of inputs are
1442 // vector<int> (*)
1443 // vector<Int_t>
1444 // vector<long long>
1445 // vector<Long_64_t> (*)
1446 // vector<int, allocator<int> >
1447 // vector<Int_t, allocator<int> >
1448 //
1449 // One of the possibly expensive operation is the resolving of the typedef
1450 // which can provoke the parsing of the header files (and/or the loading
1451 // of clang pcms information).
1452
1454
1455 // Remove std::, allocator, typedef, add Long64_t, etc. in just one call.
1456 std::string normalized;
1458
1459 TClass *cl = nullptr;
1460 if (normalized != name) cl = TClass::GetClass(normalized.c_str(),load,silent);
1461
1462 if (load && cl==nullptr) {
1463 // Create an Emulated class for this container.
1464 cl = gInterpreter->GenerateTClass(normalized.c_str(), kTRUE, silent);
1465 }
1466
1467 return cl;
1468}
1469
1470////////////////////////////////////////////////////////////////////////////////
1471/// Return pointer to class with name. Obsolete, use TClass::GetClass directly
1472
1473TClass *TROOT::GetClass(const char *name, Bool_t load, Bool_t silent) const
1474{
1475 return TClass::GetClass(name,load,silent);
1476}
1477
1478
1479////////////////////////////////////////////////////////////////////////////////
1480/// Return pointer to class from its name. Obsolete, use TClass::GetClass directly
1481/// See TClass::GetClass
1482
1483TClass *TROOT::GetClass(const std::type_info& typeinfo, Bool_t load, Bool_t silent) const
1484{
1485 return TClass::GetClass(typeinfo,load,silent);
1486}
1487
1488////////////////////////////////////////////////////////////////////////////////
1489/// Return address of color with index color.
1490
1492{
1494 TObjArray *lcolors = (TObjArray*) GetListOfColors();
1495 if (!lcolors) return nullptr;
1496 if (color < 0 || color >= lcolors->GetSize()) return nullptr;
1497 TColor *col = (TColor*)lcolors->At(color);
1498 if (col && col->GetNumber() == color) return col;
1499 TIter next(lcolors);
1500 while ((col = (TColor *) next()))
1501 if (col->GetNumber() == color) return col;
1502
1503 return nullptr;
1504}
1505
1506////////////////////////////////////////////////////////////////////////////////
1507/// Return a default canvas.
1508
1510{
1511 return (TCanvas*)gROOT->ProcessLine("TCanvas::MakeDefCanvas();");
1512}
1513
1514////////////////////////////////////////////////////////////////////////////////
1515/// Return pointer to type with name.
1516
1517TDataType *TROOT::GetType(const char *name, Bool_t /* load */) const
1518{
1519 return (TDataType*)gROOT->GetListOfTypes()->FindObject(name);
1520}
1521
1522////////////////////////////////////////////////////////////////////////////////
1523/// Return pointer to file with name.
1524
1525TFile *TROOT::GetFile(const char *name) const
1526{
1528 return (TFile*)GetListOfFiles()->FindObject(name);
1529}
1530
1531////////////////////////////////////////////////////////////////////////////////
1532/// Return pointer to style with name
1533
1534TStyle *TROOT::GetStyle(const char *name) const
1535{
1537}
1538
1539////////////////////////////////////////////////////////////////////////////////
1540/// Return pointer to function with name.
1541
1543{
1544 if (name == nullptr || name[0] == 0) {
1545 return nullptr;
1546 }
1547
1548 {
1551 if (f1) return f1;
1552 }
1553
1554 gROOT->ProcessLine("TF1::InitStandardFunctions();");
1555
1557 return fFunctions->FindObject(name);
1558}
1559
1560////////////////////////////////////////////////////////////////////////////////
1561
1563{
1564 if (!gInterpreter) return nullptr;
1565
1567
1569}
1570
1571////////////////////////////////////////////////////////////////////////////////
1572/// Return pointer to global variable by name. If load is true force
1573/// reading of all currently defined globals from CINT (more expensive).
1574
1575TGlobal *TROOT::GetGlobal(const char *name, Bool_t load) const
1576{
1577 return (TGlobal *)gROOT->GetListOfGlobals(load)->FindObject(name);
1578}
1579
1580////////////////////////////////////////////////////////////////////////////////
1581/// Return pointer to global variable with address addr.
1582
1583TGlobal *TROOT::GetGlobal(const TObject *addr, Bool_t /* load */) const
1584{
1585 if (addr == nullptr || ((Longptr_t)addr) == -1) return nullptr;
1586
1587 TInterpreter::DeclId_t decl = gInterpreter->GetDataMemberAtAddr(addr);
1588 if (decl) {
1589 TListOfDataMembers *globals = ((TListOfDataMembers*)(gROOT->GetListOfGlobals(kFALSE)));
1590 return (TGlobal*)globals->Get(decl);
1591 }
1592 // If we are actually looking for a global that is held by a global
1593 // pointer (for example gRandom), we need to find a pointer with the
1594 // correct value.
1595 decl = gInterpreter->GetDataMemberWithValue(addr);
1596 if (decl) {
1597 TListOfDataMembers *globals = ((TListOfDataMembers*)(gROOT->GetListOfGlobals(kFALSE)));
1598 return (TGlobal*)globals->Get(decl);
1599 }
1600 return nullptr;
1601}
1602
1603////////////////////////////////////////////////////////////////////////////////
1604/// Internal routine returning, and creating if necessary, the list
1605/// of global function.
1606
1608{
1610 return fGlobalFunctions;
1611}
1612
1613////////////////////////////////////////////////////////////////////////////////
1614/// Return the collection of functions named "name".
1615
1617{
1618 return ((TListOfFunctions*)fGlobalFunctions)->GetListForObject(name);
1619}
1620
1621////////////////////////////////////////////////////////////////////////////////
1622/// Return pointer to global function by name.
1623/// If params != 0 it will also resolve overloading other it returns the first
1624/// name match.
1625/// If params == 0 and load is true force reading of all currently defined
1626/// global functions from Cling.
1627/// The param string must be of the form: "3189,\"aap\",1.3".
1628
1629TFunction *TROOT::GetGlobalFunction(const char *function, const char *params,
1630 Bool_t load)
1631{
1632 if (!params) {
1634 return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
1635 } else {
1636 if (!fInterpreter)
1637 Fatal("GetGlobalFunction", "fInterpreter not initialized");
1638
1640 TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithValues(nullptr,
1641 function, params,
1642 false);
1643
1644 if (!decl) return nullptr;
1645
1646 TFunction *f = GetGlobalFunctions()->Get(decl);
1647 if (f) return f;
1648
1649 Error("GetGlobalFunction",
1650 "\nDid not find matching TFunction <%s> with \"%s\".",
1651 function,params);
1652 return nullptr;
1653 }
1654}
1655
1656////////////////////////////////////////////////////////////////////////////////
1657/// Return pointer to global function by name. If proto != 0
1658/// it will also resolve overloading. If load is true force reading
1659/// of all currently defined global functions from CINT (more expensive).
1660/// The proto string must be of the form: "int, char*, float".
1661
1663 const char *proto, Bool_t load)
1664{
1665 if (!proto) {
1667 return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
1668 } else {
1669 if (!fInterpreter)
1670 Fatal("GetGlobalFunctionWithPrototype", "fInterpreter not initialized");
1671
1673 TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithPrototype(nullptr,
1674 function, proto);
1675
1676 if (!decl) return nullptr;
1677
1678 TFunction *f = GetGlobalFunctions()->Get(decl);
1679 if (f) return f;
1680
1681 Error("GetGlobalFunctionWithPrototype",
1682 "\nDid not find matching TFunction <%s> with \"%s\".",
1683 function,proto);
1684 return nullptr;
1685 }
1686}
1687
1688////////////////////////////////////////////////////////////////////////////////
1689/// Return pointer to Geometry with name
1690
1692{
1694}
1695
1696////////////////////////////////////////////////////////////////////////////////
1697
1699{
1700 if(!fEnums.load()) {
1702 // Test again just in case, another thread did the work while we were
1703 // waiting.
1704 if (!fEnums.load()) fEnums = new TListOfEnumsWithLock(nullptr);
1705 }
1706 if (load) {
1708 (*fEnums).Load(); // Refresh the list of enums.
1709 }
1710 return fEnums.load();
1711}
1712
1713////////////////////////////////////////////////////////////////////////////////
1714
1716{
1718 if(!fFuncTemplate) {
1720 }
1721 return fFuncTemplate;
1722}
1723
1724////////////////////////////////////////////////////////////////////////////////
1725/// Return list containing the TGlobals currently defined.
1726/// Since globals are created and deleted during execution of the
1727/// program, we need to update the list of globals every time we
1728/// execute this method. However, when calling this function in
1729/// a (tight) loop where no interpreter symbols will be created
1730/// you can set load=kFALSE (default).
1731
1733{
1734 if (!fGlobals) {
1736 // We add to the list the "funcky-fake" globals.
1737
1738 // provide special functor for gROOT, while ROOT::GetROOT() does not return reference
1739 TGlobalMappedFunction::MakeFunctor("gROOT", "TROOT*", ROOT::GetROOT, [] {
1740 ROOT::GetROOT();
1741 return (void *)&ROOT::Internal::gROOTLocal;
1742 });
1743
1745 TGlobalMappedFunction::MakeFunctor("gVirtualX", "TVirtualX*", TVirtualX::Instance);
1747
1748 // Don't let TGlobalMappedFunction delete our globals, now that we take them.
1752 }
1753
1754 if (!fInterpreter)
1755 Fatal("GetListOfGlobals", "fInterpreter not initialized");
1756
1757 if (load) fGlobals->Load();
1758
1759 return fGlobals;
1760}
1761
1762////////////////////////////////////////////////////////////////////////////////
1763/// Return list containing the TFunctions currently defined.
1764/// Since functions are created and deleted during execution of the
1765/// program, we need to update the list of functions every time we
1766/// execute this method. However, when calling this function in
1767/// a (tight) loop where no interpreter symbols will be created
1768/// you can set load=kFALSE (default).
1769
1771{
1773
1774 if (!fGlobalFunctions) {
1775 fGlobalFunctions = new TListOfFunctions(nullptr);
1776 }
1777
1778 if (!fInterpreter)
1779 Fatal("GetListOfGlobalFunctions", "fInterpreter not initialized");
1780
1781 // A thread that calls with load==true and a thread that calls with load==false
1782 // will conflict here (the load==true will be updating the list while the
1783 // other is reading it). To solve the problem, we could use a read-write lock
1784 // inside the list itself.
1785 if (load) fGlobalFunctions->Load();
1786
1787 return fGlobalFunctions;
1788}
1789
1790////////////////////////////////////////////////////////////////////////////////
1791/// Return a dynamic list giving access to all TDataTypes (typedefs)
1792/// currently defined.
1793///
1794/// The list is populated on demand. Calling
1795/// ~~~ {.cpp}
1796/// gROOT->GetListOfTypes()->FindObject(nameoftype);
1797/// ~~~
1798/// will return the TDataType corresponding to 'nameoftype'. If the
1799/// TDataType is not already in the list itself and the type does exist,
1800/// a new TDataType will be created and added to the list.
1801///
1802/// Calling
1803/// ~~~ {.cpp}
1804/// gROOT->GetListOfTypes()->ls(); // or Print()
1805/// ~~~
1806/// list only the typedefs that have been previously accessed through the
1807/// list (plus the builtins types).
1808
1810{
1811 if (!fInterpreter)
1812 Fatal("GetListOfTypes", "fInterpreter not initialized");
1813
1814 return fTypes;
1815}
1816
1817////////////////////////////////////////////////////////////////////////////////
1818/// Get number of classes.
1819
1821{
1822 return fClasses->GetSize();
1823}
1824
1825////////////////////////////////////////////////////////////////////////////////
1826/// Get number of types.
1827
1829{
1830 return fTypes->GetSize();
1831}
1832
1833////////////////////////////////////////////////////////////////////////////////
1834/// Execute command when system has been idle for idleTimeInSec seconds.
1835
1836void TROOT::Idle(UInt_t idleTimeInSec, const char *command)
1837{
1838 if (!fApplication.load())
1840
1841 if (idleTimeInSec <= 0)
1842 (*fApplication).RemoveIdleTimer();
1843 else
1844 (*fApplication).SetIdleTimer(idleTimeInSec, command);
1845}
1846
1847////////////////////////////////////////////////////////////////////////////////
1848/// Check whether className is a known class, and only autoload
1849/// if we can. Helper function for TROOT::IgnoreInclude().
1850
1851static TClass* R__GetClassIfKnown(const char* className)
1852{
1853 // Check whether the class is available for auto-loading first:
1854 const char* libsToLoad = gInterpreter->GetClassSharedLibs(className);
1855 TClass* cla = nullptr;
1856 if (libsToLoad) {
1857 // trigger autoload, and only create TClass in this case.
1858 return TClass::GetClass(className);
1859 } else if (gROOT->GetListOfClasses()
1860 && (cla = (TClass*)gROOT->GetListOfClasses()->FindObject(className))) {
1861 // cla assigned in if statement
1862 } else if (gClassTable->FindObject(className)) {
1863 return TClass::GetClass(className);
1864 }
1865 return cla;
1866}
1867
1868////////////////////////////////////////////////////////////////////////////////
1869/// Return 1 if the name of the given include file corresponds to a class that
1870/// is known to ROOT, e.g. "TLorentzVector.h" versus TLorentzVector.
1871
1872Int_t TROOT::IgnoreInclude(const char *fname, const char * /*expandedfname*/)
1873{
1874 if (fname == nullptr) return 0;
1875
1876 TString stem(fname);
1877 // Remove extension if any, ignore files with extension not being .h*
1878 Int_t where = stem.Last('.');
1879 if (where != kNPOS) {
1880 if (stem.EndsWith(".so") || stem.EndsWith(".sl") ||
1881 stem.EndsWith(".dl") || stem.EndsWith(".a") ||
1882 stem.EndsWith(".dll", TString::kIgnoreCase))
1883 return 0;
1884 stem.Remove(where);
1885 }
1886
1887 TString className = gSystem->BaseName(stem);
1888 TClass* cla = R__GetClassIfKnown(className);
1889 if (!cla) {
1890 // Try again with modifications to the file name:
1891 className = stem;
1892 className.ReplaceAll("/", "::");
1893 className.ReplaceAll("\\", "::");
1894 if (className.Contains(":::")) {
1895 // "C:\dir" becomes "C:::dir".
1896 // fname corresponds to whatever is stated after #include and
1897 // a full path name usually means that it's not a regular #include
1898 // but e.g. a ".L", so we can assume that this is not a header of
1899 // a class in a namespace (a global-namespace class would have been
1900 // detected already before).
1901 return 0;
1902 }
1903 cla = R__GetClassIfKnown(className);
1904 }
1905
1906 if (!cla) {
1907 return 0;
1908 }
1909
1910 // cla is valid, check wether it's actually in the header of the same name:
1911 if (cla->GetDeclFileLine() <= 0) return 0; // to a void an error with VisualC++
1912 TString decfile = gSystem->BaseName(cla->GetDeclFileName());
1913 if (decfile != gSystem->BaseName(fname)) {
1914 return 0;
1915 }
1916 return 1;
1917}
1918
1919////////////////////////////////////////////////////////////////////////////////
1920/// Initialize operating system interface.
1921
1923{
1924 if (gSystem == nullptr) {
1925#if defined(R__UNIX)
1926#if defined(R__HAS_COCOA)
1927 gSystem = new TMacOSXSystem;
1928#else
1929 gSystem = new TUnixSystem;
1930#endif
1931#elif defined(R__WIN32)
1932 gSystem = new TWinNTSystem;
1933#else
1934 gSystem = new TSystem;
1935#endif
1936
1937 if (gSystem->Init())
1938 fprintf(stderr, "Fatal in <TROOT::InitSystem>: can't init operating system layer\n");
1939
1940 if (!gSystem->HomeDirectory()) {
1941 fprintf(stderr, "Fatal in <TROOT::InitSystem>: HOME directory not set\n");
1942 fprintf(stderr, "Fix this by defining the HOME shell variable\n");
1943 }
1944
1945 // read default files
1946 gEnv = new TEnv(".rootrc");
1947
1950
1951 gDebug = gEnv->GetValue("Root.Debug", 0);
1952
1953 if (!gEnv->GetValue("Root.ErrorHandlers", 1))
1955
1956 // The old "Root.ZipMode" had a discrepancy between documentation vs actual meaning.
1957 // Also, a value with the meaning "default" wasn't available. To solved this,
1958 // "Root.ZipMode" was replaced by "Root.CompressionAlgorithm". Warn about usage of
1959 // the old value, if it's set to 0, but silently translate the setting to
1960 // "Root.CompressionAlgorithm" for values > 1.
1961 Int_t oldzipmode = gEnv->GetValue("Root.ZipMode", -1);
1962 if (oldzipmode == 0) {
1963 fprintf(stderr, "Warning in <TROOT::InitSystem>: ignoring old rootrc entry \"Root.ZipMode = 0\"!\n");
1964 } else {
1965 if (oldzipmode == -1 || oldzipmode == 1) {
1966 // Not set or default value, use "default" for "Root.CompressionAlgorithm":
1967 oldzipmode = 0;
1968 }
1969 // else keep the old zipmode (e.g. "3") as "Root.CompressionAlgorithm"
1970 // if "Root.CompressionAlgorithm" isn't set; see below.
1971 }
1972
1973 Int_t zipmode = gEnv->GetValue("Root.CompressionAlgorithm", oldzipmode);
1974 if (zipmode != 0) R__SetZipMode(zipmode);
1975
1976 const char *sdeb;
1977 if ((sdeb = gSystem->Getenv("ROOTDEBUG")))
1978 gDebug = atoi(sdeb);
1979
1980 if (gDebug > 0 && isatty(2))
1981 fprintf(stderr, "Info in <TROOT::InitSystem>: running with gDebug = %d\n", gDebug);
1982
1983#if defined(R__HAS_COCOA)
1984 // create and delete a dummy TUrl so that TObjectStat table does not contain
1985 // objects that are deleted after recording is turned-off (in next line),
1986 // like the TUrl::fgSpecialProtocols list entries which are created in the
1987 // TMacOSXSystem ctor.
1988 { TUrl dummy("/dummy"); }
1989#endif
1990 TObject::SetObjectStat(gEnv->GetValue("Root.ObjectStat", 0));
1991 }
1992}
1993
1994////////////////////////////////////////////////////////////////////////////////
1995/// Load and initialize thread library.
1996
1998{
1999 if (gEnv->GetValue("Root.UseThreads", 0) || gEnv->GetValue("Root.EnableThreadSafety", 0)) {
2001 }
2002}
2003
2004////////////////////////////////////////////////////////////////////////////////
2005/// Initialize the interpreter. Should be called only after main(),
2006/// to make sure LLVM/Clang is fully initialized.
2007
2009{
2010 // usedToIdentifyRootClingByDlSym is available when TROOT is part of
2011 // rootcling.
2012 if (!dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym")
2013 && !dlsym(RTLD_DEFAULT, "usedToIdentifyStaticRoot")) {
2014 char *libRIO = gSystem->DynamicPathName("libRIO");
2015 void *libRIOHandle = dlopen(libRIO, RTLD_NOW|RTLD_GLOBAL);
2016 delete [] libRIO;
2017 if (!libRIOHandle) {
2018 TString err = dlerror();
2019 fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load library %s\n", err.Data());
2020 exit(1);
2021 }
2022
2023 char *libcling = gSystem->DynamicPathName("libCling");
2024 gInterpreterLib = dlopen(libcling, RTLD_LAZY|RTLD_LOCAL);
2025 delete [] libcling;
2026
2027 if (!gInterpreterLib) {
2028 TString err = dlerror();
2029 fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load library %s\n", err.Data());
2030 exit(1);
2031 }
2032 dlerror(); // reset error message
2033 } else {
2034 gInterpreterLib = RTLD_DEFAULT;
2035 }
2037 if (!CreateInterpreter) {
2038 TString err = dlerror();
2039 fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load symbol %s\n", err.Data());
2040 exit(1);
2041 }
2042 // Schedule the destruction of TROOT.
2043 atexit(at_exit_of_TROOT);
2044
2045 gDestroyInterpreter = (DestroyInterpreter_t*) dlsym(gInterpreterLib, "DestroyInterpreter");
2046 if (!gDestroyInterpreter) {
2047 TString err = dlerror();
2048 fprintf(stderr, "Fatal in <TROOT::InitInterpreter>: cannot load symbol %s\n", err.Data());
2049 exit(1);
2050 }
2051
2052 const char *interpArgs[] = {
2053#ifdef NDEBUG
2054 "-DNDEBUG",
2055#else
2056 "-UNDEBUG",
2057#endif
2058#ifdef DEBUG
2059 "-DDEBUG",
2060#else
2061 "-UDEBUG",
2062#endif
2063#ifdef _DEBUG
2064 "-D_DEBUG",
2065#else
2066 "-U_DEBUG",
2067#endif
2068 nullptr};
2069
2071
2074
2075 fgRootInit = kTRUE;
2076
2077 // initialize gClassTable is not already done
2078 if (!gClassTable)
2079 new TClassTable;
2080
2081 // Initialize all registered dictionaries.
2082 for (std::vector<ModuleHeaderInfo_t>::const_iterator
2083 li = GetModuleHeaderInfoBuffer().begin(),
2084 le = GetModuleHeaderInfoBuffer().end(); li != le; ++li) {
2085 // process buffered module registrations
2086 fInterpreter->RegisterModule(li->fModuleName,
2087 li->fHeaders,
2088 li->fIncludePaths,
2089 li->fPayloadCode,
2090 li->fFwdDeclCode,
2091 li->fTriggerFunc,
2092 li->fFwdNargsToKeepColl,
2093 li->fClassesHeaders,
2094 kTRUE /*lateRegistration*/,
2095 li->fHasCxxModule);
2096 }
2097 GetModuleHeaderInfoBuffer().clear();
2098
2100}
2101
2102////////////////////////////////////////////////////////////////////////////////
2103/// Helper function used by TClass::GetClass().
2104/// This function attempts to load the dictionary for 'classname'
2105/// either from the TClassTable or from the list of generator.
2106/// If silent is 'true', do not warn about missing dictionary for the class.
2107/// (typically used for class that are used only for transient members)
2108///
2109/// The 'requestedname' is expected to be already normalized.
2110
2111TClass *TROOT::LoadClass(const char *requestedname, Bool_t silent) const
2112{
2113 return TClass::LoadClass(requestedname, silent);
2114}
2115
2116////////////////////////////////////////////////////////////////////////////////
2117/// Check if class "classname" is known to the interpreter (in fact,
2118/// this check is not needed anymore, so classname is ignored). If
2119/// not it will load library "libname". If the library couldn't be found with original
2120/// libname and if the name was not prefixed with lib, try to prefix with "lib" and search again.
2121/// If DynamicPathName still couldn't find the library, return -1.
2122/// If check is true it will only check if libname exists and is
2123/// readable.
2124/// Returns 0 on successful loading, -1 in case libname does not
2125/// exist or in case of error and -2 in case of version mismatch.
2126
2127Int_t TROOT::LoadClass(const char * /*classname*/, const char *libname,
2128 Bool_t check)
2129{
2130 TString lib(libname);
2131
2132 // Check if libname exists in path or not
2133 if (char *path = gSystem->DynamicPathName(lib, kTRUE)) {
2134 // If check == true, only check if it exists and if it's readable
2135 if (check) {
2136 delete [] path;
2137 return 0;
2138 }
2139
2140 // If check == false, try to load the library
2141 else {
2142 int err = gSystem->Load(path, nullptr, kTRUE);
2143 delete [] path;
2144
2145 // TSystem::Load returns 1 when the library was already loaded, return success in this case.
2146 if (err == 1)
2147 err = 0;
2148 return err;
2149 }
2150 } else {
2151 // This is the branch where libname didn't exist
2152 if (check) {
2153 FileStat_t stat;
2154 if (!gSystem->GetPathInfo(libname, stat) && (R_ISREG(stat.fMode) &&
2156 return 0;
2157 }
2158
2159 // Take care of user who didn't write the whole name
2160 if (!lib.BeginsWith("lib")) {
2161 lib = "lib" + lib;
2162 return LoadClass("", lib.Data(), check);
2163 }
2164 }
2165
2166 // Execution reaches here when library was prefixed with lib, check is false and couldn't find
2167 // the library name.
2168 return -1;
2169}
2170
2171////////////////////////////////////////////////////////////////////////////////
2172/// Return true if the file is local and is (likely) to be a ROOT file
2173
2174Bool_t TROOT::IsRootFile(const char *filename) const
2175{
2176 Bool_t result = kFALSE;
2177 FILE *mayberootfile = fopen(filename,"rb");
2178 if (mayberootfile) {
2179 char header[5];
2180 if (fgets(header,5,mayberootfile)) {
2181 result = strncmp(header,"root",4)==0;
2182 }
2183 fclose(mayberootfile);
2184 }
2185 return result;
2186}
2187
2188////////////////////////////////////////////////////////////////////////////////
2189/// To list all objects of the application.
2190/// Loop on all objects created in the ROOT linked lists.
2191/// Objects may be files and windows or any other object directly
2192/// attached to the ROOT linked list.
2193
2194void TROOT::ls(Option_t *option) const
2195{
2196// TObject::SetDirLevel();
2197// GetList()->R__FOR_EACH(TObject,ls)(option);
2198 TDirectory::ls(option);
2199}
2200
2201////////////////////////////////////////////////////////////////////////////////
2202/// Load a macro in the interpreter's memory. Equivalent to the command line
2203/// command ".L filename". If the filename has "+" or "++" appended
2204/// the macro will be compiled by ACLiC. The filename must have the format:
2205/// [path/]macro.C[+|++[g|O]].
2206/// The possible error codes are defined by TInterpreter::EErrorCode.
2207/// If check is true it will only check if filename exists and is
2208/// readable.
2209/// Returns 0 on successful loading and -1 in case filename does not
2210/// exist or in case of error.
2211
2212Int_t TROOT::LoadMacro(const char *filename, int *error, Bool_t check)
2213{
2214 Int_t err = -1;
2215 Int_t lerr, *terr;
2216 if (error)
2217 terr = error;
2218 else
2219 terr = &lerr;
2220
2221 if (fInterpreter) {
2222 TString aclicMode;
2223 TString arguments;
2224 TString io;
2225 TString fname = gSystem->SplitAclicMode(filename, aclicMode, arguments, io);
2226
2227 if (arguments.Length()) {
2228 Warning("LoadMacro", "argument(%s) ignored in %s", arguments.Data(), GetMacroPath());
2229 }
2230 char *mac = gSystem->Which(GetMacroPath(), fname, kReadPermission);
2231 if (!mac) {
2232 if (!check)
2233 Error("LoadMacro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
2234 *terr = TInterpreter::kFatal;
2235 } else {
2236 err = 0;
2237 if (!check) {
2238 fname = mac;
2239 fname += aclicMode;
2240 fname += io;
2241 gInterpreter->LoadMacro(fname.Data(), (TInterpreter::EErrorCode*)terr);
2242 if (*terr)
2243 err = -1;
2244 }
2245 }
2246 delete [] mac;
2247 }
2248 return err;
2249}
2250
2251////////////////////////////////////////////////////////////////////////////////
2252/// Execute a macro in the interpreter. Equivalent to the command line
2253/// command ".x filename". If the filename has "+" or "++" appended
2254/// the macro will be compiled by ACLiC. The filename must have the format:
2255/// [path/]macro.C[+|++[g|O]][(args)].
2256/// The possible error codes are defined by TInterpreter::EErrorCode.
2257/// If padUpdate is true (default) update the current pad.
2258/// Returns the macro return value.
2259
2260Longptr_t TROOT::Macro(const char *filename, Int_t *error, Bool_t padUpdate)
2261{
2262 Longptr_t result = 0;
2263
2264 if (fInterpreter) {
2265 TString aclicMode;
2266 TString arguments;
2267 TString io;
2268 TString fname = gSystem->SplitAclicMode(filename, aclicMode, arguments, io);
2269
2270 char *mac = gSystem->Which(GetMacroPath(), fname, kReadPermission);
2271 if (!mac) {
2272 Error("Macro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
2273 if (error)
2274 *error = TInterpreter::kFatal;
2275 } else {
2276 fname = mac;
2277 fname += aclicMode;
2278 fname += arguments;
2279 fname += io;
2280 result = gInterpreter->ExecuteMacro(fname, (TInterpreter::EErrorCode*)error);
2281 }
2282 delete [] mac;
2283
2284 if (padUpdate && gPad)
2285 gPad->Update();
2286 }
2287
2288 return result;
2289}
2290
2291////////////////////////////////////////////////////////////////////////////////
2292/// Process message id called by obj.
2293
2294void TROOT::Message(Int_t id, const TObject *obj)
2295{
2296 TIter next(fMessageHandlers);
2297 TMessageHandler *mh;
2298 while ((mh = (TMessageHandler*)next())) {
2299 mh->HandleMessage(id,obj);
2300 }
2301}
2302
2303////////////////////////////////////////////////////////////////////////////////
2304/// Process interpreter command via TApplication::ProcessLine().
2305/// On Win32 the line will be processed asynchronously by sending
2306/// it to the CINT interpreter thread. For explicit synchronous processing
2307/// use ProcessLineSync(). On non-Win32 platforms there is no difference
2308/// between ProcessLine() and ProcessLineSync().
2309/// The possible error codes are defined by TInterpreter::EErrorCode. In
2310/// particular, error will equal to TInterpreter::kProcessing until the
2311/// CINT interpreted thread has finished executing the line.
2312/// Returns the result of the command, cast to a Longptr_t.
2313
2315{
2316 TString sline = line;
2317 sline = sline.Strip(TString::kBoth);
2318
2319 if (!fApplication.load())
2321
2322 return (*fApplication).ProcessLine(sline, kFALSE, error);
2323}
2324
2325////////////////////////////////////////////////////////////////////////////////
2326/// Process interpreter command via TApplication::ProcessLine().
2327/// On Win32 the line will be processed synchronously (i.e. it will
2328/// only return when the CINT interpreter thread has finished executing
2329/// the line). On non-Win32 platforms there is no difference between
2330/// ProcessLine() and ProcessLineSync().
2331/// The possible error codes are defined by TInterpreter::EErrorCode.
2332/// Returns the result of the command, cast to a Longptr_t.
2333
2335{
2336 TString sline = line;
2337 sline = sline.Strip(TString::kBoth);
2338
2339 if (!fApplication.load())
2341
2342 return (*fApplication).ProcessLine(sline, kTRUE, error);
2343}
2344
2345////////////////////////////////////////////////////////////////////////////////
2346/// Process interpreter command directly via CINT interpreter.
2347/// Only executable statements are allowed (no variable declarations),
2348/// In all other cases use TROOT::ProcessLine().
2349/// The possible error codes are defined by TInterpreter::EErrorCode.
2350
2352{
2353 TString sline = line;
2354 sline = sline.Strip(TString::kBoth);
2355
2356 if (!fApplication.load())
2358
2359 Longptr_t result = 0;
2360
2361 if (fInterpreter) {
2363 result = gInterpreter->Calc(sline, code);
2364 }
2365
2366 return result;
2367}
2368
2369////////////////////////////////////////////////////////////////////////////////
2370/// Read Git commit information and branch name from the
2371/// etc/gitinfo.txt file.
2372
2374{
2375#ifdef ROOT_GIT_COMMIT
2376 fGitCommit = ROOT_GIT_COMMIT;
2377#endif
2378#ifdef ROOT_GIT_BRANCH
2379 fGitBranch = ROOT_GIT_BRANCH;
2380#endif
2381
2382 TString gitinfo = "gitinfo.txt";
2383 char *filename = gSystem->ConcatFileName(TROOT::GetEtcDir(), gitinfo);
2384
2385 FILE *fp = fopen(filename, "r");
2386 if (fp) {
2387 TString s;
2388 // read branch name
2389 s.Gets(fp);
2390 fGitBranch = s;
2391 // read commit SHA1
2392 s.Gets(fp);
2393 fGitCommit = s;
2394 // read date/time make was run
2395 s.Gets(fp);
2396 fGitDate = s;
2397 fclose(fp);
2398 }
2399 delete [] filename;
2400}
2401
2403 TTHREAD_TLS(Bool_t) fgReadingObject = false;
2404 return fgReadingObject;
2405}
2406
2407////////////////////////////////////////////////////////////////////////////////
2408/// Deprecated (will be removed in next release).
2409
2411{
2412 return GetReadingObject();
2413}
2414
2416{
2417 GetReadingObject() = flag;
2418}
2419
2420
2421////////////////////////////////////////////////////////////////////////////////
2422/// Return date/time make was run.
2423
2425{
2426 if (fGitDate == "") {
2427 Int_t iday,imonth,iyear, ihour, imin;
2428 static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
2429 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
2430 Int_t idate = gROOT->GetBuiltDate();
2431 Int_t itime = gROOT->GetBuiltTime();
2432 iday = idate%100;
2433 imonth = (idate/100)%100;
2434 iyear = idate/10000;
2435 ihour = itime/100;
2436 imin = itime%100;
2437 fGitDate.Form("%s %02d %4d, %02d:%02d:00", months[imonth-1], iday, iyear, ihour, imin);
2438 }
2439 return fGitDate;
2440}
2441
2442////////////////////////////////////////////////////////////////////////////////
2443/// Recursively remove this object from the list of Cleanups.
2444/// Typically RecursiveRemove is implemented by classes that can contain
2445/// mulitple references to a same object or shared ownership of the object
2446/// with others.
2447
2449{
2451
2453}
2454
2455////////////////////////////////////////////////////////////////////////////////
2456/// Refresh all browsers. Call this method when some command line
2457/// command or script has changed the browser contents. Not needed
2458/// for objects that have the kMustCleanup bit set. Most useful to
2459/// update browsers that show the file system or other objects external
2460/// to the running ROOT session.
2461
2463{
2464 TIter next(GetListOfBrowsers());
2465 TBrowser *b;
2466 while ((b = (TBrowser*) next()))
2467 b->SetRefreshFlag(kTRUE);
2468}
2469////////////////////////////////////////////////////////////////////////////////
2470/// Insure that the files, canvases and sockets are closed.
2471
2472static void CallCloseFiles()
2473{
2475 gROOT->CloseFiles();
2476 }
2477}
2478
2479////////////////////////////////////////////////////////////////////////////////
2480/// Called by static dictionary initialization to register clang modules
2481/// for headers. Calls TCling::RegisterModule() unless gCling
2482/// is NULL, i.e. during startup, where the information is buffered in
2483/// the static GetModuleHeaderInfoBuffer().
2484
2485void TROOT::RegisterModule(const char* modulename,
2486 const char** headers,
2487 const char** includePaths,
2488 const char* payloadCode,
2489 const char* fwdDeclCode,
2490 void (*triggerFunc)(),
2491 const TInterpreter::FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
2492 const char** classesHeaders,
2493 bool hasCxxModule)
2494{
2495
2496 // First a side track to insure proper end of process behavior.
2497
2498 // Register for each loaded dictionary (and thus for each library),
2499 // that we need to Close the ROOT files as soon as this library
2500 // might start being unloaded after main.
2501 //
2502 // By calling atexit here (rather than directly from within the
2503 // library) we make sure that this is not called if the library is
2504 // 'only' dlclosed.
2505
2506 // On Ubuntu the linker strips the unused libraries. Eventhough
2507 // stressHistogram is explicitly linked against libNet, it is not
2508 // retained and thus is loaded only as needed in the middle part of
2509 // the execution. Concretely this also means that it is loaded
2510 // *after* the construction of the TApplication object and thus
2511 // after the registration (atexit) of the EndOfProcessCleanups
2512 // routine. Consequently, after the end of main, libNet is
2513 // unloaded before EndOfProcessCleanups is called. When
2514 // EndOfProcessCleanups is executed it indirectly needs the TClass
2515 // for TSocket and its search will use resources that have already
2516 // been unloaded (technically the function static in TUnixSystem's
2517 // DynamicPath and the dictionary from libNet).
2518
2519 // Similarly, the ordering (before this commit) was broken in the
2520 // following case:
2521
2522 // TApplication creation (EndOfProcessCleanups registration)
2523 // load UserLibrary
2524 // create TFile
2525 // Append UserObject to TFile
2526
2527 // and after the end of main the order of execution was
2528
2529 // unload UserLibrary
2530 // call EndOfProcessCleanups
2531 // Write the TFile
2532 // attempt to write the user object.
2533 // ....
2534
2535 // where what we need is to have the files closen/written before
2536 // the unloading of the library.
2537
2538 // To solve the problem we now register an atexit function for
2539 // every dictionary thus making sure there is at least one executed
2540 // before the first library tear down after main.
2541
2542 // If atexit is called directly within a library's code, the
2543 // function will called *either* when the library is 'dlclose'd or
2544 // after then end of main (whichever comes first). We do *not*
2545 // want the files to be closed whenever a library is unloaded via
2546 // dlclose. To avoid this, we add the function (CallCloseFiles)
2547 // from the dictionary indirectly (via ROOT::RegisterModule). In
2548 // this case the function will only only be called either when
2549 // libCore is 'dlclose'd or right after the end of main.
2550
2551 atexit(CallCloseFiles);
2552
2553 // Now register with TCling.
2554 if (TROOT::Initialized()) {
2555 gCling->RegisterModule(modulename, headers, includePaths, payloadCode, fwdDeclCode, triggerFunc,
2556 fwdDeclsArgToSkip, classesHeaders, false, hasCxxModule);
2557 } else {
2558 GetModuleHeaderInfoBuffer().push_back(ModuleHeaderInfo_t(modulename, headers, includePaths, payloadCode,
2559 fwdDeclCode, triggerFunc, fwdDeclsArgToSkip,
2560 classesHeaders, hasCxxModule));
2561 }
2562}
2563
2564////////////////////////////////////////////////////////////////////////////////
2565/// Remove an object from the in-memory list.
2566/// Since TROOT is global resource, this is lock protected.
2567
2569{
2571 return TDirectory::Remove(obj);
2572}
2573
2574////////////////////////////////////////////////////////////////////////////////
2575/// Remove a class from the list and map of classes.
2576/// This routine is deprecated, use TClass::RemoveClass directly.
2577
2579{
2580 TClass::RemoveClass(oldcl);
2581}
2582
2583////////////////////////////////////////////////////////////////////////////////
2584/// Delete all global interpreter objects created since the last call to Reset
2585///
2586/// If option="a" is set reset to startup context (i.e. unload also
2587/// all loaded files, classes, structs, typedefs, etc.).
2588///
2589/// This function is typically used at the beginning (or end) of an unnamed macro
2590/// to clean the environment.
2591///
2592/// IMPORTANT WARNING:
2593/// Do not use this call from within any function (neither compiled nor
2594/// interpreted. This should only be used from a unnamed macro
2595/// (which starts with a { (curly braces) ). For example, using TROOT::Reset
2596/// from within an interpreted function will lead to the unloading of the
2597/// dictionary and source file, including the one defining the function being
2598/// executed.
2599///
2600
2602{
2603 if (IsExecutingMacro()) return; //True when TMacro::Exec runs
2604 if (fInterpreter) {
2605 if (!strncmp(option, "a", 1)) {
2608 } else
2609 gInterpreter->ResetGlobals();
2610
2611 if (fGlobals) fGlobals->Unload();
2613
2614 SaveContext();
2615 }
2616}
2617
2618////////////////////////////////////////////////////////////////////////////////
2619/// Save the current interpreter context.
2620
2622{
2623 if (fInterpreter)
2624 gInterpreter->SaveGlobalsContext();
2625}
2626
2627////////////////////////////////////////////////////////////////////////////////
2628/// Set the default graphical cut class name for the graphics editor
2629/// By default the graphics editor creates an instance of a class TCutG.
2630/// This function may be called to specify a different class that MUST
2631/// derive from TCutG
2632
2634{
2635 if (!name) {
2636 Error("SetCutClassName","Invalid class name");
2637 return;
2638 }
2640 if (!cl) {
2641 Error("SetCutClassName","Unknown class:%s",name);
2642 return;
2643 }
2644 if (!cl->InheritsFrom("TCutG")) {
2645 Error("SetCutClassName","Class:%s does not derive from TCutG",name);
2646 return;
2647 }
2649}
2650
2651////////////////////////////////////////////////////////////////////////////////
2652/// Set editor mode
2653
2654void TROOT::SetEditorMode(const char *mode)
2655{
2656 fEditorMode = 0;
2657 if (!mode[0]) return;
2658 if (!strcmp(mode,"Arc")) {fEditorMode = kArc; return;}
2659 if (!strcmp(mode,"Line")) {fEditorMode = kLine; return;}
2660 if (!strcmp(mode,"Arrow")) {fEditorMode = kArrow; return;}
2661 if (!strcmp(mode,"Button")) {fEditorMode = kButton; return;}
2662 if (!strcmp(mode,"Diamond")) {fEditorMode = kDiamond; return;}
2663 if (!strcmp(mode,"Ellipse")) {fEditorMode = kEllipse; return;}
2664 if (!strcmp(mode,"Pad")) {fEditorMode = kPad; return;}
2665 if (!strcmp(mode,"Pave")) {fEditorMode = kPave; return;}
2666 if (!strcmp(mode,"PaveLabel")){fEditorMode = kPaveLabel; return;}
2667 if (!strcmp(mode,"PaveText")) {fEditorMode = kPaveText; return;}
2668 if (!strcmp(mode,"PavesText")){fEditorMode = kPavesText; return;}
2669 if (!strcmp(mode,"PolyLine")) {fEditorMode = kPolyLine; return;}
2670 if (!strcmp(mode,"CurlyLine")){fEditorMode = kCurlyLine; return;}
2671 if (!strcmp(mode,"CurlyArc")) {fEditorMode = kCurlyArc; return;}
2672 if (!strcmp(mode,"Text")) {fEditorMode = kText; return;}
2673 if (!strcmp(mode,"Marker")) {fEditorMode = kMarker; return;}
2674 if (!strcmp(mode,"CutG")) {fEditorMode = kCutG; return;}
2675}
2676
2677////////////////////////////////////////////////////////////////////////////////
2678/// Change current style to style with name stylename
2679
2680void TROOT::SetStyle(const char *stylename)
2681{
2682 TString style_name = stylename;
2683
2684 TStyle *style = GetStyle(style_name);
2685 if (style) style->cd();
2686 else Error("SetStyle","Unknown style:%s",style_name.Data());
2687}
2688
2689
2690//-------- Static Member Functions ---------------------------------------------
2691
2692
2693////////////////////////////////////////////////////////////////////////////////
2694/// Decrease the indentation level for ls().
2695
2697{
2698 return --fgDirLevel;
2699}
2700
2701////////////////////////////////////////////////////////////////////////////////
2702///return directory level
2703
2705{
2706 return fgDirLevel;
2707}
2708
2709////////////////////////////////////////////////////////////////////////////////
2710/// Get macro search path. Static utility function.
2711
2713{
2714 TString &macroPath = ROOT::GetMacroPath();
2715
2716 if (macroPath.Length() == 0) {
2717 macroPath = gEnv->GetValue("Root.MacroPath", (char*)nullptr);
2718#if defined(R__WIN32)
2719 macroPath.ReplaceAll("; ", ";");
2720#else
2721 macroPath.ReplaceAll(": ", ":");
2722#endif
2723 if (macroPath.Length() == 0)
2724#if !defined(R__WIN32)
2725 macroPath = ".:" + TROOT::GetMacroDir();
2726#else
2727 macroPath = ".;" + TROOT::GetMacroDir();
2728#endif
2729 }
2730
2731 return macroPath;
2732}
2733
2734////////////////////////////////////////////////////////////////////////////////
2735/// Set or extend the macro search path. Static utility function.
2736/// If newpath=0 or "" reset to value specified in the rootrc file.
2737
2738void TROOT::SetMacroPath(const char *newpath)
2739{
2740 TString &macroPath = ROOT::GetMacroPath();
2741
2742 if (!newpath || !*newpath)
2743 macroPath = "";
2744 else
2745 macroPath = newpath;
2746}
2747
2748////////////////////////////////////////////////////////////////////////////////
2749/// \brief Specify where web graphics shall be rendered
2750///
2751/// The input parameter `webdisplay` defines where web graphics is rendered.
2752/// `webdisplay` parameter may contain:
2753///
2754/// - "off": turns off the web display and comes back to normal graphics in
2755/// interactive mode.
2756/// - "batch": turns the web display in batch mode. It can be prepended with
2757/// another string which is considered as the new current web display.
2758/// - "nobatch": turns the web display in interactive mode. It can be
2759/// prepended with another string which is considered as the new current web display.
2760///
2761/// If the option "off" is not set, this method turns the normal graphics to
2762/// "Batch" to avoid the loading of local graphics libraries.
2763
2764void TROOT::SetWebDisplay(const char *webdisplay)
2765{
2766 const char *wd = webdisplay;
2767 if (!wd)
2768 wd = "";
2769
2770 if (!strcmp(wd, "off")) {
2773 fWebDisplay = "";
2774 } else {
2776 if (!strncmp(wd, "batch", 5)) {
2778 wd += 5;
2779 } else if (!strncmp(wd, "nobatch", 7)) {
2781 wd += 7;
2782 } else {
2784 }
2785 fWebDisplay = wd;
2786 }
2787}
2788
2789////////////////////////////////////////////////////////////////////////////////
2790/// Increase the indentation level for ls().
2791
2793{
2794 return ++fgDirLevel;
2795}
2796
2797////////////////////////////////////////////////////////////////////////////////
2798/// Functions used by ls() to indent an object hierarchy.
2799
2801{
2802 for (int i = 0; i < fgDirLevel; i++) std::cout.put(' ');
2803}
2804
2805////////////////////////////////////////////////////////////////////////////////
2806/// Initialize ROOT explicitly.
2807
2809 (void) gROOT;
2810}
2811
2812////////////////////////////////////////////////////////////////////////////////
2813/// Return kTRUE if the TROOT object has been initialized.
2814
2816{
2817 return fgRootInit;
2818}
2819
2820////////////////////////////////////////////////////////////////////////////////
2821/// Return Indentation level for ls().
2822
2824{
2825 fgDirLevel = level;
2826}
2827
2828////////////////////////////////////////////////////////////////////////////////
2829/// Convert version code to an integer, i.e. 331527 -> 51507.
2830
2832{
2833 return 10000*(code>>16) + 100*((code&65280)>>8) + (code&255);
2834}
2835
2836////////////////////////////////////////////////////////////////////////////////
2837/// Convert version as an integer to version code as used in RVersion.h.
2838
2840{
2841 int a = v/10000;
2842 int b = (v - a*10000)/100;
2843 int c = v - a*10000 - b*100;
2844 return (a << 16) + (b << 8) + c;
2845}
2846
2847////////////////////////////////////////////////////////////////////////////////
2848/// Return ROOT version code as defined in RVersion.h.
2849
2851{
2852 return ROOT_VERSION_CODE;
2853}
2854////////////////////////////////////////////////////////////////////////////////
2855/// Provide command line arguments to the interpreter construction.
2856/// These arguments are added to the existing flags (e.g. `-DNDEBUG`).
2857/// They are evaluated once per process, at the time where TROOT (and thus
2858/// TInterpreter) is constructed.
2859/// Returns the new flags.
2860
2861const std::vector<std::string> &TROOT::AddExtraInterpreterArgs(const std::vector<std::string> &args) {
2862 static std::vector<std::string> sArgs = {};
2863 sArgs.insert(sArgs.begin(), args.begin(), args.end());
2864 return sArgs;
2865}
2866
2867////////////////////////////////////////////////////////////////////////////////
2868/// INTERNAL function!
2869/// Used by rootcling to inject interpreter arguments through a C-interface layer.
2870
2872 static const char** extraInterpArgs = nullptr;
2873 return extraInterpArgs;
2874}
2875
2876////////////////////////////////////////////////////////////////////////////////
2877
2878#ifdef ROOTPREFIX
2879static Bool_t IgnorePrefix() {
2880 static Bool_t ignorePrefix = gSystem->Getenv("ROOTIGNOREPREFIX");
2881 return ignorePrefix;
2882}
2883#endif
2884
2885////////////////////////////////////////////////////////////////////////////////
2886/// Get the rootsys directory in the installation. Static utility function.
2887
2889 // Avoid returning a reference to a temporary because of the conversion
2890 // between std::string and TString.
2891 const static TString rootsys = ROOT::FoundationUtils::GetRootSys();
2892 return rootsys;
2893}
2894
2895////////////////////////////////////////////////////////////////////////////////
2896/// Get the binary directory in the installation. Static utility function.
2897
2899#ifdef ROOTBINDIR
2900 if (IgnorePrefix()) {
2901#endif
2902 static TString rootbindir;
2903 if (rootbindir.IsNull()) {
2904 rootbindir = "bin";
2905 gSystem->PrependPathName(GetRootSys(), rootbindir);
2906 }
2907 return rootbindir;
2908#ifdef ROOTBINDIR
2909 } else {
2910 const static TString rootbindir = ROOTBINDIR;
2911 return rootbindir;
2912 }
2913#endif
2914}
2915
2916////////////////////////////////////////////////////////////////////////////////
2917/// Get the library directory in the installation. Static utility function.
2918
2920#ifdef ROOTLIBDIR
2921 if (IgnorePrefix()) {
2922#endif
2923 static TString rootlibdir;
2924 if (rootlibdir.IsNull()) {
2925 rootlibdir = "lib";
2926 gSystem->PrependPathName(GetRootSys(), rootlibdir);
2927 }
2928 return rootlibdir;
2929#ifdef ROOTLIBDIR
2930 } else {
2931 const static TString rootlibdir = ROOTLIBDIR;
2932 return rootlibdir;
2933 }
2934#endif
2935}
2936
2937////////////////////////////////////////////////////////////////////////////////
2938/// Get the include directory in the installation. Static utility function.
2939
2941 // Avoid returning a reference to a temporary because of the conversion
2942 // between std::string and TString.
2943 const static TString includedir = ROOT::FoundationUtils::GetIncludeDir();
2944 return includedir;
2945}
2946
2947////////////////////////////////////////////////////////////////////////////////
2948/// Get the sysconfig directory in the installation. Static utility function.
2949
2951 // Avoid returning a reference to a temporary because of the conversion
2952 // between std::string and TString.
2953 const static TString etcdir = ROOT::FoundationUtils::GetEtcDir();
2954 return etcdir;
2955}
2956
2957////////////////////////////////////////////////////////////////////////////////
2958/// Get the data directory in the installation. Static utility function.
2959
2961#ifdef ROOTDATADIR
2962 if (IgnorePrefix()) {
2963#endif
2964 return GetRootSys();
2965#ifdef ROOTDATADIR
2966 } else {
2967 const static TString rootdatadir = ROOTDATADIR;
2968 return rootdatadir;
2969 }
2970#endif
2971}
2972
2973////////////////////////////////////////////////////////////////////////////////
2974/// Get the documentation directory in the installation. Static utility function.
2975
2977#ifdef ROOTDOCDIR
2978 if (IgnorePrefix()) {
2979#endif
2980 return GetRootSys();
2981#ifdef ROOTDOCDIR
2982 } else {
2983 const static TString rootdocdir = ROOTDOCDIR;
2984 return rootdocdir;
2985 }
2986#endif
2987}
2988
2989////////////////////////////////////////////////////////////////////////////////
2990/// Get the macro directory in the installation. Static utility function.
2991
2993#ifdef ROOTMACRODIR
2994 if (IgnorePrefix()) {
2995#endif
2996 static TString rootmacrodir;
2997 if (rootmacrodir.IsNull()) {
2998 rootmacrodir = "macros";
2999 gSystem->PrependPathName(GetRootSys(), rootmacrodir);
3000 }
3001 return rootmacrodir;
3002#ifdef ROOTMACRODIR
3003 } else {
3004 const static TString rootmacrodir = ROOTMACRODIR;
3005 return rootmacrodir;
3006 }
3007#endif
3008}
3009
3010////////////////////////////////////////////////////////////////////////////////
3011/// Get the tutorials directory in the installation. Static utility function.
3012
3014#ifdef ROOTTUTDIR
3015 if (IgnorePrefix()) {
3016#endif
3017 static TString roottutdir;
3018 if (roottutdir.IsNull()) {
3019 roottutdir = "tutorials";
3020 gSystem->PrependPathName(GetRootSys(), roottutdir);
3021 }
3022 return roottutdir;
3023#ifdef ROOTTUTDIR
3024 } else {
3025 const static TString roottutdir = ROOTTUTDIR;
3026 return roottutdir;
3027 }
3028#endif
3029}
3030
3031////////////////////////////////////////////////////////////////////////////////
3032/// Shut down ROOT.
3033
3035{
3036 if (gROOT)
3037 gROOT->EndOfProcessCleanups();
3038 else if (gInterpreter)
3039 gInterpreter->ShutDown();
3040}
3041
3042////////////////////////////////////////////////////////////////////////////////
3043/// Get the source directory in the installation. Static utility function.
3044
3046#ifdef ROOTSRCDIR
3047 if (IgnorePrefix()) {
3048#endif
3049 static TString rootsrcdir;
3050 if (rootsrcdir.IsNull()) {
3051 rootsrcdir = "src";
3052 gSystem->PrependPathName(GetRootSys(), rootsrcdir);
3053 }
3054 return rootsrcdir;
3055#ifdef ROOTSRCDIR
3056 } else {
3057 const static TString rootsrcdir = ROOTSRCDIR;
3058 return rootsrcdir;
3059 }
3060#endif
3061}
3062
3063////////////////////////////////////////////////////////////////////////////////
3064/// Get the icon path in the installation. Static utility function.
3065
3067#ifdef ROOTICONPATH
3068 if (IgnorePrefix()) {
3069#endif
3070 static TString rooticonpath;
3071 if (rooticonpath.IsNull()) {
3072 rooticonpath = "icons";
3073 gSystem->PrependPathName(GetRootSys(), rooticonpath);
3074 }
3075 return rooticonpath;
3076#ifdef ROOTICONPATH
3077 } else {
3078 const static TString rooticonpath = ROOTICONPATH;
3079 return rooticonpath;
3080 }
3081#endif
3082}
3083
3084////////////////////////////////////////////////////////////////////////////////
3085/// Get the fonts directory in the installation. Static utility function.
3086
3088#ifdef TTFFONTDIR
3089 if (IgnorePrefix()) {
3090#endif
3091 static TString ttffontdir;
3092 if (ttffontdir.IsNull()) {
3093 ttffontdir = "fonts";
3094 gSystem->PrependPathName(GetRootSys(), ttffontdir);
3095 }
3096 return ttffontdir;
3097#ifdef TTFFONTDIR
3098 } else {
3099 const static TString ttffontdir = TTFFONTDIR;
3100 return ttffontdir;
3101 }
3102#endif
3103}
3104
3105////////////////////////////////////////////////////////////////////////////////
3106/// Get the tutorials directory in the installation. Static utility function.
3107/// Backward compatibility function - do not use for new code
3108
3110 return GetTutorialDir();
3111}
@ kMarker
Definition: Buttons.h:34
@ kCurlyArc
Definition: Buttons.h:38
@ kPad
Definition: Buttons.h:30
@ kPolyLine
Definition: Buttons.h:28
@ kDiamond
Definition: Buttons.h:37
@ kPave
Definition: Buttons.h:31
@ kArrow
Definition: Buttons.h:33
@ kPaveText
Definition: Buttons.h:32
@ kCutG
Definition: Buttons.h:38
@ kLine
Definition: Buttons.h:33
@ kPavesText
Definition: Buttons.h:32
@ kCurlyLine
Definition: Buttons.h:38
@ kPaveLabel
Definition: Buttons.h:31
@ kButton
Definition: Buttons.h:37
@ kEllipse
Definition: Buttons.h:32
@ kText
Definition: Buttons.h:30
@ kArc
Definition: Buttons.h:33
int Int_t
Definition: CPyCppyy.h:43
unsigned int UInt_t
Definition: CPyCppyy.h:44
The file contains utilities which are foundational and could be used across the core component of ROO...
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
#define SafeDelete(p)
Definition: RConfig.hxx:536
#define d(i)
Definition: RSha256.hxx:102
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define c(i)
Definition: RSha256.hxx:101
#define g(i)
Definition: RSha256.hxx:105
#define ROOT_RELEASE
Definition: RVersion.h:17
#define ROOT_RELEASE_TIME
Definition: RVersion.h:19
#define ROOT_VERSION_CODE
Definition: RVersion.h:21
#define ROOT_RELEASE_DATE
Definition: RVersion.h:18
const Ssiz_t kNPOS
Definition: RtypesCore.h:124
long Longptr_t
Definition: RtypesCore.h:82
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:364
void(* VoidFuncPtr_t)()
Definition: Rtypes.h:79
R__EXTERN TClassTable * gClassTable
Definition: TClassTable.h:95
R__DLLEXPORT TInterpreter * CreateInterpreter(void *interpLibHandle, const char *argv[])
Definition: TCling.cxx:597
#define gDirectory
Definition: TDirectory.h:327
R__EXTERN TEnv * gEnv
Definition: TEnv.h:170
void DefaultErrorHandler(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
The default error handler function.
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
Definition: TError.cxx:92
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition: TGuiFactory.h:67
R__EXTERN TGuiFactory * gGuiFactory
Definition: TGuiFactory.h:66
R__EXTERN TVirtualMutex * gInterpreterMutex
Definition: TInterpreter.h:44
TInterpreter * CreateInterpreter_t(void *shlibHandle, const char *argv[])
Definition: TInterpreter.h:556
R__EXTERN TInterpreter * gCling
Definition: TInterpreter.h:561
#define gInterpreter
Definition: TInterpreter.h:560
void * DestroyInterpreter_t(TInterpreter *)
Definition: TInterpreter.h:557
R__EXTERN TPluginManager * gPluginMgr
Bool_t & GetReadingObject()
Definition: TROOT.cxx:2402
static Int_t IVERSQ()
Return version id as an integer, i.e. "2.22/04" -> 22204.
Definition: TROOT.cxx:183
static Int_t IDATQQ(const char *date)
Return built date as integer, i.e. "Apr 28 2000" -> 20000428.
Definition: TROOT.cxx:193
static TClass * R__GetClassIfKnown(const char *className)
Check whether className is a known class, and only autoload if we can.
Definition: TROOT.cxx:1851
static DestroyInterpreter_t * gDestroyInterpreter
Definition: TROOT.cxx:169
Int_t gDebug
Definition: TROOT.cxx:589
static void * gInterpreterLib
Definition: TROOT.cxx:170
static Int_t ITIMQQ(const char *time)
Return built time as integer (with min precision), i.e.
Definition: TROOT.cxx:214
static void at_exit_of_TROOT()
Definition: TROOT.cxx:288
TVirtualMutex * gROOTMutex
Definition: TROOT.cxx:173
static void CleanUpROOTAtExit()
Clean up at program termination before global objects go out of scope.
Definition: TROOT.cxx:224
static void CallCloseFiles()
Insure that the files, canvases and sockets are closed.
Definition: TROOT.cxx:2472
void R__SetZipMode(int)
#define gROOT
Definition: TROOT.h:404
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
void(* Func_t)()
Definition: TSystem.h:238
R__EXTERN const char * gRootDir
Definition: TSystem.h:241
@ kReadPermission
Definition: TSystem.h:47
Bool_t R_ISREG(Int_t mode)
Definition: TSystem.h:118
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
R__EXTERN TVirtualMutex * gGlobalMutex
Definition: TVirtualMutex.h:27
#define R__LOCKGUARD(mutex)
#define gPad
Definition: TVirtualPad.h:287
#define R__READ_LOCKGUARD(mutex)
#define gVirtualX
Definition: TVirtualX.h:338
R__EXTERN TVirtualX * gGXBatch
Definition: TVirtualX.h:341
const char * proto
Definition: civetweb.c:16604
char fHolder[sizeof(TROOT)]
Definition: TROOT.cxx:330
static void CreateApplication()
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
The Canvas class.
Definition: TCanvas.h:23
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition: TCanvas.cxx:706
Objects following this interface can be passed onto the TROOT object to implement a user customized w...
This class registers for all classes their name, id and dictionary function in a hash table.
Definition: TClassTable.h:36
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
ClassInfo_t * GetClassInfo() const
Definition: TClass.h:430
static void AddClass(TClass *cl)
static: Add a class to the list and map of classes.
Definition: TClass.cxx:494
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Definition: TClass.cxx:5742
Short_t GetDeclFileLine() const
Definition: TClass.h:426
static void RemoveClass(TClass *cl)
static: Remove a class from the list and map of classes
Definition: TClass.cxx:520
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition: TClass.cxx:4867
const char * GetDeclFileName() const
Return name of the file containing the declaration of this class.
Definition: TClass.cxx:3416
@ kClassSaved
Definition: TClass.h:94
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:2955
Collection abstract base class.
Definition: TCollection.h:63
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual bool UseRWLock()
Set this collection to use a RW lock upon access, making it thread safe.
virtual void Clear(Option_t *option="")=0
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
virtual void Delete(Option_t *option="")=0
Delete this object.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Add(TObject *obj)=0
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
The color creation and management class.
Definition: TColor.h:19
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition: TColor.cxx:1095
Int_t GetNumber() const
Definition: TColor.h:55
Basic data type descriptor (datatype information is obtained from CINT).
Definition: TDataType.h:44
Describe directory structure in memory.
Definition: TDirectory.h:45
virtual void Close(Option_t *option="")
Delete all objects from memory and directory structure itself.
Definition: TDirectory.cxx:593
virtual TList * GetList() const
Definition: TDirectory.h:213
void ls(Option_t *option="") const override
List Directory contents.
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
Definition: TDirectory.cxx:191
void SetName(const char *newname) override
Set the name for directory If the directory name is changed after the directory was written once,...
void BuildDirectory(TFile *motherFile, TDirectory *motherDir)
Initialise directory to defaults.
Definition: TDirectory.cxx:238
static std::atomic< TDirectory * > & CurrentDirectory()
Return the current directory for the current thread.
Definition: TDirectory.cxx:387
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
TList * fList
Definition: TDirectory.h:138
The TEnv class reads config files, by default named .rootrc.
Definition: TEnv.h:124
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
A TFolder object is a collection of objects and folders.
Definition: TFolder.h:30
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:188
virtual TObject * FindObjectAny(const char *name) const
Return a pointer to the first object with name starting at this folder.
Definition: TFolder.cxx:349
Dictionary for function template This class describes one single function template.
Global functions class (global functions are obtained from CINT).
Definition: TFunction.h:30
static void MakeFunctor(const char *name, const char *type, GlobFunc &func)
Definition: TGlobal.h:73
static TList & GetEarlyRegisteredGlobals()
Returns list collected globals Used to storeTGlobalMappedFunctions from other libs,...
Definition: TGlobal.cxx:185
Global variables class (global variables are obtained from CINT).
Definition: TGlobal.h:28
This ABC is a factory for GUI components.
Definition: TGuiFactory.h:42
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
THashTable implements a hash table to store TObject's.
Definition: THashTable.h:35
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, Bool_t hasCxxModule=false)=0
virtual void Reset()=0
virtual void Initialize()=0
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
Definition: TInterpreter.h:137
virtual void SaveContext()=0
TDictionary::DeclId_t DeclId_t
Definition: TInterpreter.h:288
Option_t * GetOption() const
Definition: TCollection.h:251
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
virtual void Delete(Option_t *option="")
Delete all TDataMember object files.
void Unload()
Mark 'all func' as being unloaded.
TDictionary * Get(DeclId_t id)
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
void Load()
Load all the DataMembers known to the interpreter for the scope 'fClass' into this collection.
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
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...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunction * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
void Load()
Load all the functions known to the interpreter for the scope 'fClass' into this collection.
void Unload()
Mark 'all func' as being unloaded.
virtual void Delete(Option_t *option="")
Delete all TFunction object files.
A collection of TDataType designed to hold the typedef information and numerical type information.
Definition: TListOfTypes.h:31
A doubly linked list.
Definition: TList.h:44
virtual TObjLink * FirstLink() const
Definition: TList.h:108
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:470
virtual void AddLast(TObject *obj)
Add object at the end of the list.
Definition: TList.cxx:152
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:402
Handle messages that might be generated by the system.
virtual void HandleMessage(Long_t id, const TObject *obj)
Store message origin, keep statistics and call Notify().
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
An array of TObjects.
Definition: TObjArray.h:37
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
Mother of all ROOT objects.
Definition: TObject.h:37
static void SetObjectStat(Bool_t stat)
Turn on/off tracking of objects in the TObjectTable.
Definition: TObject.cxx:974
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
@ kNotDeleted
object has not been deleted
Definition: TObject.h:78
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:879
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:323
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:921
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition: TObject.h:68
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition: TObject.h:60
This class implements a plugin library manager.
void LoadHandlersFromEnv(TEnv *env)
Load plugin handlers specified in config file, like:
static void Cleanup()
static function (called by TROOT destructor) to delete all TProcessIDs
Definition: TProcessID.cxx:204
static TProcessID * AddProcessID()
Static function to add a new TProcessID to the list of PIDs.
Definition: TProcessID.cxx:116
This class is a specialized TProcessID managing the list of UUIDs.
Definition: TProcessUUID.h:32
static Bool_t BlockAllSignals(Bool_t b)
Block or unblock all signals. Returns the previous block status.
Definition: TQObject.cxx:1057
ROOT top level object description.
Definition: TROOT.h:94
TSeqCollection * GetListOfColors() const
Definition: TROOT.h:232
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2792
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:1872
Int_t fVersionCode
Definition: TROOT.h:115
TSeqCollection * GetListOfBrowsers() const
Definition: TROOT.h:245
void Message(Int_t id, const TObject *obj)
Process message id called by obj.
Definition: TROOT.cxx:2294
void RemoveClass(TClass *)
Remove a class from the list and map of classes.
Definition: TROOT.cxx:2578
TSeqCollection * fProofs
Definition: TROOT.h:162
TCollection * fClassGenerators
Definition: TROOT.h:160
TROOT()
Default ctor.
Definition: TROOT.cxx:597
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:2633
TSeqCollection * fCanvases
Definition: TROOT.h:149
const TObject * fPrimitive
Definition: TROOT.h:138
Bool_t fIsWebDisplay
Definition: TROOT.h:128
TFolder * fRootFolder
Definition: TROOT.h:167
void AddClassGenerator(TClassGenerator *gen)
Add a class generator.
Definition: TROOT.cxx:1014
TSeqCollection * fGeometries
Definition: TROOT.h:154
TString fCutClassName
Definition: TROOT.h:170
TInterpreter * fInterpreter
Definition: TROOT.h:125
TSeqCollection * GetListOfStyles() const
Definition: TROOT.h:241
std::vector< std::pair< std::string, int > > FwdDeclArgsToKeepCollection_t
Definition: TROOT.h:187
Int_t fVersionTime
Definition: TROOT.h:117
void EndOfProcessCleanups()
Execute the cleanups necessary at the end of the process, in particular those that must be executed b...
Definition: TROOT.cxx:1206
Bool_t fBatch
Definition: TROOT.h:126
Bool_t fEscape
Definition: TROOT.h:135
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2898
Int_t fVersionInt
Definition: TROOT.h:114
static const TString & GetIncludeDir()
Get the include directory in the installation. Static utility function.
Definition: TROOT.cxx:2940
Longptr_t ProcessLine(const char *line, Int_t *error=0)
Process interpreter command via TApplication::ProcessLine().
Definition: TROOT.cxx:2314
Longptr_t ProcessLineFast(const char *line, Int_t *error=0)
Process interpreter command directly via CINT interpreter.
Definition: TROOT.cxx:2351
Bool_t fFromPopUp
Definition: TROOT.h:131
TSeqCollection * fSockets
Definition: TROOT.h:148
static const char * GetMacroPath()
Get macro search path. Static utility function.
Definition: TROOT.cxx:2712
TCollection * fFunctions
Definition: TROOT.h:151
void SaveContext()
Save the current interpreter context.
Definition: TROOT.cxx:2621
Bool_t IsExecutingMacro() const
Definition: TROOT.h:280
TDataType * GetType(const char *name, Bool_t load=kFALSE) const
Return pointer to type with name.
Definition: TROOT.cxx:1517
static void Initialize()
Initialize ROOT explicitly.
Definition: TROOT.cxx:2808
TFunction * GetGlobalFunctionWithPrototype(const char *name, const char *proto=0, Bool_t load=kFALSE)
Return pointer to global function by name.
Definition: TROOT.cxx:1662
static void ShutDown()
Shut down ROOT.
Definition: TROOT.cxx:3034
TObject * GetFunction(const char *name) const
Return pointer to function with name.
Definition: TROOT.cxx:1542
static Int_t ConvertVersionCode2Int(Int_t code)
Convert version code to an integer, i.e. 331527 -> 51507.
Definition: TROOT.cxx:2831
TSeqCollection * fMessageHandlers
Definition: TROOT.h:158
void SetStyle(const char *stylename="Default")
Change current style to style with name stylename.
Definition: TROOT.cxx:2680
AListOfEnums_t fEnums
Definition: TROOT.h:165
void ReadGitInfo()
Read Git commit information and branch name from the etc/gitinfo.txt file.
Definition: TROOT.cxx:2373
static Bool_t fgRootInit
Definition: TROOT.h:103
void RefreshBrowsers()
Refresh all browsers.
Definition: TROOT.cxx:2462
void CloseFiles()
Close any files and sockets that gROOT knows about.
Definition: TROOT.cxx:1128
std::atomic< TApplication * > fApplication
Definition: TROOT.h:124
const char * FindObjectPathName(const TObject *obj) const
Return path name of obj somewhere in the //root/...
Definition: TROOT.cxx:1428
static Int_t ConvertVersionInt2Code(Int_t v)
Convert version as an integer to version code as used in RVersion.h.
Definition: TROOT.cxx:2839
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition: TROOT.cxx:3087
Bool_t fForceStyle
Definition: TROOT.h:133
TCanvas * MakeDefCanvas() const
Return a default canvas.
Definition: TROOT.cxx:1509
TCollection * fTypes
Definition: TROOT.h:141
TColor * GetColor(Int_t color) const
Return address of color with index color.
Definition: TROOT.cxx:1491
TGlobal * GetGlobal(const char *name, Bool_t load=kFALSE) const
Return pointer to global variable by name.
Definition: TROOT.cxx:1575
TClass * FindSTLClass(const char *name, Bool_t load, Bool_t silent=kFALSE) const
return a TClass object corresponding to 'name' assuming it is an STL container.
Definition: TROOT.cxx:1439
TSeqCollection * fStreamerInfo
Definition: TROOT.h:159
static const TString & GetIconPath()
Get the icon path in the installation. Static utility function.
Definition: TROOT.cxx:3066
TCollection * GetListOfGlobalFunctions(Bool_t load=kFALSE)
Return list containing the TFunctions currently defined.
Definition: TROOT.cxx:1770
TString fGitDate
Definition: TROOT.h:122
TSeqCollection * fSpecials
Definition: TROOT.h:156
TCollection * GetListOfFunctionTemplates()
Definition: TROOT.cxx:1715
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, bool hasCxxModule=false)
Called by static dictionary initialization to register clang modules for headers.
Definition: TROOT.cxx:2485
TCollection * fClasses
Definition: TROOT.h:140
Bool_t fEditHistograms
Definition: TROOT.h:130
TListOfDataMembers * fGlobals
Definition: TROOT.h:143
TListOfFunctionTemplates * fFuncTemplate
Definition: TROOT.h:142
Int_t fTimer
Definition: TROOT.h:123
TSeqCollection * fDataSets
Definition: TROOT.h:164
TString fConfigOptions
Definition: TROOT.h:111
TStyle * GetStyle(const char *name) const
Return pointer to style with name.
Definition: TROOT.cxx:1534
TCollection * GetListOfEnums(Bool_t load=kFALSE)
Definition: TROOT.cxx:1698
void InitInterpreter()
Initialize the interpreter.
Definition: TROOT.cxx:2008
TCollection * GetListOfGlobals(Bool_t load=kFALSE)
Return list containing the TGlobals currently defined.
Definition: TROOT.cxx:1732
virtual TObject * FindObjectAnyFile(const char *name) const
Scan the memory lists of all files for an object with name.
Definition: TROOT.cxx:1391
TSeqCollection * GetListOfFiles() const
Definition: TROOT.h:237
TSeqCollection * GetListOfGeometries() const
Definition: TROOT.h:244
static void SetDirLevel(Int_t level=0)
Return Indentation level for ls().
Definition: TROOT.cxx:2823
TSeqCollection * fSecContexts
Definition: TROOT.h:161
TFile * GetFile() const
Definition: TROOT.h:260
TString fWebDisplay
Definition: TROOT.h:127
static const char * GetTutorialsDir()
Get the tutorials directory in the installation.
Definition: TROOT.cxx:3109
TCollection * GetListOfFunctionOverloads(const char *name) const
Return the collection of functions named "name".
Definition: TROOT.cxx:1616
TSeqCollection * fCleanups
Definition: TROOT.h:157
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition: TROOT.cxx:2815
void RecursiveRemove(TObject *obj)
Recursively remove this object from the list of Cleanups.
Definition: TROOT.cxx:2448
Int_t fLineIsProcessing
Definition: TROOT.h:100
static const TString & GetSourceDir()
Get the source directory in the installation. Static utility function.
Definition: TROOT.cxx:3045
static const TString & GetMacroDir()
Get the macro directory in the installation. Static utility function.
Definition: TROOT.cxx:2992
TString fGitCommit
Definition: TROOT.h:120
TSeqCollection * fClosedObjects
Definition: TROOT.h:145
TSeqCollection * fTasks
Definition: TROOT.h:152
void Browse(TBrowser *b)
Add browsable objects to TBrowser.
Definition: TROOT.cxx:1035
TFunction * GetGlobalFunction(const char *name, const char *params=0, Bool_t load=kFALSE)
Return pointer to global function by name.
Definition: TROOT.cxx:1629
TSeqCollection * fClipboard
Definition: TROOT.h:163
const char * GetGitDate()
Return date/time make was run.
Definition: TROOT.cxx:2424
void SetEditorMode(const char *mode="")
Set editor mode.
Definition: TROOT.cxx:2654
static const TString & GetTutorialDir()
Get the tutorials directory in the installation. Static utility function.
Definition: TROOT.cxx:3013
virtual ~TROOT()
Clean up and free resources used by ROOT (files, network sockets, shared memory segments,...
Definition: TROOT.cxx:853
TSeqCollection * fColors
Definition: TROOT.h:153
void Idle(UInt_t idleTimeInSec, const char *command=0)
Execute command when system has been idle for idleTimeInSec seconds.
Definition: TROOT.cxx:1836
Bool_t ReadingObject() const
Deprecated (will be removed in next release).
Definition: TROOT.cxx:2410
TSeqCollection * fStyles
Definition: TROOT.h:150
Int_t fVersionDate
Definition: TROOT.h:116
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
Definition: TROOT.cxx:1026
Int_t fBuiltTime
Definition: TROOT.h:119
static const std::vector< std::string > & AddExtraInterpreterArgs(const std::vector< std::string > &args)
Provide command line arguments to the interpreter construction.
Definition: TROOT.cxx:2861
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:1473
TVirtualPad * fSelectPad
Definition: TROOT.h:139
TSeqCollection * fFiles
Definition: TROOT.h:146
virtual TObject * FindObjectAny(const char *name) const
Return a pointer to the first object with name starting at //root.
Definition: TROOT.cxx:1381
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
Definition: TROOT.cxx:2888
TListOfFunctions * GetGlobalFunctions()
Internal routine returning, and creating if necessary, the list of global function.
Definition: TROOT.cxx:1607
Bool_t fInterrupt
Definition: TROOT.h:134
Bool_t fMustClean
Definition: TROOT.h:132
TObject * Remove(TObject *)
Remove an object from the in-memory list.
Definition: TROOT.cxx:2568
Int_t LoadClass(const char *classname, const char *libname, Bool_t check=kFALSE)
Check if class "classname" is known to the interpreter (in fact, this check is not needed anymore,...
Definition: TROOT.cxx:2127
void AddClass(TClass *cl)
Add a class to the list and map of classes.
Definition: TROOT.cxx:1004
static Int_t RootVersionCode()
Return ROOT version code as defined in RVersion.h.
Definition: TROOT.cxx:2850
TObject * FindSpecialObject(const char *name, void *&where)
Returns address and folder of a ROOT object if it exists.
Definition: TROOT.cxx:1322
void InitSystem()
Initialize operating system interface.
Definition: TROOT.cxx:1922
Bool_t ClassSaved(TClass *cl)
return class status bit kClassSaved for class cl This function is called by the SavePrimitive functio...
Definition: TROOT.cxx:1054
TString fGitBranch
Definition: TROOT.h:121
TCollection * GetListOfTypes(Bool_t load=kFALSE)
Return a dynamic list giving access to all TDataTypes (typedefs) currently defined.
Definition: TROOT.cxx:1809
virtual TObject * FindObject(const char *name) const
Returns address of a ROOT object if it exists.
Definition: TROOT.cxx:1268
static Int_t fgDirLevel
Definition: TROOT.h:102
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:2174
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2800
static const TString & GetDocDir()
Get the documentation directory in the installation. Static utility function.
Definition: TROOT.cxx:2976
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition: TROOT.cxx:2950
Int_t GetNclasses() const
Get number of classes.
Definition: TROOT.cxx:1820
static const char **& GetExtraInterpreterArgs()
INTERNAL function! Used by rootcling to inject interpreter arguments through a C-interface layer.
Definition: TROOT.cxx:2871
static void SetMacroPath(const char *newpath)
Set or extend the macro search path.
Definition: TROOT.cxx:2738
void InitThreads()
Load and initialize thread library.
Definition: TROOT.cxx:1997
TProcessUUID * fUUIDs
Definition: TROOT.h:166
TString fConfigFeatures
Definition: TROOT.h:112
TFunctionTemplate * GetFunctionTemplate(const char *name)
Definition: TROOT.cxx:1562
TPluginManager * fPluginManager
Definition: TROOT.h:169
TObject * GetGeometry(const char *name) const
Return pointer to Geometry with name.
Definition: TROOT.cxx:1691
Bool_t fExecutingMacro
Definition: TROOT.h:136
Int_t fBuiltDate
Definition: TROOT.h:118
Bool_t fIsWebDisplayBatch
Definition: TROOT.h:129
Longptr_t ProcessLineSync(const char *line, Int_t *error=0)
Process interpreter command via TApplication::ProcessLine().
Definition: TROOT.cxx:2334
TSeqCollection * fMappedFiles
Definition: TROOT.h:147
Int_t GetNtypes() const
Get number of types.
Definition: TROOT.cxx:1828
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Definition: TROOT.cxx:2919
void ls(Option_t *option="") const
To list all objects of the application.
Definition: TROOT.cxx:2194
TSeqCollection * fBrowsers
Definition: TROOT.h:155
TString fDefCanvasName
Definition: TROOT.h:171
TListOfFunctions * fGlobalFunctions
Definition: TROOT.h:144
TList * fBrowsables
Definition: TROOT.h:168
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2696
void Reset(Option_t *option="")
Delete all global interpreter objects created since the last call to Reset.
Definition: TROOT.cxx:2601
Int_t fEditorMode
Definition: TROOT.h:137
const char * FindObjectClassName(const char *name) const
Returns class name of a ROOT object including CINT globals.
Definition: TROOT.cxx:1408
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
Definition: TROOT.cxx:2960
void SetWebDisplay(const char *webdisplay)
Specify where web graphics shall be rendered.
Definition: TROOT.cxx:2764
Int_t LoadMacro(const char *filename, Int_t *error=0, Bool_t check=kFALSE)
Load a macro in the interpreter's memory.
Definition: TROOT.cxx:2212
Longptr_t Macro(const char *filename, Int_t *error=0, Bool_t padUpdate=kTRUE)
Execute a macro in the interpreter.
Definition: TROOT.cxx:2260
TString fVersion
Definition: TROOT.h:113
static Int_t GetDirLevel()
return directory level
Definition: TROOT.cxx:2704
void SetReadingObject(Bool_t flag=kTRUE)
Definition: TROOT.cxx:2415
Sequenceable collection abstract base class.
virtual void AddLast(TObject *obj)=0
virtual TObject * Last() const =0
virtual TObject * First() const =0
virtual void Add(TObject *obj)
static void PrintStatistics()
Print memory usage statistics.
Definition: TStorage.cxx:406
Basic string class.
Definition: TString.h:136
Ssiz_t Length() const
Definition: TString.h:410
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2202
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1131
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
@ kBoth
Definition: TString.h:267
@ kIgnoreCase
Definition: TString.h:268
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:916
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:615
const char * Data() const
Definition: TString.h:369
Bool_t IsNull() const
Definition: TString.h:407
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2314
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
TStyle objects may be created to define special styles.
Definition: TStyle.h:29
static void BuildStyles()
Create some standard styles.
Definition: TStyle.cxx:509
Describes an Operating System directory for the browser.
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:266
virtual Func_t DynFindSymbol(const char *module, const char *entry)
Find specific entry point in specified library.
Definition: TSystem.cxx:2042
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1663
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Definition: TSystem.cxx:4241
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1071
virtual void CleanCompiledMacros()
Remove the shared libs produced by the CompileMacro() function.
Definition: TSystem.cxx:4351
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1855
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition: TSystem.cxx:1398
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition: TSystem.cxx:1081
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition: TSystem.cxx:1296
virtual Bool_t Init()
Initialize the OS interface.
Definition: TSystem.cxx:182
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:935
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:872
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition: TSystem.cxx:1546
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition: TSystem.cxx:888
virtual const char * GetError()
Return system error string.
Definition: TSystem.cxx:253
virtual void ResetSignals()
Reset signals handlers to previous behaviour.
Definition: TSystem.cxx:587
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Definition: TSystem.cxx:2018
This class represents a WWW compatible URL.
Definition: TUrl.h:33
This class implements a mutex interface.
Definition: TVirtualMutex.h:32
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Definition: TVirtualPad.cxx:27
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition: TVirtualX.h:46
static TVirtualX *& Instance()
Returns gVirtualX global.
Definition: TVirtualX.cxx:57
TLine * line
TF1 * f1
Definition: legend1.C:11
const std::string & GetIncludeDir()
\ returns the include directory in the installation.
const std::string & GetRootSys()
const std::string & GetEtcDir()
static Func_t GetSymInLibImt(const char *funcname)
Definition: TROOT.cxx:393
static GetROOTFun_t gGetROOT
Definition: TROOT.cxx:391
static Bool_t & IsImplicitMTEnabledImpl()
Keeps track of the status of ImplicitMT w/o resorting to the load of libImt.
Definition: TROOT.cxx:455
R__EXTERN TROOT * gROOTLocal
Definition: TROOT.h:377
void DisableParBranchProcessing()
Globally disables the IMT use case of parallel branch processing, deactivating the corresponding lock...
Definition: TROOT.cxx:426
std::function< const char *()> ErrorSystemMsgHandlerFunc_t
Retrieves the error string associated with the last system error.
Definition: TError.h:59
void MinimalErrorHandler(int level, Bool_t abort, const char *location, const char *msg)
A very simple error handler that is usually replaced by the TROOT default error handler.
Definition: TError.cxx:69
ErrorSystemMsgHandlerFunc_t SetErrorSystemMsgHandler(ErrorSystemMsgHandlerFunc_t h)
Returns the previous system error message handler.
Definition: TError.cxx:59
TROOT *(* GetROOTFun_t)()
Definition: TROOT.cxx:389
void EnableParBranchProcessing()
Globally enables the parallel branch processing, which is a case of implicit multi-threading (IMT) in...
Definition: TROOT.cxx:412
Bool_t IsParBranchProcessingEnabled()
Returns true if parallel branch processing is enabled.
Definition: TROOT.cxx:439
TROOT * GetROOT2()
Definition: TROOT.cxx:379
void ReleaseDefaultErrorHandler()
Destructs resources that are taken by using the default error handler.
TROOT * GetROOT1()
Definition: TROOT.cxx:372
static const std::string name("name")
void Error(const char *location, const char *va_(fmt),...)
Definition: TClingUtils.h:789
void Warning(const char *location, const char *va_(fmt),...)
Definition: TClingUtils.h:819
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: RNumpyDS.hxx:30
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
Definition: TROOT.cxx:524
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
Definition: TROOT.cxx:555
UInt_t GetThreadPoolSize()
Returns the size of ROOT's thread pool.
Definition: TROOT.cxx:562
R__EXTERN TVirtualRWMutex * gCoreMutex
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.
Definition: TROOT.cxx:493
TString & GetMacroPath()
Definition: TROOT.cxx:468
UInt_t GetImplicitMTPoolSize()
Returns the size of the pool used for implicit multi-threading.
Definition: TROOT.cxx:577
TROOT * GetROOT()
Definition: TROOT.cxx:464
void DisableImplicitMT()
Disables the implicit multi-threading in ROOT (see EnableImplicitMT).
Definition: TROOT.cxx:541
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
Definition: TClassEdit.cxx:837
static constexpr double s
static constexpr double mm
Int_t fMode
Definition: TSystem.h:127
TCanvas * style()
Definition: style.C:1
auto * m
Definition: textangle.C:8
auto * l
Definition: textangle.C:4
auto * a
Definition: textangle.C:12
#define sym(otri1, otri2)
Definition: triangle.c:933