00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4AnalysisObjectNames.h"
00017
00018 #include "Riostream.h"
00019
00020 #include "TROOT.h"
00021 #include "TFolder.h"
00022 #include "TGo4Log.h"
00023
00024 TGo4AnalysisObjectNames::TGo4AnalysisObjectNames() :
00025 TGo4Status(),
00026 fxTopFolder(0)
00027 {
00028 }
00029
00030 TGo4AnalysisObjectNames::TGo4AnalysisObjectNames(const char* name) :
00031 TGo4Status(name),
00032 fxTopFolder(0)
00033 {
00034 TRACE((15,"TGo4AnalysisObjectnames::TGo4AnalysisObjectnames(Text_t*)",__LINE__, __FILE__));
00035 }
00036
00037 TGo4AnalysisObjectNames::~TGo4AnalysisObjectNames()
00038 {
00039 TRACE((15,"TGo4AnalysisObjectnames::~TGo4AnalysisObjectnames()",__LINE__, __FILE__));
00040 if(fxTopFolder!=0) {
00041 delete fxTopFolder;
00042 fxTopFolder=0;
00043 }
00044 }
00045
00046 TList* TGo4AnalysisObjectNames::GetFolderList()
00047 {
00048 if(fxTopFolder!=0)
00049 return dynamic_cast<TList*> (fxTopFolder->GetListOfFolders());
00050 else
00051 return 0;
00052 }
00053
00054 TFolder* TGo4AnalysisObjectNames::GetNamesFolder(Bool_t chown)
00055 {
00056 TFolder* reval=fxTopFolder;
00057 if(chown) fxTopFolder=0;
00058 return reval;
00059 }
00060
00061
00062 Int_t TGo4AnalysisObjectNames::PrintStatus(Text_t* buffer, Int_t buflen)
00063 {
00064 TRACE((12,"TGo4AnalysisObjectNames::PrintStatus()",__LINE__, __FILE__));
00065
00066 if(buflen<=0 && buffer!=0)
00067 return 0;
00068 gROOT->SetDirLevel(0);
00069 Int_t locallen=64000;
00070 Text_t localbuf[64000];
00071 Int_t size=0;
00072 Text_t* current=localbuf;
00073 Int_t restlen=locallen;
00074 current=PrintBuffer(localbuf,restlen,"G-OOOO-> Analysis Object Names Printout <-OOOO-G\n");
00075 current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00076 Int_t delta=PrintFolder(fxTopFolder, current, restlen);
00077 restlen-=delta;
00078 current+= delta;
00079 if(buffer==0)
00080 {
00081 cout << localbuf << endl;
00082 }
00083 else
00084 {
00085 size=locallen-restlen;
00086 if(size>buflen-1)
00087 size=buflen-1;
00088 strncpy(buffer,localbuf,size);
00089 }
00090 return size;
00091 }
00092
00093 Int_t TGo4AnalysisObjectNames::PrintFolder(TFolder* fold, Text_t * buf, Int_t buflen)
00094 {
00095 TRACE((12,"TGo4AnalysisObjectNames::PrintFolder()",__LINE__, __FILE__));
00096
00097 if(buf!=0 && buflen<=0)
00098 {
00099 cout <<"PrintFolder returns nop" << endl;
00100 return 0;
00101 }
00102 gROOT->IncreaseDirLevel();
00103 Int_t locallen=64000;
00104 Text_t localbuf[64000];
00105 Int_t size=0;
00106 Text_t* current=localbuf;
00107 Int_t restlen=locallen;
00108 if(fold!=0) {
00109 current=PrintIndent(current,restlen);
00110 current=PrintBuffer(current,restlen,"G-OOOO-> Status Folder %s Printout <-OOOO-G\n", fold->GetName());
00111 current=PrintIndent(current,restlen);
00112 current=PrintBuffer(current,restlen,"G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00113
00114
00115
00116 TIter iter(fold->GetListOfFolders());
00117 TObject* entry=0;
00118
00119 while((entry=iter()) !=0) {
00120 if(entry->InheritsFrom(TFolder::Class()))
00121 {
00122
00123 TFolder* subobj= dynamic_cast<TFolder*> (entry);
00124 Int_t delta=PrintFolder(subobj, current, restlen);
00125 restlen-=delta;
00126 current+= delta;
00127 }
00128 else if (entry->InheritsFrom(TGo4Status::Class()))
00129 {
00130 TGo4Status* subobj= dynamic_cast<TGo4Status*> (entry);
00131 Int_t delta=subobj->PrintStatus(current,restlen);
00132 restlen-=delta;
00133 current+=delta;
00134 }
00135 else
00136 {
00137 entry->ls();
00138
00139 }
00140 }
00141 current=PrintIndent(current,restlen);
00142 current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00143 }
00144
00145 if(buf==0)
00146 {
00147 cout << localbuf << endl;
00148 }
00149 else
00150 {
00151 size=locallen-restlen;
00152 if(size>buflen-1)
00153 size=buflen-1;
00154 strncpy(buf,localbuf,size);
00155
00156 }
00157 gROOT->DecreaseDirLevel();
00158 return size;
00159 }
00160
00161