30 #include "RConfigure.h"
51 class TClassGenerator;
54 class TListOfDataMembers;
56 class TListOfFunctions;
57 class TListOfFunctionTemplates;
58 class TFunctionTemplate;
59 class TGlobalMappedFunction;
61 R__EXTERN TVirtualMutex *gROOTMutex;
70 void EnableParBranchProcessing();
71 void DisableParBranchProcessing();
72 Bool_t IsParBranchProcessingEnabled();
73 class TParBranchProcessingRAII {
75 TParBranchProcessingRAII() { EnableParBranchProcessing(); }
76 ~TParBranchProcessingRAII() { DisableParBranchProcessing(); }
80 void EnableParTreeProcessing();
81 void DisableParTreeProcessing();
82 Bool_t IsParTreeProcessingEnabled();
83 class TParTreeProcessingRAII {
85 TParTreeProcessingRAII() { EnableParTreeProcessing(); }
86 ~TParTreeProcessingRAII() { DisableParTreeProcessing(); }
93 void EnableThreadSafety();
96 void EnableImplicitMT(UInt_t numthreads = 0);
97 void DisableImplicitMT();
98 Bool_t IsImplicitMTEnabled();
99 UInt_t GetImplicitMTPoolSize();
102 class TROOT :
public TDirectory {
105 friend TROOT *ROOT::Internal::GetROOT2();
108 Int_t fLineIsProcessing;
110 static Int_t fgDirLevel;
111 static Bool_t fgRootInit;
112 static Bool_t fgMemCheck;
115 TROOT& operator=(
const TROOT&);
118 typedef std::atomic<TListOfEnums*> AListOfEnums_t;
120 TString fConfigOptions;
121 TString fConfigFeatures;
133 std::atomic<TApplication*> fApplication;
134 TInterpreter *fInterpreter;
137 Bool_t fIsWebDisplay;
138 Bool_t fIsWebDisplayBatch;
139 Bool_t fEditHistograms;
142 Bool_t fReadingObject;
146 Bool_t fExecutingMacro;
148 const TObject *fPrimitive;
149 TVirtualPad *fSelectPad;
150 TCollection *fClasses;
152 TListOfFunctionTemplates *fFuncTemplate;
153 TListOfDataMembers*fGlobals;
154 TListOfFunctions*fGlobalFunctions;
155 TSeqCollection *fClosedObjects;
156 TSeqCollection *fFiles;
157 TSeqCollection *fMappedFiles;
158 TSeqCollection *fSockets;
159 TSeqCollection *fCanvases;
160 TSeqCollection *fStyles;
161 TCollection *fFunctions;
162 TSeqCollection *fTasks;
163 TSeqCollection *fColors;
164 TSeqCollection *fGeometries;
165 TSeqCollection *fBrowsers;
166 TSeqCollection *fSpecials;
167 TSeqCollection *fCleanups;
168 TSeqCollection *fMessageHandlers;
169 TSeqCollection *fStreamerInfo;
170 TCollection *fClassGenerators;
171 TSeqCollection *fSecContexts;
172 TSeqCollection *fProofs;
173 TSeqCollection *fClipboard;
174 TSeqCollection *fDataSets;
175 AListOfEnums_t fEnums;
176 TProcessUUID *fUUIDs;
177 TFolder *fRootFolder;
179 TPluginManager *fPluginManager;
180 TString fCutClassName;
181 TString fDefCanvasName;
186 void InitInterpreter();
188 void *
operator new(
size_t l) {
return TObject::operator
new(l); }
189 void *
operator new(
size_t l,
void *ptr) {
return TObject::operator
new(l,ptr); }
191 friend class ::ROOT::Internal::TROOTAllocator;
193 TListOfFunctions*GetGlobalFunctions();
197 typedef std::vector<std::pair<std::string, int> > FwdDeclArgsToKeepCollection_t;
199 TROOT(
const char *name,
const char *title, VoidFuncPtr_t *initfunc = 0);
201 void AddClass(TClass *cl);
202 void AddClassGenerator(TClassGenerator *gen);
203 virtual void Append(TObject *obj, Bool_t replace = kFALSE);
204 void Browse(TBrowser *b);
205 Bool_t ClassSaved(TClass *cl);
207 void EndOfProcessCleanups();
208 virtual TObject *FindObject(
const char *name)
const;
209 virtual TObject *FindObject(
const TObject *obj)
const;
210 virtual TObject *FindObjectAny(
const char *name)
const;
211 virtual TObject *FindObjectAnyFile(
const char *name)
const;
212 TObject *FindSpecialObject(
const char *name,
void *&where);
213 const char *FindObjectClassName(
const char *name)
const;
214 const char *FindObjectPathName(
const TObject *obj)
const;
215 TClass *FindSTLClass(
const char *name, Bool_t load, Bool_t silent = kFALSE)
const;
216 void ForceStyle(Bool_t force = kTRUE) { fForceStyle = force; }
217 Bool_t FromPopUp()
const {
return fFromPopUp; }
218 TPluginManager *GetPluginManager()
const {
return fPluginManager; }
219 TApplication *GetApplication()
const {
return fApplication; }
220 TInterpreter *GetInterpreter()
const {
return fInterpreter; }
221 TClass *GetClass(
const char *name, Bool_t load = kTRUE, Bool_t silent = kFALSE)
const;
222 TClass *GetClass(
const std::type_info &typeinfo, Bool_t load = kTRUE, Bool_t silent = kFALSE)
const;
223 TColor *GetColor(Int_t color)
const;
224 const char *GetConfigOptions()
const {
return fConfigOptions; }
225 const char *GetConfigFeatures()
const {
return fConfigFeatures; }
226 const char *GetCutClassName()
const {
return fCutClassName; }
227 const char *GetDefCanvasName()
const {
return fDefCanvasName; }
228 Bool_t GetEditHistograms()
const {
return fEditHistograms; }
229 Int_t GetEditorMode()
const {
return fEditorMode; }
230 Bool_t GetForceStyle()
const {
return fForceStyle; }
231 Int_t GetBuiltDate()
const {
return fBuiltDate; }
232 Int_t GetBuiltTime()
const {
return fBuiltTime; }
233 const char *GetGitCommit()
const {
return fGitCommit; }
234 const char *GetGitBranch()
const {
return fGitBranch; }
235 const char *GetGitDate();
236 Int_t GetVersionDate()
const {
return fVersionDate; }
237 Int_t GetVersionTime()
const {
return fVersionTime; }
238 Int_t GetVersionInt()
const {
return fVersionInt; }
239 Int_t GetVersionCode()
const {
return fVersionCode; }
240 const char *GetVersion()
const {
return fVersion; }
241 TCollection *GetListOfClasses()
const {
return fClasses; }
242 TSeqCollection *GetListOfColors()
const {
return fColors; }
243 TCollection *GetListOfTypes(Bool_t load = kFALSE);
244 TCollection *GetListOfGlobals(Bool_t load = kFALSE);
245 TCollection *GetListOfGlobalFunctions(Bool_t load = kFALSE);
246 TSeqCollection *GetListOfClosedObjects()
const {
return fClosedObjects; }
247 TSeqCollection *GetListOfFiles()
const {
return fFiles; }
248 TSeqCollection *GetListOfMappedFiles()
const {
return fMappedFiles; }
249 TSeqCollection *GetListOfSockets()
const {
return fSockets; }
250 TSeqCollection *GetListOfCanvases()
const {
return fCanvases; }
251 TSeqCollection *GetListOfStyles()
const {
return fStyles; }
252 TCollection *GetListOfFunctions()
const {
return fFunctions; }
253 TCollection *GetListOfFunctionOverloads(
const char* name)
const;
254 TSeqCollection *GetListOfGeometries()
const {
return fGeometries; }
255 TSeqCollection *GetListOfBrowsers()
const {
return fBrowsers; }
256 TSeqCollection *GetListOfSpecials()
const {
return fSpecials; }
257 TSeqCollection *GetListOfTasks()
const {
return fTasks; }
258 TSeqCollection *GetListOfCleanups()
const {
return fCleanups; }
259 TSeqCollection *GetListOfStreamerInfo()
const {
return fStreamerInfo; }
260 TSeqCollection *GetListOfMessageHandlers()
const {
return fMessageHandlers; }
261 TCollection *GetListOfClassGenerators()
const {
return fClassGenerators; }
262 TSeqCollection *GetListOfSecContexts()
const {
return fSecContexts; }
263 TSeqCollection *GetListOfProofs()
const {
return fProofs; }
264 TSeqCollection *GetClipboard()
const {
return fClipboard; }
265 TSeqCollection *GetListOfDataSets()
const {
return fDataSets; }
266 TCollection *GetListOfEnums(Bool_t load = kFALSE);
267 TCollection *GetListOfFunctionTemplates();
268 TList *GetListOfBrowsables()
const {
return fBrowsables; }
269 TDataType *GetType(
const char *name, Bool_t load = kFALSE)
const;
270 TFile *GetFile()
const {
if (gDirectory !=
this)
return gDirectory->GetFile();
else return 0;}
271 TFile *GetFile(
const char *name)
const;
272 TFunctionTemplate*GetFunctionTemplate(
const char *name);
273 TStyle *GetStyle(
const char *name)
const;
274 TObject *GetFunction(
const char *name)
const;
275 TGlobal *GetGlobal(
const char *name, Bool_t load = kFALSE)
const;
276 TGlobal *GetGlobal(
const TObject *obj, Bool_t load = kFALSE)
const;
277 TFunction *GetGlobalFunction(
const char *name,
const char *params = 0, Bool_t load = kFALSE);
278 TFunction *GetGlobalFunctionWithPrototype(
const char *name,
const char *proto = 0, Bool_t load = kFALSE);
279 TObject *GetGeometry(
const char *name)
const;
280 const TObject *GetSelectedPrimitive()
const {
return fPrimitive; }
281 TVirtualPad *GetSelectedPad()
const {
return fSelectPad; }
282 Int_t GetNclasses()
const {
return fClasses->GetSize(); }
283 Int_t GetNtypes()
const {
return fTypes->GetSize(); }
284 TFolder *GetRootFolder()
const {
return fRootFolder; }
285 TProcessUUID *GetUUIDs()
const {
return fUUIDs; }
286 const TString &GetWebDisplay()
const {
return fWebDisplay; }
287 void Idle(UInt_t idleTimeInSec,
const char *command = 0);
288 Int_t IgnoreInclude(
const char *fname,
const char *expandedfname);
289 Bool_t IsBatch()
const {
return fBatch; }
290 Bool_t IsExecutingMacro()
const {
return fExecutingMacro; }
291 Bool_t IsFolder()
const {
return kTRUE; }
292 Bool_t IsInterrupted()
const {
return fInterrupt; }
293 Bool_t IsEscaped()
const {
return fEscape; }
294 Bool_t IsLineProcessing()
const {
return fLineIsProcessing ? kTRUE : kFALSE; }
295 Bool_t IsProofServ()
const {
return fName ==
"proofserv" ? kTRUE : kFALSE; }
296 Bool_t IsRootFile(
const char *filename)
const;
297 Bool_t IsWebDisplay()
const {
return fIsWebDisplay; }
298 Bool_t IsWebDisplayBatch()
const {
return fIsWebDisplayBatch; }
299 void ls(Option_t *option =
"")
const;
300 Int_t LoadClass(
const char *classname,
const char *libname, Bool_t check = kFALSE);
301 TClass *LoadClass(
const char *name, Bool_t silent = kFALSE)
const;
302 Int_t LoadMacro(
const char *filename, Int_t *error = 0, Bool_t check = kFALSE);
303 Long_t Macro(
const char *filename, Int_t *error = 0, Bool_t padUpdate = kTRUE);
304 TCanvas *MakeDefCanvas()
const;
305 void Message(Int_t
id,
const TObject *obj);
306 Bool_t MustClean()
const {
return fMustClean; }
307 Long_t ProcessLine(
const char *line, Int_t *error = 0);
308 Long_t ProcessLineSync(
const char *line, Int_t *error = 0);
309 Long_t ProcessLineFast(
const char *line, Int_t *error = 0);
310 Bool_t ReadingObject()
const;
311 void RecursiveRemove(TObject *obj);
312 void RefreshBrowsers();
313 static void RegisterModule(
const char* modulename,
314 const char** headers,
315 const char** includePaths,
316 const char* payLoadCode,
317 const char* fwdDeclCode,
318 void (*triggerFunc)(),
319 const FwdDeclArgsToKeepCollection_t& fwdDeclsArgToSkip,
320 const char** classesHeaders,
321 bool hasCxxModule =
false);
322 TObject *Remove(TObject*);
323 void RemoveClass(TClass *);
324 void Reset(Option_t *option=
"");
326 void SetApplication(TApplication *app) { fApplication = app; }
327 void SetBatch(Bool_t batch = kTRUE) { fBatch = batch; }
328 void SetWebDisplay(
const char *webdisplay);
329 void SetCutClassName(
const char *name =
"TCutG");
330 void SetDefCanvasName(
const char *name =
"c1") { fDefCanvasName = name; }
331 void SetEditHistograms(Bool_t flag = kTRUE) { fEditHistograms = flag; }
332 void SetEditorMode(
const char *mode =
"");
333 void SetExecutingMacro(Bool_t flag = kTRUE) { fExecutingMacro = flag; }
334 void SetFromPopUp(Bool_t flag = kTRUE) { fFromPopUp = flag; }
335 void SetInterrupt(Bool_t flag = kTRUE) { fInterrupt = flag; }
336 void SetEscape(Bool_t flag = kTRUE) { fEscape = flag; }
337 void SetLineIsProcessing() { fLineIsProcessing++; }
338 void SetLineHasBeenProcessed() {
if (fLineIsProcessing) fLineIsProcessing--; }
339 void SetReadingObject(Bool_t flag = kTRUE);
340 void SetMustClean(Bool_t flag = kTRUE) { fMustClean=flag; }
341 void SetSelectedPrimitive(
const TObject *obj) { fPrimitive = obj; }
342 void SetSelectedPad(TVirtualPad *pad) { fSelectPad = pad; }
343 void SetStyle(
const char *stylename =
"Default");
344 void Time(Int_t casetime=1) { fTimer = casetime; }
345 Int_t Timer()
const {
return fTimer; }
348 static Int_t DecreaseDirLevel();
349 static Int_t GetDirLevel();
350 static const char *GetMacroPath();
351 static void SetMacroPath(
const char *newpath);
352 static Int_t IncreaseDirLevel();
353 static void IndentLevel();
354 static void Initialize();
355 static Bool_t Initialized();
356 static Bool_t MemCheck();
357 static void SetDirLevel(Int_t level = 0);
358 static Int_t ConvertVersionCode2Int(Int_t code);
359 static Int_t ConvertVersionInt2Code(Int_t v);
360 static Int_t RootVersionCode();
361 static const std::vector<std::string> &AddExtraInterpreterArgs(
const std::vector<std::string> &args);
362 static const char**&GetExtraInterpreterArgs();
364 static const TString& GetRootSys();
365 static const TString& GetBinDir();
366 static const TString& GetLibDir();
367 static const TString& GetIncludeDir();
368 static const TString& GetEtcDir();
369 static const TString& GetDataDir();
370 static const TString& GetDocDir();
371 static const TString& GetMacroDir();
372 static const TString& GetTutorialDir();
373 static const TString& GetSourceDir();
374 static const TString& GetIconPath();
375 static const TString& GetTTFFontDir();
378 static const char *GetTutorialsDir();
379 static void ShutDown();
388 R__EXTERN TROOT *gROOTLocal;
390 inline void SetRequireCleanup(TObject &obj) {
391 obj.SetBit(kIsReferenced);
395 inline Bool_t RequiresCleanup(TObject &obj) {
396 return obj.TestBit(kIsReferenced) && obj.GetUniqueID() == 0;
404 inline void CallRecursiveRemoveIfNeeded(TObject &obj)
406 if (obj.TestBit(kMustCleanup)) {
407 TROOT *root = ROOT::Internal::gROOTLocal;
408 if (root && root != &obj && (root->MustClean() || Internal::RequiresCleanup(obj))) {
409 root->RecursiveRemove(&obj);
410 obj.ResetBit(kMustCleanup);
415 #define gROOT (ROOT::GetROOT())