GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4AnalysisStatus.cxx
Go to the documentation of this file.
1 // $Id: TGo4AnalysisStatus.cxx 1423 2015-03-25 13:45:17Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4AnalysisStatus.h"
15 
16 #include "Riostream.h"
17 
18 #include "TMutex.h"
19 #include "TObjArray.h"
20 #include "TROOT.h"
21 #include "TUrl.h"
22 
23 #include "TGo4LockGuard.h"
24 #include "TGo4Log.h"
25 #include "TGo4AnalysisStepStatus.h"
26 
27 #include "TGo4Analysis.h"
28 
29 
31  TGo4Status("Go4 Default Analysis Status","Go4 Analysis Status Object"),
32  fxStepArray(0),
33  fxStepMutex(0),
34  fxStepIterator(0),
35  fbStepCheckingMode(1),
36  fiFirstStepIndex(0),
37  fiLastStepIndex(0),
38  fiAutoSaveInterval(0),
39  fiAutoSaveCompression(5),
40  fbAutoSaveOverwrite(0),
41  fbAutoSaveOn(1),
42  fxAutoFileName(),
43  fxConfigFileName()
44 {
45  GO4TRACE((15,"TGo4AnalysisStatus::TGo4AnalysisStatus()",__LINE__, __FILE__));
46 }
47 
48 
50  TGo4Status(name,"Go4 Analysis Status Object"),
51  fxStepArray(0),
52  fxStepMutex(0),
53  fxStepIterator(0),
54  fbStepCheckingMode(1),
55  fiFirstStepIndex(0),
56  fiLastStepIndex(0),
57  fiAutoSaveInterval(0),
58  fiAutoSaveCompression(5),
59  fbAutoSaveOverwrite(0),
60  fbAutoSaveOn(1),
61  fxAutoFileName(),
62  fxConfigFileName()
63 {
64  GO4TRACE((15,"TGo4AnalysisStatus::TGo4AnalysisStatus(const char*)",__LINE__, __FILE__));
65  fxStepArray = new TObjArray;
66  fxStepIterator = fxStepArray->MakeIterator();
67  fxStepMutex = new TMutex;
68 }
69 
71 {
72  GO4TRACE((15,"TGo4AnalysisStatus::~TGo4AnalysisStatus()",__LINE__, __FILE__));
73  delete fxStepMutex; fxStepMutex = 0;
74  delete fxStepIterator; fxStepIterator = 0;
75  if (fxStepArray) fxStepArray->Delete();
76  delete fxStepArray; fxStepArray = 0;
77 }
78 
79 Int_t TGo4AnalysisStatus::PrintStatus(Text_t* buffer, Int_t buflen)
80 {
81  GO4TRACE((12,"TGo4AnalysisStatus::PrintStatus()",__LINE__, __FILE__));
82  if(buflen<=0 && buffer!=0)
83  {
84  std::cout << "analysis status print has invalid buflen and nonzero buffer"<< std::endl;
85  return 0;
86  }
87  Int_t size=0;
88  Int_t locallen=512000;
89  Text_t localbuf[512000];
90  Text_t* current=localbuf;
91  Int_t restlen=locallen;
92 
93  current=PrintBuffer(current,restlen, "---------------------------------------------- \n");
94  current=PrintBuffer(current,restlen, "++++++ Status of %s ++++++\n", GetName());
95  current=PrintBuffer(current,restlen, "First Analysis Step index: \t%d\n",GetFirstStepIndex());
96  current=PrintBuffer(current,restlen, "Last Analysis Step index: \t%d\n",GetLastStepIndex());
97  current=PrintBuffer(current,restlen, "Autosave Interval: \t\t%d s\n",GetAutoSaveInterval());
98  current=PrintBuffer(current,restlen, "Autosave File: \t\t%s \n",GetAutoFileName());
99  current=PrintBuffer(current,restlen, "Autosave File compression: \t%d \n",GetAutoSaveCompression());
100  current=PrintBuffer(current,restlen, "Autosave overwrite mode: \t%d \n",IsAutoSaveOverwrite());
101  current=PrintBuffer(current,restlen, "Autosave enabled: \t\t%d \n",IsAutoSaveOn());
102  current=PrintBuffer(current,restlen, "---------------------------------------------- \n");
103  TROOT::IncreaseDirLevel();
105  TGo4AnalysisStepStatus* step=0;
106  while((step=NextStepStatus()) != 0)
107  {
108  Int_t delta=step->PrintStatus(current,restlen);
109  restlen-=delta;
110  current+= delta ;
111  }
112  TROOT::DecreaseDirLevel();
113  current=PrintBuffer(current,restlen, "---------------------------------------------- \n");
114  if(buffer==0)
115  {
116  std::cout << localbuf << std::endl;
117  }
118  else
119  {
120  size=locallen-restlen;
121  if(size>buflen-1)
122  size=buflen-1;
123  strncpy(buffer,localbuf,size);
124  }
125  return size;
126 }
127 
129 {
130  GO4TRACE((11,"TGo4Analysis::GetAnalysisStep(const char*)",__LINE__, __FILE__));
131  if(fxStepArray==0) return 0;
132 
133  TGo4LockGuard listguard(fxStepMutex);
134  return dynamic_cast<TGo4AnalysisStepStatus*>( fxStepArray->FindObject(name) );
135 }
136 
138 {
139  GO4TRACE((11,"TGo4AnalysisStatus::NextStepStatus()",__LINE__, __FILE__));
140  if(fxStepIterator==0) return 0;
141  TGo4LockGuard listguard(fxStepMutex);
142  return dynamic_cast<TGo4AnalysisStepStatus*>( fxStepIterator->Next() );
143 }
144 
146 {
147  TGo4LockGuard listguard(fxStepMutex);
148  delete fxStepIterator;
149  if(fxStepArray)
150  fxStepIterator = fxStepArray->MakeIterator();
151  else
152  fxStepIterator = 0;
153  // fxStepIterator->Reset();
154 }
155 
156 
158 {
159  GO4TRACE((14,"TGo4AnalysisStatus::AddAnalysisStep(TGo4AnalysisStep*)",__LINE__, __FILE__));
160  //
161  if(fxStepArray==0) return kFALSE;
162  Bool_t rev=kFALSE;
163  if(next)
164  {
165  TGo4LockGuard listguard(fxStepMutex);
166  fxStepArray->AddLast(next);
167  rev=kTRUE;
168  } // if(next) ; TGo4LockGuard
169  else
170  {
171  rev=kFALSE;
172  // TGo4Log::Debug(" Analysis: WARNING - did not add zero analysis step pointer to steplist ");
173  }
174  return rev;
175 }
176 
178 {
179  TGo4LockGuard listguard(fxStepMutex);
180  fxStepArray->Delete();
181 }
182 
183 
185 {
186  return fxStepArray==0 ? 0 : fxStepArray->GetLast()+1;
187 }
188 
189 
191 {
192  if ((indx<0) || (indx>=GetNumberOfSteps())) return 0;
193  return dynamic_cast<TGo4AnalysisStepStatus*> (fxStepArray->At(indx));
194 }
195 
196 
197 
Int_t GetAutoSaveCompression() const
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
TGo4AnalysisStepStatus * NextStepStatus()
const char * GetAutoFileName() const
Int_t IsAutoSaveOverwrite() const
Bool_t AddStepStatus(TGo4AnalysisStepStatus *next)
Int_t IsAutoSaveOn() const
Int_t GetLastStepIndex() const
TGo4AnalysisStepStatus * GetStepStatus(const char *name)
#define GO4TRACE(X)
Definition: TGo4Log.h:26
static Text_t * PrintBuffer(char *buffer, Int_t &buflen, const char *text,...)
Definition: TGo4Status.cxx:85
Int_t GetAutoSaveInterval() const
Int_t GetFirstStepIndex() const