00001 //--------------------------------------------------------------- 00002 // Go4 Release Package v2.10-5 (build 21005) 00003 // 03-Nov-2005 00004 //--------------------------------------------------------------- 00005 // The GSI Online Offline Object Oriented (Go4) Project 00006 // Experiment Data Processing at DVEE department, GSI 00007 //--------------------------------------------------------------- 00008 // 00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI 00010 // Planckstr. 1, 64291 Darmstadt, Germany 00011 //Contact: http://go4.gsi.de 00012 //---------------------------------------------------------------- 00013 //This software can be used under the license agreements as stated 00014 //in Go4License.txt file which is part of the distribution. 00015 //---------------------------------------------------------------- 00016 #include "TGo4DiskFileBrowserStatus.h" 00017 00018 #include <iostream.h> 00019 00020 #include "TFile.h" 00021 #include "TObjArray.h" 00022 #include "TTree.h" 00023 00024 TGo4DiskFileBrowserStatus::TGo4DiskFileBrowserStatus(const char* name, const char* title) 00025 :TGo4Status(name, title) 00026 { 00027 // TGo4LockGuard Global; 00028 FileListStatus=new TObjArray(); 00029 fxActiveTree=0; 00030 fxActiveFile=0; 00031 } 00032 00033 TObjArray *TGo4DiskFileBrowserStatus::GetFileListStatus() 00034 { 00035 // TGo4LockGuard Global; 00036 return FileListStatus; 00037 } 00038 void TGo4DiskFileBrowserStatus::RemoveFromFileListStatus(TNamed *f) 00039 { 00040 // TGo4LockGuard Global; 00041 FileListStatus->Remove(f); 00042 FileListStatus->Compress(); 00043 FileListStatus->Expand(FileListStatus->GetLast()+1); 00044 TFile* toactive=dynamic_cast<TFile*>(FileListStatus->Last()); 00045 SetActiveFile(toactive); 00046 SetActiveTree((TTree*) 0); // prevent treeviewer crash 00047 00048 // delete f; 00049 00050 } 00051 TObject* TGo4DiskFileBrowserStatus::GetObjectfromFileList(const char *Object) 00052 { 00053 // TGo4LockGuard Global; 00054 return(FileListStatus->FindObject(Object)); 00055 00056 } 00057 void TGo4DiskFileBrowserStatus::AddToFileListStatus(TNamed *f) 00058 { 00059 // TGo4LockGuard Global; 00060 FileListStatus->Add(f); 00061 FileListStatus->Sort(kTRUE); 00062 } 00063 00064 TGo4DiskFileBrowserStatus::~TGo4DiskFileBrowserStatus() 00065 { 00066 // TGo4LockGuard Global; 00067 for (int i=0 ;i<=FileListStatus->LastIndex();i++ ){ 00068 ((TFile *)FileListStatus->At(i))->Close(); 00069 } 00070 FileListStatus->Delete(); 00071 delete FileListStatus; 00072 } 00073 00074 void TGo4DiskFileBrowserStatus::SetActiveTree(const char *TreeName) 00075 { 00076 // TGo4LockGuard Global; 00077 if(fxActiveFile!=0){ 00078 fxActiveTree = (TTree*) (fxActiveFile->Get(TreeName)); 00079 00080 } 00081 } 00082 void TGo4DiskFileBrowserStatus::SetActiveTree(TTree *fxTree) 00083 { 00084 // TGo4LockGuard Global; 00085 // cout << "TGo4DiskFileBrowserStatus::SetActiveTree "<< fxTree << endl; 00086 fxActiveTree =fxTree; 00087 } 00088 00089 TTree *TGo4DiskFileBrowserStatus::GetActiveTree() 00090 { 00091 // TGo4LockGuard Global; 00092 return fxActiveTree; 00093 } 00094 00095 void TGo4DiskFileBrowserStatus::SetActiveFile(TFile *fxFile) 00096 { 00097 // TGo4LockGuard Global; 00098 fxActiveFile= fxFile; 00099 if(fxActiveFile) fxActiveFile->cd(); 00100 00101 } 00102 TFile *TGo4DiskFileBrowserStatus::GetActiveFile() 00103 { 00104 // TGo4LockGuard Global; 00105 return fxActiveFile; 00106 } 00107 00108 void TGo4DiskFileBrowserStatus::SetActiveFile(const char *f) 00109 { 00110 // TGo4LockGuard Global; 00111 TFile *File; 00112 char FileName[256]; 00113 FileName[0]=0; 00114 File=gROOT->GetFile(f); 00115 if (File!=0){ 00116 SetActiveFile(File); 00117 } 00118 else 00119 { 00120 fxActiveFile= 0; 00121 } 00122 } 00123 00124 00125 //----------------------------END OF GO4 SOURCE FILE ---------------------