Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4StatusAnalysis/TGo4EventStatus.cxx

Go to the documentation of this file.
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 "TGo4EventStatus.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TClass.h"
00021 #include "TDataMember.h"
00022 #include "TBaseClass.h"
00023 
00024 #include "Go4Log/TGo4Log.h"
00025 #include "Go4Event/TGo4EventElement.h"
00026 #include "Go4StatusBase/TGo4MemberStatus.h"
00027 
00028 TGo4EventStatus::TGo4EventStatus(TGo4EventElement* ev) : TGo4ObjectStatus(ev,kFALSE)
00029 {
00030    fxTempFolder = gROOT->GetRootFolder()->AddFolder("temp","Eventstatus temporary object folder");
00031    fxTempFolder->SetOwner(kFALSE);
00032    TClass* eclass = ev->IsA();
00033    fxFolder = CreateMembersFolder(eclass);
00034 }
00035 
00036 TGo4EventStatus::TGo4EventStatus() : TGo4ObjectStatus()
00037 {
00038 }
00039 
00040 TGo4EventStatus::~TGo4EventStatus()
00041 {
00042    gROOT->GetRootFolder()->Remove(fxTempFolder);
00043    fxTempFolder->Clear();
00044    delete fxTempFolder;
00045 }
00046 
00047 
00048 Int_t TGo4EventStatus::PrintStatus(Text_t* buffer, Int_t buflen)
00049 {
00050    TRACE((12,"TGo4EventStatus::PrintStatus()",__LINE__, __FILE__));
00051    if(buflen<=0 && buffer!=0)
00052       return 0;
00053    Int_t locallen=128000;
00054    Text_t localbuf[locallen];
00055    Int_t size=0;
00056    Text_t* current=localbuf;
00057    Int_t restlen=locallen;
00058    Int_t delta   = TGo4ObjectStatus::PrintStatus(current,restlen);
00059    restlen-=delta;
00060    current+=delta;   
00061    current=PrintIndent(current,restlen);
00062    current=PrintBuffer(current,restlen, "G-OOOO-> Event Status Class Printout <-OOOO-G\n");
00063    current=PrintIndent(current,restlen);
00064    current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00065    // put printout of members here:
00066    if(fxFolder) {
00067        TIter iter(fxFolder->GetListOfFolders());
00068        TObject* nob = 0;
00069        while((nob = iter()) !=0)
00070          {
00071             TGo4MemberStatus* memstat= dynamic_cast<TGo4MemberStatus*>(nob);
00072             if(memstat)
00073                {
00074                   delta=memstat->PrintStatus(current,restlen);
00075                   restlen-=delta;
00076                   current+=delta;
00077                }
00078          } // while
00079       } // if(fxFolder)
00081   if(buffer==0)
00082       {
00083           cout << localbuf << endl;
00084       }
00085    else
00086       {
00087          size=locallen-restlen;
00088          if(size>buflen-1)
00089                size=buflen-1;
00090          strncpy(buffer,localbuf,size);
00091       }
00092    return size;
00093 }
00094 
00095 
00096 TFolder* TGo4EventStatus::CreateMembersFolder(TClass* cl)
00097 {
00098 if(cl==0) return 0;
00099 TFolder* memberfolder;
00100 TList* nameslist= new TList;
00101 TList* members =cl->GetListOfDataMembers();
00102 TIterator* memiter=members->MakeIterator();
00103 TObject* nob=0;
00104 TGo4MemberStatus* state;
00105 // scan members of this event class:
00106 while((nob=memiter->Next()) !=0)
00107    {
00108       TDataMember* mem=dynamic_cast<TDataMember*>(nob);
00109       if(mem->IsaPointer()) continue; // suppress heap aggregates
00110          // later, we might scan these recursively
00111       state=new TGo4MemberStatus(mem);
00112       nameslist->AddLast(state);
00113    } // while
00114 delete memiter;
00115 // now process baseclasses of event:
00116 TList* baselist=cl->GetListOfBases();
00117 TIterator* baseiter=baselist->MakeIterator();
00118 TObject* bob=0;
00119 while((bob=baseiter->Next()) !=0)
00120    {
00121       TBaseClass* baseclass=dynamic_cast<TBaseClass*>(bob);
00122       if(baseclass)
00123          {
00124             // we have a baseclass
00125             TClass* bclass=baseclass->GetClassPointer();
00126             if(bclass==0) continue;
00127             if(!strcmp(bclass->GetName(),"TNamed")) continue; // suppress bases above
00128                      // recursively find out members of all baseclasses
00129             TFolder* subfold=CreateMembersFolder(bclass);
00130             if(subfold==0) continue;
00131 //            Text_t buffer[256];
00132 //            snprintf(buffer,256,"%s::%s",bclass->GetName(),subfold->GetName());
00133 //            subfold->SetName(buffer); // folder name contains baseclass name
00134             subfold->SetName(bclass->GetName()); // baseclass folder has baseclass name
00135             nameslist->AddLast(subfold);
00136           }
00137    } // while((bob=baseiter->Next()) !=0)
00138 delete baseiter;
00139 memberfolder=fxTempFolder->AddFolder(GetName(),GetTitle(),nameslist);
00140 fxTempFolder->Remove(memberfolder);
00141 memberfolder->SetOwner(kTRUE);
00142 return memberfolder;
00143 }
00144 
00145 
00146 
00147 ClassImp(TGo4EventStatus)
00148 
00149 
00150 
00151 
00152 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:05 2005 for Go4-v2.10-5 by doxygen1.2.15