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