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

/Go4StatusAnalysis/TGo4AnalysisStatus.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 "TGo4AnalysisStatus.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TMutex.h"
00021 
00022 #include "Go4ThreadManager/TGo4LockGuard.h"
00023 #include "Go4Log/TGo4Log.h"
00024 #include "TGo4AnalysisStepStatus.h"
00025 
00026 TGo4AnalysisStatus::TGo4AnalysisStatus(const char* name) : 
00027   TGo4Status(name,"Go4 Analysis Status Object"),
00028   fxStepArray(0),fxStepMutex(0),fxStepIterator(0),
00029   fbStepCheckingMode(1),fiFirstStepIndex(0), fiLastStepIndex(0),
00030   fiAutoSaveInterval(0), fiAutoSaveCompression(5), fbAutoSaveOverwrite(0), fbAutoSaveOn(1)
00031 {
00032   TRACE((15,"TGo4AnalysisStatus::TGo4AnalysisStatus(Text_t*)",__LINE__, __FILE__));
00033   fxStepArray= new TObjArray;
00034   fxStepIterator= fxStepArray->MakeIterator();
00035   fxStepMutex=new TMutex;
00036 }
00037 
00038 TGo4AnalysisStatus::TGo4AnalysisStatus() :
00039   TGo4Status("Go4 Default Analysis Status","Go4 Analysis Status Object"),
00040   fxStepArray(0),fxStepMutex(0),fxStepIterator(0),
00041   fbStepCheckingMode(1),fiFirstStepIndex(0), fiLastStepIndex(0),
00042   fiAutoSaveInterval(0), fiAutoSaveCompression(5), fbAutoSaveOverwrite(0), fbAutoSaveOn(1)
00043 {
00044   TRACE((15,"TGo4AnalysisStatus::TGo4AnalysisStatus()",__LINE__, __FILE__));
00045   // disable heap objects to avoid streamer leak
00046   //fxStepArray= new TObjArray;
00047   //fxStepIterator= fxStepArray->MakeIterator();
00048   //fxStepMutex=new TMutex;
00049 }
00050 
00051 TGo4AnalysisStatus::~TGo4AnalysisStatus()
00052 {
00053   TRACE((15,"TGo4AnalysisStatus::~TGo4AnalysisStatus()",__LINE__, __FILE__));
00054   delete fxStepMutex;
00055   delete fxStepIterator;
00056   fxStepArray->Delete();
00057   delete fxStepArray;
00058 }
00059 
00060 Int_t TGo4AnalysisStatus::PrintStatus(Text_t* buffer, Int_t buflen)
00061 {
00062    TRACE((12,"TGo4AnalysisStatus::PrintStatus()",__LINE__, __FILE__));
00063    if(buflen<=0 && buffer!=0)
00064       {
00065          cout << "analysis status print has invalid buflen and nonzero buffer"<< endl;
00066          return 0;
00067       }
00068    Int_t size=0;
00069    Int_t locallen=512000;
00070    Text_t localbuf[locallen];
00071    Text_t* current=localbuf;
00072    Int_t restlen=locallen;
00073    current=PrintBuffer(current,restlen, "----------------------------------------------  \n");
00074    current=PrintBuffer(current,restlen, "++++++ Status of %s ++++++\n", GetName());
00075    current=PrintBuffer(current,restlen, "First Analysis Step index: \t%d\n",GetFirstStepIndex());
00076    current=PrintBuffer(current,restlen, "Last Analysis Step index: \t%d\n",GetLastStepIndex());
00077    current=PrintBuffer(current,restlen, "Autosave Interval: \t\t%d s\n",GetAutoSaveInterval());
00078    current=PrintBuffer(current,restlen, "Autosave File: \t\t\t%s \n",GetAutoFileName());
00079    current=PrintBuffer(current,restlen, "Autosave File compression: \t%d \n",GetAutoSaveCompression());
00080    current=PrintBuffer(current,restlen, "Autosave overwrite mode: \t%d \n",IsAutoSaveOverwrite());
00081    current=PrintBuffer(current,restlen, "----------------------------------------------  \n");
00082    TROOT::IncreaseDirLevel();
00083    ResetStepIterator();
00084    TGo4AnalysisStepStatus* step=0;   
00085    while((step=NextStepStatus()) != 0)
00086       {
00087            Int_t delta=step->PrintStatus(current,restlen);
00088            restlen-=delta;
00089            current+= delta ;
00090       }
00091    TROOT::DecreaseDirLevel();
00092    current=PrintBuffer(current,restlen, "----------------------------------------------  \n");
00093    if(buffer==0)
00094       {
00095           cout << localbuf << endl;
00096       }
00097    else
00098       {
00099          size=locallen-restlen;
00100          if(size>buflen-1)
00101                size=buflen-1;
00102          strncpy(buffer,localbuf,size);
00103       }
00104    return size;
00105 }
00106 
00107 TGo4AnalysisStepStatus * TGo4AnalysisStatus::GetStepStatus(const Text_t * name)
00108 {
00109 TRACE((11,"TGo4Analysis::GetAnalysisStep(Text_t *)",__LINE__, __FILE__));
00110 if(fxStepArray==0) return 0;
00111    TGo4AnalysisStepStatus* step=0;
00112       {
00113       TGo4LockGuard  listguard(fxStepMutex);
00114          step = dynamic_cast<TGo4AnalysisStepStatus*>( fxStepArray->FindObject(name) );
00115       }
00116    return step;
00117 }
00118 
00119 TGo4AnalysisStepStatus * TGo4AnalysisStatus::NextStepStatus()
00120 {
00121 TRACE((11,"TGo4AnalysisStatus::GetAnalysisStep(Text_t *)",__LINE__, __FILE__));
00122 if(fxStepIterator==0) return 0;
00123    TGo4AnalysisStepStatus* step=0;
00124       {
00125       TGo4LockGuard  listguard(fxStepMutex);
00126          step = dynamic_cast<TGo4AnalysisStepStatus*>( fxStepIterator->Next() );
00127       }
00128    return step;
00129 }
00130 
00131 void TGo4AnalysisStatus::ResetStepIterator()
00132 {
00133    TGo4LockGuard listguard(fxStepMutex);
00134       delete fxStepIterator;
00135       if(fxStepArray)
00136          fxStepIterator=fxStepArray->MakeIterator();
00137       else
00138          fxStepIterator=0;
00139       // fxStepIterator->Reset();
00140 }
00141 
00142 
00143 Bool_t  TGo4AnalysisStatus::AddStepStatus(TGo4AnalysisStepStatus * next)
00144 {
00145 TRACE((14,"TGo4AnalysisStatus::AddAnalysisStep(TGo4AnalysisStep*)",__LINE__, __FILE__));
00146 //
00147 if(fxStepArray==0) return kFALSE;
00148    Bool_t rev=kFALSE;
00149    if(next)
00150       {
00151       TGo4LockGuard  listguard(fxStepMutex);
00152           fxStepArray->AddLast(next);
00153           rev=kTRUE;
00154       } //  if(next) ; TGo4LockGuard
00155    else
00156       {
00157            rev=kFALSE;
00158 //         TGo4Log::Debug(" Analysis: WARNING - did not add zero analysis step pointer to steplist ");
00159       }
00160    return rev;
00161 }
00162 
00163 ClassImp(TGo4AnalysisStatus)
00164 
00165 //----------------------------END OF GO4 SOURCE FILE ---------------------

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