GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4AnalysisStatus.cxx
Go to the documentation of this file.
1 // $Id: TGo4AnalysisStatus.cxx 2794 2020-05-08 18:46:00Z 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 fuer 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 "TMutex.h"
17 #include "TObjArray.h"
18 
19 #include "TGo4LockGuard.h"
20 #include "TGo4AnalysisStepStatus.h"
21 #include "TGo4Log.h"
22 #include "TROOT.h"
23 
24 
26  TGo4Status("Go4 Default Analysis Status","Go4 Analysis Status Object"),
27  fxStepArray(0),
28  fxStepMutex(0),
29  fxStepIterator(0),
30  fbStepCheckingMode(1),
31  fiFirstStepIndex(0),
32  fiLastStepIndex(0),
33  fiAutoSaveInterval(0),
34  fiAutoSaveCompression(5),
35  fbAutoSaveOverwrite(0),
36  fbAutoSaveOn(1),
37  fxAutoFileName(),
38  fxConfigFileName()
39 {
40  GO4TRACE((15,"TGo4AnalysisStatus::TGo4AnalysisStatus()",__LINE__, __FILE__));
41 }
42 
43 
45  TGo4Status(name,"Go4 Analysis Status Object"),
46  fxStepArray(0),
47  fxStepMutex(0),
48  fxStepIterator(0),
49  fbStepCheckingMode(1),
50  fiFirstStepIndex(0),
51  fiLastStepIndex(0),
52  fiAutoSaveInterval(0),
53  fiAutoSaveCompression(5),
54  fbAutoSaveOverwrite(0),
55  fbAutoSaveOn(1),
56  fxAutoFileName(),
57  fxConfigFileName()
58 {
59  GO4TRACE((15,"TGo4AnalysisStatus::TGo4AnalysisStatus(const char*)",__LINE__, __FILE__));
60  fxStepArray = new TObjArray;
61  fxStepIterator = fxStepArray->MakeIterator();
62  fxStepMutex = new TMutex;
63 }
64 
66 {
67  GO4TRACE((15,"TGo4AnalysisStatus::~TGo4AnalysisStatus()",__LINE__, __FILE__));
68  delete fxStepMutex; fxStepMutex = 0;
69  delete fxStepIterator; fxStepIterator = 0;
70  if (fxStepArray) fxStepArray->Delete();
71  delete fxStepArray; fxStepArray = 0;
72 }
73 
74 Int_t TGo4AnalysisStatus::PrintStatus(Text_t* buffer, Int_t buflen)
75 {
76  GO4TRACE((12,"TGo4AnalysisStatus::PrintStatus()",__LINE__, __FILE__));
77  if(buflen<=0 && buffer!=0)
78  {
79  std::cout << "analysis status print has invalid buflen and nonzero buffer"<< std::endl;
80  return 0;
81  }
82  Int_t size=0;
83  Int_t locallen=512000;
84  Text_t localbuf[512000];
85  Text_t* current=localbuf;
86  Int_t restlen=locallen;
87 
88  current=PrintBuffer(current,restlen, "---------------------------------------------- \n");
89  current=PrintBuffer(current,restlen, "++++++ Status of %s ++++++\n", GetName());
90  current=PrintBuffer(current,restlen, "First Analysis Step index: \t%d\n",GetFirstStepIndex());
91  current=PrintBuffer(current,restlen, "Last Analysis Step index: \t%d\n",GetLastStepIndex());
92  current=PrintBuffer(current,restlen, "Autosave Interval: \t\t%d s\n",GetAutoSaveInterval());
93  current=PrintBuffer(current,restlen, "Autosave File: \t\t%s \n",GetAutoFileName());
94  current=PrintBuffer(current,restlen, "Autosave File compression: \t%d \n",GetAutoSaveCompression());
95  current=PrintBuffer(current,restlen, "Autosave overwrite mode: \t%d \n",IsAutoSaveOverwrite());
96  current=PrintBuffer(current,restlen, "Autosave enabled: \t\t%d \n",IsAutoSaveOn());
97  current=PrintBuffer(current,restlen, "---------------------------------------------- \n");
98  TROOT::IncreaseDirLevel();
100  TGo4AnalysisStepStatus* step=0;
101  while((step=NextStepStatus()) != 0)
102  {
103  Int_t delta=step->PrintStatus(current,restlen);
104  restlen-=delta;
105  current+= delta ;
106  }
107  TROOT::DecreaseDirLevel();
108  current = PrintBuffer(current, restlen, "---------------------------------------------- \n");
109  if (buffer == 0) {
110  std::cout << localbuf << std::endl;
111  } else {
112  size = locallen - restlen;
113  if (size > buflen - 1)
114  size = buflen - 1;
115  strncpy(buffer, localbuf, size);
116  }
117  return size;
118 }
119 
121 {
122  GO4TRACE((11,"TGo4Analysis::GetAnalysisStep(const char*)",__LINE__, __FILE__));
123  if(fxStepArray==0) return 0;
124 
125  TGo4LockGuard listguard(fxStepMutex);
126  return dynamic_cast<TGo4AnalysisStepStatus*>( fxStepArray->FindObject(name) );
127 }
128 
130 {
131  GO4TRACE((11,"TGo4AnalysisStatus::NextStepStatus()",__LINE__, __FILE__));
132  if(fxStepIterator==0) return 0;
133  TGo4LockGuard listguard(fxStepMutex);
134  return dynamic_cast<TGo4AnalysisStepStatus*>( fxStepIterator->Next() );
135 }
136 
138 {
139  TGo4LockGuard listguard(fxStepMutex);
140  delete fxStepIterator;
141  if(fxStepArray)
142  fxStepIterator = fxStepArray->MakeIterator();
143  else
144  fxStepIterator = 0;
145  // fxStepIterator->Reset();
146 }
147 
148 
150 {
151  GO4TRACE((14,"TGo4AnalysisStatus::AddAnalysisStep(TGo4AnalysisStep*)",__LINE__, __FILE__));
152  //
153  if(fxStepArray==0) return kFALSE;
154  Bool_t rev=kFALSE;
155  if(next)
156  {
157  TGo4LockGuard listguard(fxStepMutex);
158  fxStepArray->AddLast(next);
159  rev=kTRUE;
160  } // if(next) ; TGo4LockGuard
161  else
162  {
163  rev=kFALSE;
164  // TGo4Log::Debug(" Analysis: WARNING - did not add zero analysis step pointer to steplist ");
165  }
166  return rev;
167 }
168 
170 {
171  TGo4LockGuard listguard(fxStepMutex);
172  fxStepArray->Delete();
173 }
174 
175 
177 {
178  return fxStepArray==0 ? 0 : fxStepArray->GetLast()+1;
179 }
180 
181 
183 {
184  if ((indx<0) || (indx>=GetNumberOfSteps())) return 0;
185  return dynamic_cast<TGo4AnalysisStepStatus*> (fxStepArray->At(indx));
186 }
187 
188 
189 
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:84
Int_t GetAutoSaveInterval() const
Int_t GetFirstStepIndex() const