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