Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4AnalysisStatus.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE 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 "Riostream.h"
00019 
00020 #include "TMutex.h"
00021 #include "TObjArray.h"
00022 #include "TROOT.h"
00023 
00024 #include "TGo4LockGuard.h"
00025 #include "TGo4Log.h"
00026 #include "TGo4AnalysisStepStatus.h"
00027 
00028 TGo4AnalysisStatus::TGo4AnalysisStatus() :
00029    TGo4Status("Go4 Default Analysis Status","Go4 Analysis Status Object"),
00030    fxStepArray(0),
00031    fxStepMutex(0),
00032    fxStepIterator(0),
00033    fbStepCheckingMode(1),
00034    fiFirstStepIndex(0),
00035    fiLastStepIndex(0),
00036    fiAutoSaveInterval(0),
00037    fiAutoSaveCompression(5),
00038    fbAutoSaveOverwrite(0),
00039    fbAutoSaveOn(1),
00040    fxAutoFileName(),
00041    fxConfigFileName()
00042 {
00043   TRACE((15,"TGo4AnalysisStatus::TGo4AnalysisStatus()",__LINE__, __FILE__));
00044 }
00045 
00046 
00047 TGo4AnalysisStatus::TGo4AnalysisStatus(const char* name) :
00048    TGo4Status(name,"Go4 Analysis Status Object"),
00049    fxStepArray(0),
00050    fxStepMutex(0),
00051    fxStepIterator(0),
00052    fbStepCheckingMode(1),
00053    fiFirstStepIndex(0),
00054    fiLastStepIndex(0),
00055    fiAutoSaveInterval(0),
00056    fiAutoSaveCompression(5),
00057    fbAutoSaveOverwrite(0),
00058    fbAutoSaveOn(1),
00059    fxAutoFileName(),
00060    fxConfigFileName()
00061 {
00062   TRACE((15,"TGo4AnalysisStatus::TGo4AnalysisStatus(Text_t*)",__LINE__, __FILE__));
00063   fxStepArray = new TObjArray;
00064   fxStepIterator = fxStepArray->MakeIterator();
00065   fxStepMutex = new TMutex;
00066 }
00067 
00068 TGo4AnalysisStatus::~TGo4AnalysisStatus()
00069 {
00070   TRACE((15,"TGo4AnalysisStatus::~TGo4AnalysisStatus()",__LINE__, __FILE__));
00071   delete fxStepMutex;
00072   delete fxStepIterator;
00073   fxStepArray->Delete();
00074   delete fxStepArray;
00075 }
00076 
00077 Int_t TGo4AnalysisStatus::PrintStatus(Text_t* buffer, Int_t buflen)
00078 {
00079    TRACE((12,"TGo4AnalysisStatus::PrintStatus()",__LINE__, __FILE__));
00080    if(buflen<=0 && buffer!=0)
00081       {
00082          cout << "analysis status print has invalid buflen and nonzero buffer"<< endl;
00083          return 0;
00084       }
00085    Int_t size=0;
00086    Int_t locallen=512000;
00087    Text_t localbuf[512000];
00088    Text_t* current=localbuf;
00089    Int_t restlen=locallen;
00090    current=PrintBuffer(current,restlen, "----------------------------------------------  \n");
00091    current=PrintBuffer(current,restlen, "++++++ Status of %s ++++++\n", GetName());
00092    current=PrintBuffer(current,restlen, "First Analysis Step index: \t%d\n",GetFirstStepIndex());
00093    current=PrintBuffer(current,restlen, "Last Analysis Step index: \t%d\n",GetLastStepIndex());
00094    current=PrintBuffer(current,restlen, "Autosave Interval: \t\t%d s\n",GetAutoSaveInterval());
00095    current=PrintBuffer(current,restlen, "Autosave File: \t\t\t%s \n",GetAutoFileName());
00096    current=PrintBuffer(current,restlen, "Autosave File compression: \t%d \n",GetAutoSaveCompression());
00097    current=PrintBuffer(current,restlen, "Autosave overwrite mode: \t%d \n",IsAutoSaveOverwrite());
00098    current=PrintBuffer(current,restlen, "----------------------------------------------  \n");
00099    TROOT::IncreaseDirLevel();
00100    ResetStepIterator();
00101    TGo4AnalysisStepStatus* step=0;
00102    while((step=NextStepStatus()) != 0)
00103       {
00104            Int_t delta=step->PrintStatus(current,restlen);
00105            restlen-=delta;
00106            current+= delta ;
00107       }
00108    TROOT::DecreaseDirLevel();
00109    current=PrintBuffer(current,restlen, "----------------------------------------------  \n");
00110    if(buffer==0)
00111       {
00112           cout << localbuf << endl;
00113       }
00114    else
00115       {
00116          size=locallen-restlen;
00117          if(size>buflen-1)
00118                size=buflen-1;
00119          strncpy(buffer,localbuf,size);
00120       }
00121    return size;
00122 }
00123 
00124 TGo4AnalysisStepStatus * TGo4AnalysisStatus::GetStepStatus(const Text_t * name)
00125 {
00126 TRACE((11,"TGo4Analysis::GetAnalysisStep(Text_t *)",__LINE__, __FILE__));
00127 if(fxStepArray==0) return 0;
00128    TGo4AnalysisStepStatus* step=0;
00129       {
00130       TGo4LockGuard  listguard(fxStepMutex);
00131          step = dynamic_cast<TGo4AnalysisStepStatus*>( fxStepArray->FindObject(name) );
00132       }
00133    return step;
00134 }
00135 
00136 TGo4AnalysisStepStatus * TGo4AnalysisStatus::NextStepStatus()
00137 {
00138 TRACE((11,"TGo4AnalysisStatus::GetAnalysisStep(Text_t *)",__LINE__, __FILE__));
00139 if(fxStepIterator==0) return 0;
00140    TGo4AnalysisStepStatus* step=0;
00141       {
00142       TGo4LockGuard  listguard(fxStepMutex);
00143          step = dynamic_cast<TGo4AnalysisStepStatus*>( fxStepIterator->Next() );
00144       }
00145    return step;
00146 }
00147 
00148 void TGo4AnalysisStatus::ResetStepIterator()
00149 {
00150    TGo4LockGuard listguard(fxStepMutex);
00151       delete fxStepIterator;
00152       if(fxStepArray)
00153          fxStepIterator=fxStepArray->MakeIterator();
00154       else
00155          fxStepIterator=0;
00156       // fxStepIterator->Reset();
00157 }
00158 
00159 
00160 Bool_t  TGo4AnalysisStatus::AddStepStatus(TGo4AnalysisStepStatus * next)
00161 {
00162 TRACE((14,"TGo4AnalysisStatus::AddAnalysisStep(TGo4AnalysisStep*)",__LINE__, __FILE__));
00163 //
00164 if(fxStepArray==0) return kFALSE;
00165    Bool_t rev=kFALSE;
00166    if(next)
00167       {
00168       TGo4LockGuard  listguard(fxStepMutex);
00169           fxStepArray->AddLast(next);
00170           rev=kTRUE;
00171       } //  if(next) ; TGo4LockGuard
00172    else
00173       {
00174            rev=kFALSE;
00175 //         TGo4Log::Debug(" Analysis: WARNING - did not add zero analysis step pointer to steplist ");
00176       }
00177    return rev;
00178 }
00179 
00180 Int_t TGo4AnalysisStatus::GetNumberOfSteps()
00181 {
00182     return fxStepArray==0 ? 0 : fxStepArray->GetLast()+1;
00183 }
00184 
00185 
00186 TGo4AnalysisStepStatus* TGo4AnalysisStatus::GetStepStatus(Int_t indx)
00187 {
00188    if ((indx<0) || (indx>=GetNumberOfSteps())) return 0;
00189    return dynamic_cast<TGo4AnalysisStepStatus*> (fxStepArray->At(indx));
00190 }
00191 
00192 
00193 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:28 2008 for Go4-v3.04-1 by  doxygen 1.4.2