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