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 #ifndef ROOT_TROOT 13 #define ROOT_TROOT 14 15 16 ////////////////////////////////////////////////////////////////////////// 17 // // 18 // TROOT // 19 // // 20 // The TROOT object is the entry point to the system. // 21 // The single instance of TROOT is accessable via the global gROOT. // 22 // Using the gROOT pointer one has access to basically every object // 23 // created in a ROOT based program. The TROOT object is essentially a // 24 // "dispatcher" with several lists pointing to the ROOT main objects. // 25 // // 26 ////////////////////////////////////////////////////////////////////////// 27 28 #ifndef ROOT_TDirectory 29 #include "TDirectory.h" 30 #endif 31 #ifndef ROOT_TList 32 #include "TList.h" 33 #endif 34 #if __cplusplus >= 201103L 35 #include <atomic> 36 #endif 37 38 class TClass; 39 class TCanvas; 40 class TColor; 41 class TDataType; 42 class TFile; 43 class TStyle; 44 class TVirtualPad; 45 class TApplication; 46 class TInterpreter; 47 class TBrowser; 48 class TGlobal; 49 class TFunction; 50 class TFolder; 51 class TPluginManager; 52 class TProcessUUID; 53 class TClassGenerator; 54 class TVirtualMutex; 55 56 57 58 R__EXTERN TVirtualMutex *gROOTMutex; 59 60 class TROOT : public TDirectory { 61 62 friend class TCint; 63 friend class TCintWithCling; 64 65 private: 66 Int_t fLineIsProcessing; //To synchronize multi-threads 67 68 static Int_t fgDirLevel; //Indentation level for ls() 69 static Bool_t fgRootInit; //Singleton initialization flag 70 static Bool_t fgMemCheck; //Turn on memory leak checker 71 72 TROOT(const TROOT&); //Not implemented 73 TROOT& operator=(const TROOT&); //Not implemented 74 75 protected: 76 TString fConfigOptions; //ROOT ./configure set build options 77 TString fConfigFeatures; //ROOT ./configure detected build features 78 TString fVersion; //ROOT version (from CMZ VERSQQ) ex 0.05/01 79 Int_t fVersionInt; //ROOT version in integer format (501) 80 Int_t fVersionCode; //ROOT version code as used in RVersion.h 81 Int_t fVersionDate; //Date of ROOT version (ex 951226) 82 Int_t fVersionTime; //Time of ROOT version (ex 1152) 83 Int_t fBuiltDate; //Date of ROOT built 84 Int_t fBuiltTime; //Time of ROOT built 85 Int_t fSvnRevision; //Subversion revision number of built (dec value of Git short SHA1) 86 TString fGitCommit; //Git commit SHA1 of built 87 TString fGitBranch; //Git branch 88 TString fGitDate; //Date and time when make was run 89 Int_t fTimer; //Timer flag 90 #if __cplusplus >= 201103L 91 std::atomic<TApplication*> fApplication; //Pointer to current application 92 #else 93 TApplication *fApplication; //Pointer to current application 94 #endif 95 TInterpreter *fInterpreter; //Command interpreter 96 Bool_t fBatch; //True if session without graphics 97 Bool_t fEditHistograms; //True if histograms can be edited with the mouse 98 Bool_t fFromPopUp; //True if command executed from a popup menu 99 Bool_t fMustClean; //True if object destructor scans canvases 100 Bool_t fReadingObject; //True while reading an object [Deprecated (will be removed in next release) 101 Bool_t fForceStyle; //Force setting of current style when reading objects 102 Bool_t fInterrupt; //True if macro should be interrupted 103 Bool_t fEscape; //True if ESC has been pressed 104 Bool_t fExecutingMacro; //True while executing a TMacro 105 Int_t fEditorMode; //Current Editor mode 106 const TObject *fPrimitive; //Currently selected primitive 107 TVirtualPad *fSelectPad; //Currently selected pad 108 TCollection *fClasses; //List of classes definition 109 TCollection *fTypes; //List of data types definition 110 TCollection *fGlobals; //List of global variables 111 TCollection *fGlobalFunctions; //List of global functions 112 TSeqCollection *fClosedObjects; //List of closed objects from the list of files and sockets, so we can delete them if neededCl. 113 TSeqCollection *fFiles; //List of files 114 TSeqCollection *fMappedFiles; //List of memory mapped files 115 TSeqCollection *fSockets; //List of network sockets 116 TSeqCollection *fCanvases; //List of canvases 117 TSeqCollection *fStyles; //List of styles 118 TCollection *fFunctions; //List of analytic functions 119 TSeqCollection *fTasks; //List of tasks 120 TSeqCollection *fColors; //List of colors 121 TSeqCollection *fGeometries; //List of geometries 122 TSeqCollection *fBrowsers; //List of browsers 123 TSeqCollection *fSpecials; //List of special objects 124 TSeqCollection *fCleanups; //List of recursiveRemove collections 125 TSeqCollection *fMessageHandlers; //List of message handlers 126 TSeqCollection *fStreamerInfo; //List of active StreamerInfo classes 127 TCollection *fClassGenerators; //List of user defined class generators; 128 TSeqCollection *fSecContexts; //List of security contexts (TSecContext) 129 TSeqCollection *fProofs; //List of proof sessions 130 TSeqCollection *fClipboard; //List of clipbard objects 131 TSeqCollection *fDataSets; //List of data sets (TDSet or TChain) 132 TProcessUUID *fUUIDs; //Pointer to TProcessID managing TUUIDs 133 TFolder *fRootFolder; //top level folder //root 134 TList *fBrowsables; //List of browsables 135 TPluginManager *fPluginManager; //Keeps track of plugin library handlers 136 TString fCutClassName; //Name of default CutG class in graphics editor 137 TString fDefCanvasName; //Name of default canvas 138 139 TROOT(); //Only used by Dictionary 140 void InitSystem(); //Operating System interface 141 void InitThreads(); //Initialize threads library 142 void ReadGitInfo(); //Read Subversion revision number and branch name 143 void *operator new(size_t l) { return TObject::operator new(l); } 144 145 public: 146 TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc = 0); 147 virtual ~TROOT(); 148 void AddClass(TClass *cl); 149 void AddClassGenerator(TClassGenerator *gen); 150 void Browse(TBrowser *b); 151 Bool_t ClassSaved(TClass *cl); 152 void CloseFiles(); 153 void EndOfProcessCleanups(bool altInterpreter = kFALSE); 154 virtual TObject *FindObject(const char *name) const; 155 virtual TObject *FindObject(const TObject *obj) const; 156 virtual TObject *FindObjectAny(const char *name) const; 157 virtual TObject *FindObjectAnyFile(const char *name) const; 158 TObject *FindSpecialObject(const char *name, void *&where); 159 const char *FindObjectClassName(const char *name) const; 160 const char *FindObjectPathName(const TObject *obj) const; 161 TClass *FindSTLClass(const char *name, Bool_t load, Bool_t silent = kFALSE) const; 162 void ForceStyle(Bool_t force = kTRUE) { fForceStyle = force; } 163 Bool_t FromPopUp() const { return fFromPopUp; } 164 TPluginManager *GetPluginManager() const { return fPluginManager; } 165 TApplication *GetApplication() const { return fApplication; } 166 TInterpreter *GetInterpreter() const { return fInterpreter; } 167 TClass *GetClass(const char *name, Bool_t load = kTRUE, Bool_t silent = kFALSE) const; 168 TClass *GetClass(const type_info &typeinfo, Bool_t load = kTRUE, Bool_t silent = kFALSE) const; 169 TColor *GetColor(Int_t color) const; 170 const char *GetConfigOptions() const { return fConfigOptions; } 171 const char *GetConfigFeatures() const { return fConfigFeatures; } 172 const char *GetCutClassName() const { return fCutClassName; } 173 const char *GetDefCanvasName() const { return fDefCanvasName; } 174 Bool_t GetEditHistograms() const { return fEditHistograms; } 175 Int_t GetEditorMode() const { return fEditorMode; } 176 Bool_t GetForceStyle() const { return fForceStyle; } 177 Int_t GetBuiltDate() const { return fBuiltDate; } 178 Int_t GetBuiltTime() const { return fBuiltTime; } 179 Int_t GetSvnRevision() const { return fSvnRevision; } 180 const char *GetSvnBranch() const { return fGitBranch; } 181 const char *GetSvnDate() { return GetGitDate(); } 182 const char *GetGitCommit() const { return fGitCommit; } 183 const char *GetGitBranch() const { return fGitBranch; } 184 const char *GetGitDate(); 185 Int_t GetVersionDate() const { return fVersionDate; } 186 Int_t GetVersionTime() const { return fVersionTime; } 187 Int_t GetVersionInt() const { return fVersionInt; } 188 Int_t GetVersionCode() const { return fVersionCode; } 189 const char *GetVersion() const { return fVersion; } 190 TCollection *GetListOfClasses() const { return fClasses; } 191 TSeqCollection *GetListOfColors() const { return fColors; } 192 TCollection *GetListOfTypes(Bool_t load = kFALSE); 193 TCollection *GetListOfGlobals(Bool_t load = kFALSE); 194 TCollection *GetListOfGlobalFunctions(Bool_t load = kFALSE); 195 TSeqCollection *GetListOfClosedObjects() const { return fClosedObjects; } 196 TSeqCollection *GetListOfFiles() const { return fFiles; } 197 TSeqCollection *GetListOfMappedFiles() const { return fMappedFiles; } 198 TSeqCollection *GetListOfSockets() const { return fSockets; } 199 TSeqCollection *GetListOfCanvases() const { return fCanvases; } 200 TSeqCollection *GetListOfStyles() const { return fStyles; } 201 TCollection *GetListOfFunctions() const { return fFunctions; } 202 TSeqCollection *GetListOfGeometries() const { return fGeometries; } 203 TSeqCollection *GetListOfBrowsers() const { return fBrowsers; } 204 TSeqCollection *GetListOfSpecials() const { return fSpecials; } 205 TSeqCollection *GetListOfTasks() const { return fTasks; } 206 TSeqCollection *GetListOfCleanups() const { return fCleanups; } 207 TSeqCollection *GetListOfStreamerInfo() const { return fStreamerInfo; } 208 TSeqCollection *GetListOfMessageHandlers() const { return fMessageHandlers; } 209 TCollection *GetListOfClassGenerators() const { return fClassGenerators; } 210 TSeqCollection *GetListOfSecContexts() const { return fSecContexts; } 211 TSeqCollection *GetListOfProofs() const { return fProofs; } 212 TSeqCollection *GetClipboard() const { return fClipboard; } 213 TSeqCollection *GetListOfDataSets() const { return fDataSets; } 214 TList *GetListOfBrowsables() const { return fBrowsables; } 215 TDataType *GetType(const char *name, Bool_t load = kFALSE) const; 216 TFile *GetFile() const { if (gDirectory != this) return gDirectory->GetFile(); else return 0;} 217 TFile *GetFile(const char *name) const; 218 TStyle *GetStyle(const char *name) const; 219 TObject *GetFunction(const char *name) const; 220 TGlobal *GetGlobal(const char *name, Bool_t load = kFALSE) const; 221 TGlobal *GetGlobal(const TObject *obj, Bool_t load = kFALSE) const; 222 TFunction *GetGlobalFunction(const char *name, const char *params = 0, Bool_t load = kFALSE); 223 TFunction *GetGlobalFunctionWithPrototype(const char *name, const char *proto = 0, Bool_t load = kFALSE); 224 TObject *GetGeometry(const char *name) const; 225 const TObject *GetSelectedPrimitive() const { return fPrimitive; } 226 TVirtualPad *GetSelectedPad() const { return fSelectPad; } 227 Int_t GetNclasses() const { return fClasses->GetSize(); } 228 Int_t GetNtypes() const { return fTypes->GetSize(); } 229 TFolder *GetRootFolder() const { return fRootFolder; } 230 TProcessUUID *GetUUIDs() const { return fUUIDs; } 231 void Idle(UInt_t idleTimeInSec, const char *command = 0); 232 Int_t IgnoreInclude(const char *fname, const char *expandedfname); 233 Bool_t IsBatch() const { return fBatch; } 234 Bool_t IsExecutingMacro() const { return fExecutingMacro; } 235 Bool_t IsFolder() const { return kTRUE; } 236 Bool_t IsInterrupted() const { return fInterrupt; } 237 Bool_t IsEscaped() const { return fEscape; } 238 Bool_t IsLineProcessing() const { return fLineIsProcessing ? kTRUE : kFALSE; } 239 Bool_t IsProofServ() const { return fName == "proofserv" ? kTRUE : kFALSE; } 240 void ls(Option_t *option = "") const; 241 Int_t LoadClass(const char *classname, const char *libname, Bool_t check = kFALSE); 242 TClass *LoadClass(const char *name, Bool_t silent = kFALSE) const; 243 Int_t LoadMacro(const char *filename, Int_t *error = 0, Bool_t check = kFALSE); 244 Long_t Macro(const char *filename, Int_t *error = 0, Bool_t padUpdate = kTRUE); 245 TCanvas *MakeDefCanvas() const; 246 void Message(Int_t id, const TObject *obj); 247 Bool_t MustClean() const { return fMustClean; } 248 Long_t ProcessLine(const char *line, Int_t *error = 0); 249 Long_t ProcessLineSync(const char *line, Int_t *error = 0); 250 Long_t ProcessLineFast(const char *line, Int_t *error = 0); 251 Bool_t ReadingObject() const; 252 void RefreshBrowsers(); 253 void RemoveClass(TClass *); 254 void Reset(Option_t *option=""); 255 void SaveContext(); 256 void SetApplication(TApplication *app) { fApplication = app; } 257 void SetBatch(Bool_t batch = kTRUE) { fBatch = batch; } 258 void SetCutClassName(const char *name = "TCutG"); 259 void SetDefCanvasName(const char *name = "c1") { fDefCanvasName = name; } 260 void SetEditHistograms(Bool_t flag = kTRUE) { fEditHistograms = flag; } 261 void SetEditorMode(const char *mode = ""); 262 void SetExecutingMacro(Bool_t flag = kTRUE) { fExecutingMacro = flag; } 263 void SetFromPopUp(Bool_t flag = kTRUE) { fFromPopUp = flag; } 264 void SetInterrupt(Bool_t flag = kTRUE) { fInterrupt = flag; } 265 void SetEscape(Bool_t flag = kTRUE) { fEscape = flag; } 266 void SetLineIsProcessing() { fLineIsProcessing++; } 267 void SetLineHasBeenProcessed() { if (fLineIsProcessing) fLineIsProcessing--; } 268 void SetReadingObject(Bool_t flag = kTRUE); 269 void SetMustClean(Bool_t flag = kTRUE) { fMustClean=flag; } 270 void SetSelectedPrimitive(const TObject *obj) { fPrimitive = obj; } 271 void SetSelectedPad(TVirtualPad *pad) { fSelectPad = pad; } 272 void SetStyle(const char *stylename = "Default"); 273 void Time(Int_t casetime=1) { fTimer = casetime; } 274 Int_t Timer() const { return fTimer; } 275 276 //---- static functions 277 static Int_t DecreaseDirLevel(); 278 static Int_t GetDirLevel(); 279 static const char *GetMacroPath(); 280 static void SetMacroPath(const char *newpath); 281 static Int_t IncreaseDirLevel(); 282 static void IndentLevel(); 283 static Bool_t Initialized(); 284 static Bool_t MemCheck(); 285 static void SetDirLevel(Int_t level = 0); 286 static Int_t ConvertVersionCode2Int(Int_t code); 287 static Int_t ConvertVersionInt2Code(Int_t v); 288 static Int_t RootVersionCode(); 289 static const char *GetTutorialsDir(); 290 291 ClassDef(TROOT,0) //Top level (or root) structure for all classes 292 }; 293 294 295 R__EXTERN TROOT *gROOT; 296 namespace ROOT { 297 TROOT *GetROOT(); 298 } 299 #endif 300