00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #include "RConfig.h"
00064 #include "RConfigure.h"
00065 #include "RConfigOptions.h"
00066
00067 #include <string>
00068 #include <map>
00069 #include <stdlib.h>
00070 #ifdef WIN32
00071 #include <io.h>
00072 #endif
00073
00074 #include "Riostream.h"
00075 #include "Gtypes.h"
00076 #include "TROOT.h"
00077 #include "TClass.h"
00078 #include "TClassEdit.h"
00079 #include "TClassGenerator.h"
00080 #include "TDataType.h"
00081 #include "TDatime.h"
00082 #include "TStyle.h"
00083 #include "TObjectTable.h"
00084 #include "TClassTable.h"
00085 #include "TSystem.h"
00086 #include "THashList.h"
00087 #include "TObjArray.h"
00088 #include "TEnv.h"
00089 #include "TError.h"
00090 #include "TColor.h"
00091 #include "TGlobal.h"
00092 #include "TFunction.h"
00093 #include "TVirtualPad.h"
00094 #include "TBrowser.h"
00095 #include "TSystemDirectory.h"
00096 #include "TApplication.h"
00097 #include "TInterpreter.h"
00098 #include "TGuiFactory.h"
00099 #include "TMessageHandler.h"
00100 #include "TFolder.h"
00101 #include "TQObject.h"
00102 #include "TProcessUUID.h"
00103 #include "TPluginManager.h"
00104 #include "TMap.h"
00105 #include "TObjString.h"
00106 #include "TVirtualMutex.h"
00107 #ifdef R__HAS_CLING
00108 # include "TCling.h"
00109 #else
00110 # include "TCint.h"
00111 #endif
00112
00113 #include <string>
00114 namespace std {} using namespace std;
00115
00116 #if defined(R__UNIX)
00117 #include "TUnixSystem.h"
00118 #elif defined(R__WIN32)
00119 #include "TWinNTSystem.h"
00120 #endif
00121
00122 extern "C" void R__SetZipMode(int);
00123
00124
00125 TVirtualMutex* gROOTMutex = 0;
00126
00127
00128
00129 static Int_t IVERSQ()
00130 {
00131
00132
00133 Int_t maj, min, cycle;
00134 sscanf(ROOT_RELEASE, "%d.%d/%d", &maj, &min, &cycle);
00135 return 10000*maj + 100*min + cycle;
00136 }
00137
00138
00139 static Int_t IDATQQ(const char *date)
00140 {
00141
00142
00143 static const char *months[] = {"Jan","Feb","Mar","Apr","May",
00144 "Jun","Jul","Aug","Sep","Oct",
00145 "Nov","Dec"};
00146
00147 char sm[12];
00148 Int_t yy, mm=0, dd;
00149 sscanf(date, "%s %d %d", sm, &dd, &yy);
00150 for (int i = 0; i < 12; i++)
00151 if (!strncmp(sm, months[i], 3)) {
00152 mm = i+1;
00153 break;
00154 }
00155 return 10000*yy + 100*mm + dd;
00156 }
00157
00158
00159 static Int_t ITIMQQ(const char *time)
00160 {
00161
00162
00163
00164 Int_t hh, mm, ss;
00165 sscanf(time, "%d:%d:%d", &hh, &mm, &ss);
00166 return 100*hh + mm;
00167 }
00168
00169 static void CleanUpROOTAtExit()
00170 {
00171
00172
00173 if (gROOT) {
00174 R__LOCKGUARD(gROOTMutex);
00175
00176 if (gROOT->GetListOfFiles())
00177 gROOT->GetListOfFiles()->Delete("slow");
00178 if (gROOT->GetListOfSockets())
00179 gROOT->GetListOfSockets()->Delete();
00180 if (gROOT->GetListOfMappedFiles())
00181 gROOT->GetListOfMappedFiles()->Delete("slow");
00182 }
00183 }
00184
00185
00186
00187 Int_t TROOT::fgDirLevel = 0;
00188 Bool_t TROOT::fgRootInit = kFALSE;
00189 Bool_t TROOT::fgMemCheck = kFALSE;
00190
00191
00192 namespace ROOT {
00193 TROOT *GetROOT() {
00194 static TROOT root("root", "The ROOT of EVERYTHING");
00195 return &root;
00196 }
00197 TString &GetMacroPath() {
00198 static TString macroPath;
00199 return macroPath;
00200 }
00201 }
00202
00203 TROOT *gROOT = ROOT::GetROOT();
00204
00205
00206
00207
00208
00209 Int_t gDebug;
00210
00211
00212 ClassImp(TROOT)
00213
00214
00215 TROOT::TROOT() : TDirectory(),
00216 fLineIsProcessing(0), fVersion(0), fVersionInt(0), fVersionCode(0),
00217 fVersionDate(0), fVersionTime(0), fBuiltDate(0), fBuiltTime(0), fSvnRevision(0),
00218 fTimer(0), fApplication(0), fInterpreter(0), fBatch(kTRUE), fEditHistograms(kTRUE),
00219 fFromPopUp(kTRUE),fMustClean(kTRUE),fReadingObject(kFALSE),fForceStyle(kFALSE),
00220 fInterrupt(kFALSE),fEscape(kFALSE),fExecutingMacro(kFALSE),fEditorMode(0),
00221 fPrimitive(0),fSelectPad(0),fClasses(0),fTypes(0),fGlobals(0),fGlobalFunctions(0),
00222 fFiles(0),fMappedFiles(0),fSockets(0),fCanvases(0),fStyles(0),fFunctions(0),
00223 fTasks(0),fColors(0),fGeometries(0),fBrowsers(0),fSpecials(0),fCleanups(0),
00224 fMessageHandlers(0),fStreamerInfo(0),fClassGenerators(0),fSecContexts(0),
00225 fProofs(0),fClipboard(0),fDataSets(0),fUUIDs(0),fRootFolder(0),fBrowsables(0),
00226 fPluginManager(0)
00227 {
00228
00229 }
00230
00231
00232 TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc)
00233 : TDirectory(), fLineIsProcessing(0), fVersion(0), fVersionInt(0), fVersionCode(0),
00234 fVersionDate(0), fVersionTime(0), fBuiltDate(0), fBuiltTime(0), fSvnRevision(0),
00235 fTimer(0), fApplication(0), fInterpreter(0), fBatch(kTRUE), fEditHistograms(kTRUE),
00236 fFromPopUp(kTRUE),fMustClean(kTRUE),fReadingObject(kFALSE),fForceStyle(kFALSE),
00237 fInterrupt(kFALSE),fEscape(kFALSE),fExecutingMacro(kFALSE),fEditorMode(0),
00238 fPrimitive(0),fSelectPad(0),fClasses(0),fTypes(0),fGlobals(0),fGlobalFunctions(0),
00239 fFiles(0),fMappedFiles(0),fSockets(0),fCanvases(0),fStyles(0),fFunctions(0),
00240 fTasks(0),fColors(0),fGeometries(0),fBrowsers(0),fSpecials(0),fCleanups(0),
00241 fMessageHandlers(0),fStreamerInfo(0),fClassGenerators(0),fSecContexts(0),
00242 fProofs(0),fClipboard(0),fDataSets(0),fUUIDs(0),fRootFolder(0),fBrowsables(0),
00243 fPluginManager(0)
00244 {
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 if (fgRootInit) {
00263
00264 return;
00265 }
00266
00267 R__LOCKGUARD2(gROOTMutex);
00268
00269 gROOT = this;
00270 gDirectory = 0;
00271 SetName(name);
00272 SetTitle(title);
00273 TDirectory::Build();
00274
00275
00276
00277 fMappedFiles = 0;
00278
00279
00280 gPluginMgr = fPluginManager = new TPluginManager;
00281
00282
00283 InitSystem();
00284
00285 #ifndef ROOTPREFIX
00286 if (!gSystem->Getenv("ROOTSYS")) {
00287 fprintf(stderr, "Fatal in <TROOT::TROOT>: ROOTSYS not set. Set it before trying to run.\n");
00288 exit(1);
00289 }
00290 #endif
00291
00292
00293 fVersionInt = 0;
00294 fClasses = 0;
00295
00296 fInterpreter = new TCint("C/C++", "CINT C/C++ Interpreter");
00297
00298 fConfigOptions = R__CONFIGUREOPTIONS;
00299 fConfigFeatures = R__CONFIGUREFEATURES;
00300 fVersion = ROOT_RELEASE;
00301 fVersionCode = ROOT_VERSION_CODE;
00302 fVersionInt = IVERSQ();
00303 fVersionDate = IDATQQ(ROOT_RELEASE_DATE);
00304 fVersionTime = ITIMQQ(ROOT_RELEASE_TIME);
00305 fBuiltDate = IDATQQ(__DATE__);
00306 fBuiltTime = ITIMQQ(__TIME__);
00307
00308 ReadSvnInfo();
00309
00310 fClasses = new THashTable(800,3);
00311
00312 fStreamerInfo = new TObjArray(100);
00313 fClassGenerators = new TList;
00314
00315
00316 fPluginManager->LoadHandlersFromEnv(gEnv);
00317
00318 TSystemDirectory *workdir = new TSystemDirectory("workdir", gSystem->WorkingDirectory());
00319
00320 fTimer = 0;
00321 fApplication = 0;
00322 fColors = new TObjArray(1000); fColors->SetName("ListOfColors");
00323 fTypes = 0;
00324 fGlobals = 0;
00325 fGlobalFunctions = 0;
00326
00327 delete fList;
00328 fList = new THashList(1000,3);
00329 fFiles = new TList; fFiles->SetName("Files");
00330 fMappedFiles = new TList; fMappedFiles->SetName("MappedFiles");
00331 fSockets = new TList; fSockets->SetName("Sockets");
00332 fCanvases = new TList; fCanvases->SetName("Canvases");
00333 fStyles = new TList; fStyles->SetName("Styles");
00334 fFunctions = new TList; fFunctions->SetName("Functions");
00335 fTasks = new TList; fTasks->SetName("Tasks");
00336 fGeometries = new TList; fGeometries->SetName("Geometries");
00337 fBrowsers = new TList; fBrowsers->SetName("Browsers");
00338 fSpecials = new TList; fSpecials->SetName("Specials");
00339 fBrowsables = new TList; fBrowsables->SetName("Browsables");
00340 fCleanups = new THashList; fCleanups->SetName("Cleanups");
00341 fMessageHandlers = new TList; fMessageHandlers->SetName("MessageHandlers");
00342 fSecContexts = new TList; fSecContexts->SetName("SecContexts");
00343 fProofs = new TList; fProofs->SetName("Proofs");
00344 fClipboard = new TList; fClipboard->SetName("Clipboard");
00345 fDataSets = new TList; fDataSets->SetName("DataSets");
00346
00347 TProcessID::AddProcessID();
00348 fUUIDs = new TProcessUUID();
00349
00350 fRootFolder = new TFolder();
00351 fRootFolder->SetName("root");
00352 fRootFolder->SetTitle("root of all folders");
00353 fRootFolder->AddFolder("Classes", "List of Active Classes",fClasses);
00354 fRootFolder->AddFolder("Colors", "List of Active Colors",fColors);
00355 fRootFolder->AddFolder("MapFiles", "List of MapFiles",fMappedFiles);
00356 fRootFolder->AddFolder("Sockets", "List of Socket Connections",fSockets);
00357 fRootFolder->AddFolder("Canvases", "List of Canvases",fCanvases);
00358 fRootFolder->AddFolder("Styles", "List of Styles",fStyles);
00359 fRootFolder->AddFolder("Functions", "List of Functions",fFunctions);
00360 fRootFolder->AddFolder("Tasks", "List of Tasks",fTasks);
00361 fRootFolder->AddFolder("Geometries","List of Geometries",fGeometries);
00362 fRootFolder->AddFolder("Browsers", "List of Browsers",fBrowsers);
00363 fRootFolder->AddFolder("Specials", "List of Special Objects",fSpecials);
00364 fRootFolder->AddFolder("Handlers", "List of Message Handlers",fMessageHandlers);
00365 fRootFolder->AddFolder("Cleanups", "List of RecursiveRemove Collections",fCleanups);
00366 fRootFolder->AddFolder("StreamerInfo","List of Active StreamerInfo Classes",fStreamerInfo);
00367 fRootFolder->AddFolder("SecContexts","List of Security Contexts",fSecContexts);
00368 fRootFolder->AddFolder("PROOF Sessions", "List of PROOF sessions",fProofs);
00369 fRootFolder->AddFolder("ROOT Memory","List of Objects in the gROOT Directory",fList);
00370 fRootFolder->AddFolder("ROOT Files","List of Connected ROOT Files",fFiles);
00371
00372
00373 fCleanups->Add(fCanvases); fCanvases->SetBit(kMustCleanup);
00374 fCleanups->Add(fBrowsers); fBrowsers->SetBit(kMustCleanup);
00375 fCleanups->Add(fTasks); fTasks->SetBit(kMustCleanup);
00376 fCleanups->Add(fFiles); fFiles->SetBit(kMustCleanup);
00377 fCleanups->Add(fInterpreter);
00378
00379 fExecutingMacro= kFALSE;
00380 fForceStyle = kFALSE;
00381 fFromPopUp = kFALSE;
00382 fReadingObject = kFALSE;
00383 fInterrupt = kFALSE;
00384 fEscape = kFALSE;
00385 fMustClean = kTRUE;
00386 fPrimitive = 0;
00387 fSelectPad = 0;
00388 fEditorMode = 0;
00389 fDefCanvasName = "c1";
00390 fEditHistograms= kFALSE;
00391 fLineIsProcessing = 1;
00392 gDirectory = this;
00393 gPad = 0;
00394
00395
00396
00397
00398 fCutClassName = "TCutG";
00399
00400
00401 new TMessageHandler((TClass*)0);
00402
00403
00404 gStyle = 0;
00405 TStyle::BuildStyles();
00406 SetStyle("Default");
00407
00408
00409 gBatchGuiFactory = new TGuiFactory;
00410 gGuiFactory = gBatchGuiFactory;
00411 gGXBatch = new TVirtualX("Batch", "ROOT Interface to batch graphics");
00412 gVirtualX = gGXBatch;
00413
00414 #ifdef R__WIN32
00415 fBatch = kFALSE;
00416 #else
00417 if (gSystem->Getenv("DISPLAY"))
00418 fBatch = kFALSE;
00419 else
00420 fBatch = kTRUE;
00421 #endif
00422
00423 int i = 0;
00424 while (initfunc && initfunc[i]) {
00425 (initfunc[i])();
00426 fBatch = kFALSE;
00427 i++;
00428 }
00429
00430
00431 InitThreads();
00432
00433
00434 TQObject::LoadRQ_OBJECT();
00435
00436
00437 fBrowsables->Add(fRootFolder, "root");
00438 fBrowsables->Add(fProofs, "PROOF Sessions");
00439 fBrowsables->Add(workdir, gSystem->WorkingDirectory());
00440 fBrowsables->Add(fFiles, "ROOT Files");
00441
00442 atexit(CleanUpROOTAtExit);
00443
00444 fgRootInit = kTRUE;
00445
00446 TClass::ReadRules();
00447 }
00448
00449
00450 TROOT::~TROOT()
00451 {
00452
00453
00454
00455 if (gROOT == this) {
00456
00457
00458
00459 gGlobalMutex = 0;
00460
00461
00462
00463 if (!fVersionInt) return;
00464
00465
00466
00467 #ifdef R__COMPLETE_MEM_TERMINATION
00468 SafeDelete(fBrowsables);
00469 SafeDelete(fRootFolder);
00470 fSpecials->Delete(); SafeDelete(fSpecials);
00471 #endif
00472 fFiles->Delete("slow"); SafeDelete(fFiles);
00473 fSecContexts->Delete("slow"); SafeDelete(fSecContexts);
00474 fSockets->Delete(); SafeDelete(fSockets);
00475 fMappedFiles->Delete("slow");
00476 delete fUUIDs;
00477 TProcessID::Cleanup();
00478 TSeqCollection *tl = fMappedFiles; fMappedFiles = 0; delete tl;
00479
00480 fFunctions->Delete(); SafeDelete(fFunctions);
00481 fColors->Delete(); SafeDelete(fColors);
00482 fStyles->Delete(); SafeDelete(fStyles);
00483 fGeometries->Delete(); SafeDelete(fGeometries);
00484 fBrowsers->Delete(); SafeDelete(fBrowsers);
00485
00486 #ifdef R__COMPLETE_MEM_TERMINATION
00487 if (gGuiFactory != gBatchGuiFactory) SafeDelete(gGuiFactory);
00488 SafeDelete(gBatchGuiFactory);
00489 if (gGXBatch != gVirtualX) SafeDelete(gGXBatch);
00490 SafeDelete(gVirtualX);
00491 #endif
00492
00493
00494 TQObject::BlockAllSignals(kTRUE);
00495
00496 fMessageHandlers->Delete(); SafeDelete(fMessageHandlers);
00497
00498 #ifdef R__COMPLETE_MEM_TERMINATION
00499 SafeDelete(fCanvases);
00500 SafeDelete(fTasks);
00501 SafeDelete(fProofs);
00502 SafeDelete(fDataSets);
00503 SafeDelete(fClipboard);
00504 fCleanups->Clear();
00505 delete fPluginManager; gPluginMgr = fPluginManager = 0;
00506 delete gClassTable; gClassTable = 0;
00507 delete gEnv; gEnv = 0;
00508
00509 if (fTypes) fTypes->Delete();
00510 SafeDelete(fTypes);
00511 if (fGlobals) fGlobals->Delete();
00512 SafeDelete(fGlobals);
00513 if (fGlobalFunctions) fGlobalFunctions->Delete();
00514 SafeDelete(fGlobalFunctions);
00515 fClasses->Delete(); SafeDelete(fClasses);
00516 #endif
00517
00518
00519 gSystem->CleanCompiledMacros();
00520
00521
00522 delete gSystem;
00523
00524
00525
00526
00527 SafeDelete(fInterpreter);
00528
00529 #ifdef R__COMPLETE_MEM_TERMINATION
00530 SafeDelete(fCleanups);
00531 #endif
00532
00533
00534 TStorage::PrintStatistics();
00535
00536 gROOT = 0;
00537 fgRootInit = kFALSE;
00538 }
00539 }
00540
00541
00542 void TROOT::AddClass(TClass *cl)
00543 {
00544
00545
00546
00547
00548
00549
00550
00551 TClass::AddClass(cl);
00552 }
00553
00554
00555 void TROOT::AddClassGenerator(TClassGenerator *generator)
00556 {
00557
00558
00559
00560
00561 if (!generator) return;
00562 fClassGenerators->Add(generator);
00563 }
00564
00565
00566 void TROOT::Browse(TBrowser *b)
00567 {
00568
00569
00570 TObject *obj;
00571 TIter next(fBrowsables);
00572
00573 while ((obj = (TObject *) next())) {
00574 const char *opt = next.GetOption();
00575 if (opt && strlen(opt))
00576 b->Add(obj, opt);
00577 else
00578 b->Add(obj, obj->GetName());
00579 }
00580 }
00581
00582
00583 Bool_t TROOT::ClassSaved(TClass *cl)
00584 {
00585
00586
00587
00588
00589 if (cl == 0) return kFALSE;
00590 if (cl->TestBit(TClass::kClassSaved)) return kTRUE;
00591 cl->SetBit(TClass::kClassSaved);
00592 return kFALSE;
00593 }
00594
00595
00596 TObject *TROOT::FindObject(const TObject *) const
00597 {
00598
00599
00600 Error("FindObject","Not yet implemented");
00601 return 0;
00602 }
00603
00604
00605 TObject *TROOT::FindObject(const char *name) const
00606 {
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626 if (name && strstr(name,"/")) return FindObjectAny(name);
00627
00628 TObject *temp = 0;
00629
00630 temp = fFiles->FindObject(name); if (temp) return temp;
00631 temp = fMappedFiles->FindObject(name); if (temp) return temp;
00632 temp = fFunctions->FindObject(name); if (temp) return temp;
00633 temp = fGeometries->FindObject(name); if (temp) return temp;
00634 temp = fCanvases->FindObject(name); if (temp) return temp;
00635 temp = fStyles->FindObject(name); if (temp) return temp;
00636 temp = fSpecials->FindObject(name); if (temp) return temp;
00637 TIter next(fGeometries);
00638 TObject *obj;
00639 while ((obj=next())) {
00640 temp = obj->FindObject(name); if (temp) return temp;
00641 }
00642 if (gDirectory) temp = gDirectory->Get(name); if (temp) return temp;
00643 if (gPad) {
00644 TVirtualPad *canvas = gPad->GetVirtCanvas();
00645 if (fCanvases->FindObject(canvas)) {
00646 temp = canvas->FindObject(name);
00647 if (!temp && canvas != gPad) temp = gPad->FindObject(name);
00648 }
00649 }
00650 return temp;
00651 }
00652
00653
00654 TObject *TROOT::FindSpecialObject(const char *name, void *&where)
00655 {
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673 TObject *temp = 0;
00674 where = 0;
00675
00676 if (!temp && !strcmp(name, "gPad")) {
00677 temp = gPad;
00678 if (gPad) {
00679 TVirtualPad *canvas = gPad->GetVirtCanvas();
00680
00681 if (fCanvases->FindObject(canvas))
00682 where = canvas;
00683 }
00684 }
00685 if (!temp && !strcmp(name, "gVirtualX")) {
00686 return gVirtualX;
00687 }
00688 if (!temp && !strcmp(name, "gInterpreter")) {
00689 return gInterpreter;
00690 }
00691 if (!temp) {
00692 temp = fFiles->FindObject(name);
00693 where = fFiles;
00694 }
00695 if (!temp) {
00696 temp = fMappedFiles->FindObject(name);
00697 where = fMappedFiles;
00698 }
00699 if (!temp) {
00700 temp = fFunctions->FindObject(name);
00701 where = fFunctions;
00702 }
00703 if (!temp) {
00704 temp = fCanvases->FindObject(name);
00705 where = fCanvases;
00706 }
00707 if (!temp) {
00708 temp = fStyles->FindObject(name);
00709 where = fStyles;
00710 }
00711 if (!temp) {
00712 temp = fSpecials->FindObject(name);
00713 where = fSpecials;
00714 }
00715 if (!temp) {
00716 TObject *glast = fGeometries->Last();
00717 if (glast) {where = glast; temp = glast->FindObject(name);}
00718 }
00719 if (!temp && gDirectory) {
00720 temp = gDirectory->Get(name);
00721 where = gDirectory;
00722 }
00723 if (!temp && gPad) {
00724 TVirtualPad *canvas = gPad->GetVirtCanvas();
00725 if (fCanvases->FindObject(canvas)) {
00726 temp = canvas->FindObject(name);
00727 where = canvas;
00728 if (!temp && canvas != gPad) {
00729 temp = gPad->FindObject(name);
00730 where = gPad;
00731 }
00732 }
00733 }
00734 if (!temp) return 0;
00735 if (temp->TestBit(kNotDeleted)) return temp;
00736 return 0;
00737 }
00738
00739
00740 TObject *TROOT::FindObjectAny(const char *name) const
00741 {
00742
00743
00744
00745
00746 TObject *obj = fRootFolder->FindObjectAny(name);
00747 if (obj) return obj;
00748 return gDirectory->FindObjectAnyFile(name);
00749 }
00750
00751
00752 const char *TROOT::FindObjectClassName(const char *name) const
00753 {
00754
00755
00756
00757 TObject *obj = FindObject(name);
00758 if (obj) return obj->ClassName();
00759
00760
00761 TGlobal *g = GetGlobal(name);
00762 if (g) return g->GetTypeName();
00763
00764 return 0;
00765 }
00766
00767
00768 const char *TROOT::FindObjectPathName(const TObject *) const
00769 {
00770
00771
00772
00773
00774
00775
00776 Error("FindObjectPathName","Not yet implemented");
00777 return "??";
00778 }
00779
00780
00781 static TClass *R__FindSTLClass(const char *name, Bool_t load, Bool_t silent, const char *outername)
00782 {
00783
00784
00785
00786
00787 TClass *cl = 0;
00788
00789
00790
00791
00792
00793 string defaultname( TClassEdit::ShortType( name, TClassEdit::kDropStlDefault ) ) ;
00794
00795 if (defaultname != name) {
00796 cl = (TClass*)gROOT->GetListOfClasses()->FindObject(defaultname.c_str());
00797 if (load && !cl) cl = gROOT->LoadClass(defaultname.c_str(), silent);
00798 }
00799
00800 if (cl==0) {
00801
00802
00803
00804
00805
00806
00807 TDataType *objType = gROOT->GetType(name, load);
00808 if (objType) {
00809 const char *typedfName = objType->GetTypeName();
00810 if (typedfName) {
00811 string defaultTypedefName(TClassEdit::ShortType(typedfName, TClassEdit::kDropStlDefault));
00812
00813 if (strcmp(typedfName, name) && defaultTypedefName == name) {
00814 cl = (TClass*)gROOT->GetListOfClasses()->FindObject(typedfName);
00815 if (load && !cl) cl = gROOT->LoadClass(typedfName, silent);
00816 }
00817 }
00818 }
00819 }
00820 if (cl==0) {
00821
00822
00823 const char *altname = gInterpreter->GetInterpreterTypeName(name);
00824 if (altname && strcmp(altname,name)!=0 && strcmp(altname,outername)!=0) {
00825 cl = TClass::GetClass(altname,load,silent);
00826 }
00827 }
00828 if (cl==0) {
00829
00830 string long64name = TClassEdit::GetLong64_Name( name );
00831 if ( long64name != name && long64name != outername ) return R__FindSTLClass( long64name.c_str(), load, silent, outername);
00832 }
00833 if (cl == 0) {
00834 TString resolvedName = TClassEdit::ResolveTypedef(name,kFALSE).c_str();
00835 if (resolvedName != name && resolvedName != outername) cl = TClass::GetClass(resolvedName,load,silent);
00836 }
00837 if (cl == 0 && (strncmp(name,"std::",5)==0)) {
00838
00839
00840 if (strlen(name+5)) cl = TClass::GetClass(name+5,load,silent);
00841 }
00842
00843 if (load && cl==0) {
00844
00845 cl = new TClass(defaultname.c_str(), TClass::GetClass("TVirtualStreamerInfo")->GetClassVersion(), 0, 0, -1, -1, silent );
00846 cl->SetBit(TClass::kIsEmulation);
00847 }
00848
00849 return cl;
00850 }
00851
00852
00853 TClass *TROOT::FindSTLClass(const char *name, Bool_t load, Bool_t silent) const
00854 {
00855
00856
00857
00858
00859 return R__FindSTLClass(name,load,silent,name);
00860 }
00861
00862
00863 TClass *TROOT::GetClass(const char *name, Bool_t load, Bool_t silent) const
00864 {
00865
00866
00867 return TClass::GetClass(name,load,silent);
00868 }
00869
00870
00871
00872 TClass *TROOT::GetClass(const type_info& typeinfo, Bool_t load, Bool_t silent) const
00873 {
00874
00875
00876
00877 return TClass::GetClass(typeinfo,load,silent);
00878 }
00879
00880
00881 TColor *TROOT::GetColor(Int_t color) const
00882 {
00883
00884
00885 TColor::InitializeColors();
00886 TObjArray *lcolors = (TObjArray*) GetListOfColors();
00887 if (color < 0 || color >= lcolors->GetSize()) return 0;
00888 TColor *col = (TColor*)lcolors->At(color);
00889 if (col && col->GetNumber() == color) return col;
00890 TIter next(lcolors);
00891 while ((col = (TColor *) next()))
00892 if (col->GetNumber() == color) return col;
00893
00894 return 0;
00895 }
00896
00897
00898 TCanvas *TROOT::MakeDefCanvas() const
00899 {
00900
00901
00902 return (TCanvas*)gROOT->ProcessLine("TCanvas::MakeDefCanvas();");
00903 }
00904
00905
00906 TDataType *TROOT::GetType(const char *name, Bool_t load) const
00907 {
00908
00909
00910 const char *tname = name + strspn(name," ");
00911 if (!strncmp(tname,"virtual",7)) {
00912 tname += 7; tname += strspn(tname," ");
00913 }
00914 if (!strncmp(tname,"const",5)) {
00915 tname += 5; tname += strspn(tname," ");
00916 }
00917 size_t nch = strlen(tname);
00918 while (tname[nch-1] == ' ') nch--;
00919
00920
00921
00922 TDataType* type = (TDataType*)gROOT->GetListOfTypes(kFALSE)->FindObject(name);
00923 if (type || !load)
00924 return type;
00925 else
00926 return (TDataType*)gROOT->GetListOfTypes(load)->FindObject(name);
00927 }
00928
00929
00930 TFile *TROOT::GetFile(const char *name) const
00931 {
00932
00933
00934 return (TFile*)GetListOfFiles()->FindObject(name);
00935 }
00936
00937
00938 TStyle *TROOT::GetStyle(const char *name) const
00939 {
00940
00941
00942 return (TStyle*)GetListOfStyles()->FindObject(name);
00943 }
00944
00945
00946 TObject *TROOT::GetFunction(const char *name) const
00947 {
00948
00949
00950 if (name == 0 || name[0] == 0) {
00951 return 0;
00952 }
00953
00954 TObject *f1 = fFunctions->FindObject(name);
00955 if (f1) return f1;
00956
00957 gROOT->ProcessLine("TF1::InitStandardFunctions();");
00958
00959 return fFunctions->FindObject(name);
00960 }
00961
00962
00963 TGlobal *TROOT::GetGlobal(const char *name, Bool_t load) const
00964 {
00965
00966
00967
00968 return (TGlobal *)gROOT->GetListOfGlobals(load)->FindObject(name);
00969 }
00970
00971
00972 TGlobal *TROOT::GetGlobal(const TObject *addr, Bool_t load) const
00973 {
00974
00975
00976
00977
00978 TIter next(gROOT->GetListOfGlobals(load));
00979
00980 TGlobal *g;
00981 while ((g = (TGlobal*) next())) {
00982 const char *t = g->GetFullTypeName();
00983 if (!strncmp(t, "class", 5) || !strncmp(t, "struct", 6)) {
00984 int ptr = 0;
00985 if (t[strlen(t)-1] == '*') ptr = 1;
00986 if (ptr) {
00987 if (*(Long_t *)g->GetAddress() == (Long_t)addr) return g;
00988 } else {
00989 if ((Long_t)g->GetAddress() == (Long_t)addr) return g;
00990 }
00991 }
00992 }
00993 return 0;
00994 }
00995
00996
00997 TFunction *TROOT::GetGlobalFunction(const char *function, const char *params,
00998 Bool_t load)
00999 {
01000
01001
01002
01003
01004
01005 if (!params)
01006 return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
01007 else {
01008 if (!fInterpreter)
01009 Fatal("GetGlobalFunction", "fInterpreter not initialized");
01010
01011 TFunction *f;
01012 TIter next(GetListOfGlobalFunctions(load));
01013
01014 TString mangled = gInterpreter->GetMangledName(0, function, params);
01015 while ((f = (TFunction *) next())) {
01016 if (mangled == f->GetMangledName()) return f;
01017 }
01018
01019 return 0;
01020 }
01021 }
01022
01023
01024 TFunction *TROOT::GetGlobalFunctionWithPrototype(const char *function,
01025 const char *proto, Bool_t load)
01026 {
01027
01028
01029
01030
01031
01032 if (!proto)
01033 return (TFunction *)GetListOfGlobalFunctions(load)->FindObject(function);
01034 else {
01035 if (!fInterpreter)
01036 Fatal("GetGlobalFunctionWithPrototype", "fInterpreter not initialized");
01037
01038 TFunction *f;
01039 TIter next(GetListOfGlobalFunctions(load));
01040
01041 TString mangled = gInterpreter->GetMangledNameWithPrototype(0,
01042 function,
01043 proto);
01044 while ((f = (TFunction *) next())) {
01045 if (mangled == f->GetMangledName()) return f;
01046 }
01047 return 0;
01048 }
01049 }
01050
01051
01052 TObject *TROOT::GetGeometry(const char *name) const
01053 {
01054
01055
01056 return GetListOfGeometries()->FindObject(name);
01057 }
01058
01059
01060 TCollection *TROOT::GetListOfGlobals(Bool_t load)
01061 {
01062
01063
01064
01065
01066
01067
01068
01069 if (!fGlobals) {
01070 fGlobals = new THashTable(100, 3);
01071 load = kTRUE;
01072 }
01073
01074 if (!fInterpreter)
01075 Fatal("GetListOfGlobals", "fInterpreter not initialized");
01076
01077 if (load)
01078 gInterpreter->UpdateListOfGlobals();
01079
01080 return fGlobals;
01081 }
01082
01083
01084 TCollection *TROOT::GetListOfGlobalFunctions(Bool_t load)
01085 {
01086
01087
01088
01089
01090
01091
01092
01093 if (!fGlobalFunctions) {
01094 fGlobalFunctions = new THashTable(100, 3);
01095 load = kTRUE;
01096 }
01097
01098 if (!fInterpreter)
01099 Fatal("GetListOfGlobalFunctions", "fInterpreter not initialized");
01100
01101 if (load)
01102 gInterpreter->UpdateListOfGlobalFunctions();
01103
01104 return fGlobalFunctions;
01105 }
01106
01107
01108 TCollection *TROOT::GetListOfTypes(Bool_t load)
01109 {
01110
01111
01112
01113
01114
01115
01116
01117 if (!fTypes) {
01118 fTypes = new THashTable(100, 3);
01119 load = kTRUE;
01120
01121
01122 fTypes->Add(new TDataType("char"));
01123 fTypes->Add(new TDataType("unsigned char"));
01124 fTypes->Add(new TDataType("short"));
01125 fTypes->Add(new TDataType("unsigned short"));
01126 fTypes->Add(new TDataType("int"));
01127 fTypes->Add(new TDataType("unsigned int"));
01128 fTypes->Add(new TDataType("unsigned"));
01129 fTypes->Add(new TDataType("long"));
01130 fTypes->Add(new TDataType("unsigned long"));
01131 fTypes->Add(new TDataType("long long"));
01132 fTypes->Add(new TDataType("unsigned long long"));
01133 fTypes->Add(new TDataType("float"));
01134 fTypes->Add(new TDataType("double"));
01135 fTypes->Add(new TDataType("void"));
01136 fTypes->Add(new TDataType("bool"));
01137 fTypes->Add(new TDataType("char*"));
01138 }
01139
01140 if (!fInterpreter)
01141 Fatal("GetListOfTypes", "fInterpreter not initialized");
01142
01143 if (load) {
01144
01145 gInterpreter->UpdateListOfTypes();
01146
01147 }
01148
01149 return fTypes;
01150 }
01151
01152
01153
01154 void TROOT::Idle(UInt_t idleTimeInSec, const char *command)
01155 {
01156
01157
01158 if (!fApplication)
01159 TApplication::CreateApplication();
01160
01161 if (idleTimeInSec <= 0)
01162 fApplication->RemoveIdleTimer();
01163 else
01164 fApplication->SetIdleTimer(idleTimeInSec, command);
01165 }
01166
01167
01168 Int_t TROOT::IgnoreInclude(const char *fname, const char * )
01169 {
01170
01171
01172
01173 if (fname == 0) return 0;
01174
01175 TString stem(fname);
01176
01177 Int_t where = stem.Last('.');
01178 if (where != kNPOS) {
01179 if (stem.EndsWith(".so") || stem.EndsWith(".sl") ||
01180 stem.EndsWith(".dl") || stem.EndsWith(".a") ||
01181 stem.EndsWith(".dll", TString::kIgnoreCase))
01182 return 0;
01183 stem.Remove(where);
01184 }
01185
01186 TString className = gSystem->BaseName(stem);
01187 TClass *cla = TClass::GetClass(className);
01188
01189 if (!cla) {
01190 className = stem;
01191 className.ReplaceAll("/", "::");
01192 className.ReplaceAll("\\", "::");
01193 if (className.Contains(":::")) {
01194
01195
01196
01197
01198
01199
01200 return 0;
01201 }
01202 cla = TClass::GetClass(className);
01203 }
01204 if ( cla ) {
01205 if (cla->GetDeclFileLine() <= 0) return 0;
01206 TString decfile = gSystem->BaseName(cla->GetDeclFileName());
01207 if (decfile == gSystem->BaseName(fname)) {
01208 return 1;
01209 }
01210 }
01211 return 0;
01212 }
01213
01214
01215 void TROOT::InitSystem()
01216 {
01217
01218
01219 if (gSystem == 0) {
01220 #if defined(R__UNIX)
01221 gSystem = new TUnixSystem;
01222 #elif defined(R__WIN32)
01223 gSystem = new TWinNTSystem;
01224 #else
01225 gSystem = new TSystem;
01226 #endif
01227
01228 if (gSystem->Init())
01229 fprintf(stderr, "Fatal in <TROOT::InitSystem>: can't init operating system layer\n");
01230
01231 if (!gSystem->HomeDirectory())
01232 fprintf(stderr, "Fatal in <TROOT::InitSystem>: HOME directory not set\n");
01233
01234
01235 gEnv = new TEnv(".rootrc");
01236
01237 gDebug = gEnv->GetValue("Root.Debug", 0);
01238
01239
01240 Int_t zipmode = gEnv->GetValue("Root.ZipMode",1);
01241 if (zipmode !=1) R__SetZipMode(zipmode);
01242
01243 const char *sdeb;
01244 if ((sdeb = gSystem->Getenv("ROOTDEBUG")))
01245 gDebug = atoi(sdeb);
01246
01247 if (gDebug > 0 && isatty(2))
01248 fprintf(stderr, "Info in <TROOT::InitSystem>: running with gDebug = %d\n", gDebug);
01249
01250 if (gEnv->GetValue("Root.MemStat", 0))
01251 TStorage::EnableStatistics();
01252 int msize = gEnv->GetValue("Root.MemStat.size", -1);
01253 int mcnt = gEnv->GetValue("Root.MemStat.cnt", -1);
01254 if (msize != -1 || mcnt != -1)
01255 TStorage::EnableStatistics(msize, mcnt);
01256
01257 fgMemCheck = gEnv->GetValue("Root.MemCheck", 0);
01258
01259 TObject::SetObjectStat(gEnv->GetValue("Root.ObjectStat", 0));
01260
01261 }
01262 }
01263
01264
01265 void TROOT::InitThreads()
01266 {
01267
01268
01269 if (gEnv->GetValue("Root.UseThreads", 0)) {
01270 char *path;
01271 if ((path = gSystem->DynamicPathName("libThread", kTRUE))) {
01272 delete [] path;
01273 LoadClass("TThread", "Thread");
01274 }
01275 }
01276 }
01277
01278
01279 TClass *TROOT::LoadClass(const char *requestedname, Bool_t silent) const
01280 {
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296 TString classname(requestedname);
01297
01298 VoidFuncPtr_t dict = TClassTable::GetDict(classname);
01299
01300 TString resolved;
01301
01302 if (!dict) {
01303
01304 resolved = TClassEdit::ResolveTypedef(classname,kTRUE);
01305 if (resolved != classname) {
01306 dict = TClassTable::GetDict(resolved.Data());
01307 } else {
01308 resolved.Clear();
01309 }
01310 }
01311 if (!dict) {
01312 if (gInterpreter->AutoLoad(classname)) {
01313 dict = TClassTable::GetDict(classname);
01314 if (!dict) {
01315
01316 if (resolved.Length()) {
01317 dict = TClassTable::GetDict(resolved.Data());
01318 }
01319 }
01320 }
01321 }
01322
01323 if (dict) {
01324 (dict)();
01325 TClass *ncl = TClass::GetClass(classname, kFALSE, silent);
01326 if (ncl) ncl->PostLoadCheck();
01327 return ncl;
01328 }
01329
01330 TIter next(fClassGenerators);
01331 TClassGenerator *gen;
01332 while ((gen = (TClassGenerator*) next())) {
01333 TClass *cl = gen->GetClass(classname, kTRUE, silent);
01334 if (cl) {
01335 cl->PostLoadCheck();
01336 return cl;
01337 }
01338 }
01339 return 0;
01340 }
01341
01342
01343 Int_t TROOT::LoadClass(const char * , const char *libname,
01344 Bool_t check)
01345 {
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359 Int_t err = -1;
01360
01361 char *path;
01362 TString lib = libname;
01363 if (!lib.BeginsWith("lib"))
01364 lib = "lib" + lib;
01365 if ((path = gSystem->DynamicPathName(lib, kTRUE))) {
01366 if (check)
01367 err = 0;
01368 else {
01369 err = gSystem->Load(path, 0, kTRUE);
01370 }
01371 delete [] path;
01372 } else {
01373 if (check) {
01374 FileStat_t stat;
01375 if (!gSystem->GetPathInfo(libname, stat)) {
01376 if (R_ISREG(stat.fMode) &&
01377 !gSystem->AccessPathName(libname, kReadPermission))
01378 err = 0;
01379 else
01380 err = -1;
01381 } else
01382 err = -1;
01383 } else {
01384 err = gSystem->Load(libname, 0, kTRUE);
01385 }
01386 }
01387
01388 if (err == 0 && !check) {
01389 GetListOfTypes(kTRUE);
01390 }
01391
01392 if (err == -1) {
01393
01394 }
01395
01396 if (err == 1) {
01397
01398
01399 err = 0;
01400 }
01401
01402 return err;
01403 }
01404
01405
01406 void TROOT::ls(Option_t *option) const
01407 {
01408
01409
01410
01411
01412
01413
01414
01415 TDirectory::ls(option);
01416 }
01417
01418
01419 Int_t TROOT::LoadMacro(const char *filename, int *error, Bool_t check)
01420 {
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431 Int_t err = -1;
01432 Int_t lerr, *terr;
01433 if (error)
01434 terr = error;
01435 else
01436 terr = &lerr;
01437
01438 if (fInterpreter) {
01439 TString aclicMode;
01440 TString arguments;
01441 TString io;
01442 TString fname = gSystem->SplitAclicMode(filename, aclicMode, arguments, io);
01443
01444 if (arguments.Length()) {
01445 Warning("LoadMacro", "argument(%s) ignored in %s", arguments.Data(), GetMacroPath());
01446 }
01447 char *mac = gSystem->Which(GetMacroPath(), fname, kReadPermission);
01448 if (!mac) {
01449 if (!check)
01450 Error("LoadMacro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
01451 *terr = TInterpreter::kFatal;
01452 } else {
01453 err = 0;
01454 if (!check) {
01455 fname = mac;
01456 fname += aclicMode;
01457 fname += io;
01458 gInterpreter->LoadMacro(fname.Data(), (TInterpreter::EErrorCode*)terr);
01459 if (*terr)
01460 err = -1;
01461
01462
01463 }
01464 }
01465 delete [] mac;
01466 }
01467 return err;
01468 }
01469
01470
01471 Long_t TROOT::Macro(const char *filename, Int_t *error, Bool_t padUpdate)
01472 {
01473
01474
01475
01476
01477
01478
01479
01480
01481 Long_t result = 0;
01482
01483 if (fInterpreter) {
01484 TString aclicMode;
01485 TString arguments;
01486 TString io;
01487 TString fname = gSystem->SplitAclicMode(filename, aclicMode, arguments, io);
01488
01489 char *mac = gSystem->Which(GetMacroPath(), fname, kReadPermission);
01490 if (!mac) {
01491 Error("Macro", "macro %s not found in path %s", fname.Data(), GetMacroPath());
01492 if (error)
01493 *error = TInterpreter::kFatal;
01494 } else {
01495 fname = mac;
01496 fname += aclicMode;
01497 fname += arguments;
01498 fname += io;
01499 result = gInterpreter->ExecuteMacro(fname, (TInterpreter::EErrorCode*)error);
01500 }
01501 delete [] mac;
01502
01503 if (padUpdate && gPad)
01504 gPad->Update();
01505 }
01506
01507 return result;
01508 }
01509
01510
01511 void TROOT::Message(Int_t id, const TObject *obj)
01512 {
01513
01514
01515 TIter next(fMessageHandlers);
01516 TMessageHandler *mh;
01517 while ((mh = (TMessageHandler*)next())) {
01518 mh->HandleMessage(id,obj);
01519 }
01520 }
01521
01522
01523 Long_t TROOT::ProcessLine(const char *line, Int_t *error)
01524 {
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535 TString sline = line;
01536 sline = sline.Strip(TString::kBoth);
01537
01538 if (!fApplication)
01539 TApplication::CreateApplication();
01540
01541 return fApplication->ProcessLine(sline, kFALSE, error);
01542 }
01543
01544
01545 Long_t TROOT::ProcessLineSync(const char *line, Int_t *error)
01546 {
01547
01548
01549
01550
01551
01552
01553
01554
01555 TString sline = line;
01556 sline = sline.Strip(TString::kBoth);
01557
01558 if (!fApplication)
01559 TApplication::CreateApplication();
01560
01561 return fApplication->ProcessLine(sline, kTRUE, error);
01562 }
01563
01564
01565 Long_t TROOT::ProcessLineFast(const char *line, Int_t *error)
01566 {
01567
01568
01569
01570
01571
01572 TString sline = line;
01573 sline = sline.Strip(TString::kBoth);
01574
01575 if (!fApplication)
01576 TApplication::CreateApplication();
01577
01578 Long_t result = 0;
01579
01580 if (fInterpreter) {
01581 TInterpreter::EErrorCode *code = (TInterpreter::EErrorCode*)error;
01582 result = gInterpreter->Calc(sline, code);
01583 }
01584
01585 return result;
01586 }
01587
01588
01589 void TROOT::ReadSvnInfo()
01590 {
01591
01592
01593
01594 fSvnRevision = 0;
01595 #ifdef ROOT_SVN_REVISION
01596 fSvnRevision = ROOT_SVN_REVISION;
01597 #endif
01598 #ifdef ROOT_SVN_BRANCH
01599 fSvnBranch = ROOT_SVN_BRANCH;
01600 #endif
01601
01602 TString svninfo = "svninfo.txt";
01603 char *filename = 0;
01604 #ifdef ROOTETCDIR
01605 filename = gSystem->ConcatFileName(ROOTETCDIR, svninfo);
01606 #else
01607 TString etc = gRootDir;
01608 #ifdef WIN32
01609 etc += "\\etc";
01610 #else
01611 etc += "/etc";
01612 #endif
01613 #if defined(R__MACOSX) && (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
01614
01615 etc = gRootDir;
01616 #endif
01617 filename = gSystem->ConcatFileName(etc, svninfo);
01618 #endif
01619
01620 FILE *fp = fopen(filename, "r");
01621 if (fp) {
01622 TString s;
01623
01624 s.Gets(fp);
01625 fSvnBranch = s;
01626
01627 s.Gets(fp);
01628 Int_t r = s.Atoi();
01629 if (r > 0)
01630 fSvnRevision = r;
01631
01632 s.Gets(fp);
01633 fSvnDate = s;
01634 fclose(fp);
01635 }
01636 delete [] filename;
01637 }
01638
01639
01640 const char *TROOT::GetSvnDate()
01641 {
01642
01643
01644 if (fSvnDate == "") {
01645 Int_t iday,imonth,iyear, ihour, imin;
01646 static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
01647 "Jul", "Aug", "Sep", "Oct", "Nov", "De" };
01648 Int_t idate = gROOT->GetBuiltDate();
01649 Int_t itime = gROOT->GetBuiltTime();
01650 iday = idate%100;
01651 imonth = (idate/100)%100;
01652 iyear = idate/10000;
01653 ihour = itime/100;
01654 imin = itime%100;
01655 fSvnDate.Form("%s %02d %4d, %02d:%02d:00", months[imonth-1], iday, iyear, ihour, imin);
01656 }
01657 return fSvnDate;
01658 }
01659
01660
01661 void TROOT::RefreshBrowsers()
01662 {
01663
01664
01665
01666
01667
01668
01669 TIter next(GetListOfBrowsers());
01670 TBrowser *b;
01671 while ((b = (TBrowser*) next()))
01672 b->SetRefreshFlag(kTRUE);
01673 }
01674
01675
01676 void TROOT::RemoveClass(TClass *oldcl)
01677 {
01678
01679
01680
01681
01682
01683
01684
01685 TClass::RemoveClass(oldcl);
01686 }
01687
01688
01689 void TROOT::Reset(Option_t *option)
01690 {
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708 if (IsExecutingMacro()) return;
01709 if (fInterpreter) {
01710 if (!strncmp(option, "a", 1)) {
01711 fInterpreter->Reset();
01712 fInterpreter->SaveContext();
01713 } else
01714 gInterpreter->ResetGlobals();
01715
01716 if (fGlobals) fGlobals->Delete();
01717 if (fGlobalFunctions) fGlobalFunctions->Delete();
01718
01719 SaveContext();
01720 }
01721 }
01722
01723
01724 void TROOT::SaveContext()
01725 {
01726
01727
01728 if (fInterpreter)
01729 gInterpreter->SaveGlobalsContext();
01730 }
01731
01732
01733 void TROOT::SetCutClassName(const char *name)
01734 {
01735
01736
01737
01738
01739
01740 if (!name) {
01741 Error("SetCutClassName","Invalid class name");
01742 return;
01743 }
01744 TClass *cl = TClass::GetClass(name);
01745 if (!cl) {
01746 Error("SetCutClassName","Unknown class:%s",name);
01747 return;
01748 }
01749 if (!cl->InheritsFrom("TCutG")) {
01750 Error("SetCutClassName","Class:%s does not derive from TCutG",name);
01751 return;
01752 }
01753 fCutClassName = name;
01754 }
01755
01756
01757 void TROOT::SetEditorMode(const char *mode)
01758 {
01759
01760
01761 fEditorMode = 0;
01762 if (strlen(mode) == 0) return;
01763 if (!strcmp(mode,"Arc")) {fEditorMode = kArc; return;}
01764 if (!strcmp(mode,"Line")) {fEditorMode = kLine; return;}
01765 if (!strcmp(mode,"Arrow")) {fEditorMode = kArrow; return;}
01766 if (!strcmp(mode,"Button")) {fEditorMode = kButton; return;}
01767 if (!strcmp(mode,"Diamond")) {fEditorMode = kDiamond; return;}
01768 if (!strcmp(mode,"Ellipse")) {fEditorMode = kEllipse; return;}
01769 if (!strcmp(mode,"Pad")) {fEditorMode = kPad; return;}
01770 if (!strcmp(mode,"Pave")) {fEditorMode = kPave; return;}
01771 if (!strcmp(mode,"PaveLabel")){fEditorMode = kPaveLabel; return;}
01772 if (!strcmp(mode,"PaveText")) {fEditorMode = kPaveText; return;}
01773 if (!strcmp(mode,"PavesText")){fEditorMode = kPavesText; return;}
01774 if (!strcmp(mode,"PolyLine")) {fEditorMode = kPolyLine; return;}
01775 if (!strcmp(mode,"CurlyLine")){fEditorMode = kCurlyLine; return;}
01776 if (!strcmp(mode,"CurlyArc")) {fEditorMode = kCurlyArc; return;}
01777 if (!strcmp(mode,"Text")) {fEditorMode = kText; return;}
01778 if (!strcmp(mode,"Marker")) {fEditorMode = kMarker; return;}
01779 if (!strcmp(mode,"CutG")) {fEditorMode = kCutG; return;}
01780 }
01781
01782
01783 void TROOT::SetStyle(const char *stylename)
01784 {
01785
01786
01787 TStyle *style = GetStyle(stylename);
01788 if (style) style->cd();
01789 else Error("SetStyle","Unknown style:%s",stylename);
01790 }
01791
01792
01793
01794
01795
01796
01797 Int_t TROOT::DecreaseDirLevel()
01798 {
01799
01800 return --fgDirLevel;
01801 }
01802
01803
01804 Int_t TROOT::GetDirLevel()
01805 {
01806
01807 return fgDirLevel;
01808 }
01809
01810
01811 const char *TROOT::GetMacroPath()
01812 {
01813
01814
01815 TString ¯oPath = ROOT::GetMacroPath();
01816
01817 if (macroPath.Length() == 0) {
01818 macroPath = gEnv->GetValue("Root.MacroPath", (char*)0);
01819 #if defined(R__WIN32)
01820 macroPath.ReplaceAll("; ", ";");
01821 #else
01822 macroPath.ReplaceAll(": ", ":");
01823 #endif
01824 if (macroPath.Length() == 0)
01825 #if !defined(R__WIN32)
01826 #ifdef ROOTMACRODIR
01827 macroPath = ".:" ROOTMACRODIR;
01828 #else
01829 macroPath = TString(".:") + gRootDir + "/macros";
01830 #endif
01831 #else
01832 #ifdef ROOTMACRODIR
01833 macroPath = ".;" ROOTMACRODIR;
01834 #else
01835 macroPath = TString(".;") + gRootDir + "/macros";
01836 #endif
01837 #endif
01838 }
01839
01840 return macroPath;
01841 }
01842
01843
01844 void TROOT::SetMacroPath(const char *newpath)
01845 {
01846
01847
01848
01849 TString ¯oPath = ROOT::GetMacroPath();
01850
01851 if (!newpath || !*newpath)
01852 macroPath = "";
01853 else
01854 macroPath = newpath;
01855 }
01856
01857
01858 Int_t TROOT::IncreaseDirLevel()
01859 {
01860
01861 return ++fgDirLevel;
01862 }
01863
01864
01865 void TROOT::IndentLevel()
01866 {
01867
01868
01869 for (int i = 0; i < fgDirLevel; i++) cout.put(' ');
01870 }
01871
01872
01873 Bool_t TROOT::Initialized()
01874 {
01875
01876 return fgRootInit;
01877 }
01878
01879
01880 Bool_t TROOT::MemCheck()
01881 {
01882
01883 return fgMemCheck;
01884 }
01885
01886
01887 void TROOT::SetDirLevel(Int_t level)
01888 {
01889
01890 fgDirLevel = level;
01891 }
01892
01893
01894 Int_t TROOT::ConvertVersionCode2Int(Int_t code)
01895 {
01896
01897
01898 return 10000*(code>>16) + 100*((code&65280)>>8) + (code&255);
01899 }
01900
01901
01902 Int_t TROOT::ConvertVersionInt2Code(Int_t v)
01903 {
01904
01905
01906 int a = v/10000;
01907 int b = (v - a*10000)/100;
01908 int c = v - a*10000 - b*100;
01909 return (a << 16) + (b << 8) + c;
01910 }
01911
01912
01913 Int_t TROOT::RootVersionCode()
01914 {
01915
01916
01917 return ROOT_VERSION_CODE;
01918 }