Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
History.cc
Go to the documentation of this file.
1 /***************************************************************************
2  History.cc - description
3  -------------------
4  begin : lun set 5 2005
5  copyright : (C) 2005 by Stefano Longo
6  email : Stefano.Longo@lnl.infn.it
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "History.hh"
19 #include "TRandom3.h"
20 #include <fstream>
21 #include "TFile.h"
22 #include "TTimeStamp.h"
23 #include <math.h>
24 
25 CWB::History::History(char** StageNames, int StageNumber, char** TypeNames, int TypeNumber, char* FilePrefix, bool HistoryModify) {
26  int i;
27  TTimeStamp CreationTT;
28 
29  Init();
30  CreationDate_Sec = CreationTT.GetSec();
31  CreationDate_NSec = CreationTT.GetNanoSec();
32 
33  if (StageNames != NULL) {
34  if (DuplicateNames(StageNames, StageNumber)) HistoryException(kBreak, "CWB::History::History", "Duplicate Stage Name");
35  for (i = 0; i < StageNumber; i++) {
36  if (StageNames[i] == NULL) HistoryException(kBreak, "CWB::History::History", "StageNames[%i] is NULL", i);
37  this->StageNames.AddLast(new TObjString(StageNames[i]));
38  }
39  }
40 
41  if (TypeNames != NULL) {
42  if (DuplicateNames(TypeNames, TypeNumber)) HistoryException(kBreak, "CWB::History::History", "Duplicate Type Name");
43  for (i = 0; i < TypeNumber; i++) {
44  if (TypeNames[i] == NULL) HistoryException(kBreak, "CWB::History::History", "TypeNames[%i] is NULL", i);
45  this->TypeNames.AddLast(new TObjString(TypeNames[i]));
46  }
47  }
48 
49  if (FilePrefix != NULL) this->FilePrefix.SetString(FilePrefix);
50  else this->FilePrefix.SetString("");
51 
52  this->HistoryModify = HistoryModify;
53 }
54 
55 CWB::History::History(const History& History) : TObject(History) {
56  int i;
57 
58  for (i = 0; i < History.StageNames.GetSize(); i++) {
59  this->StageNames.AddLast(new TObjString(*static_cast<TObjString*>(History.StageNames.At(i))));
60  }
61  for (i = 0; i < History.TypeNames.GetSize(); i++) {
62  this->TypeNames.AddLast(new TObjString(*static_cast<TObjString*>(History.TypeNames.At(i))));
63  }
64  for (i = 0; i < History.StageList.GetSize(); i++) {
65  this->StageList.AddLast(new HistoryStage(*static_cast<HistoryStage*>(History.StageList.At(i))));
66  }
67 
68  this->FilePrefix.SetString(History.FilePrefix.GetString().Data());
69  this->HistoryModify = History.HistoryModify;
70  this->SortOrder = History.SortOrder;
71  this->AscendingOrder = History.AscendingOrder;
72  this->CreationDate_Sec = History.CreationDate_Sec;
73  this->CreationDate_NSec = History.CreationDate_NSec;
74 }
75 
77  Destroy();
78 }
79 
80 bool
82  for (int i = 0; i < StageNames.GetSize(); i++) {
83  if (strcmp(Name, static_cast<TObjString*>(StageNames.At(i))->GetName()) == 0) return true;
84  }
85  return false;
86 }
87 
88 bool
90  char* StrApp;
91 
92  for (int i = 0; i < StageList.GetSize(); i++) {
93  StrApp = static_cast<HistoryStage*>(StageList.At(i))->GetName();
94  if (strcmp(StrApp, Name) == 0) {
95  //delete StrApp;
96  return true;
97  }
98  //delete StrApp;
99  }
100  return false;
101 }
102 
103 bool
105  return StageAllowed(Name);
106 }
107 
108 bool
110  for (int i = 0; i < TypeNames.GetSize(); i++) {
111  if (strcmp(Name, static_cast<TObjString*>(TypeNames.At(i))->GetName()) == 0) return true;
112  }
113  return false;
114 }
115 
116 void
117 CWB::History::SetStageNames(char** StageNames, int StageNumber) {
118  int i;
119  char* StrApp;
120  HistoryStage* tmpStage;
121 
122  if (StageNames == NULL) HistoryException(kBreak, "CWB::History::SetStageNames", "StageNames is NULL");
123 
124  this->StageNames.Delete();
125 
126  for (i = 0; i < StageNumber; i++) {
127  if (StageNames[i] == NULL) HistoryException(kBreak, "History:SetStageNames", "StageNames[%i] is NULL", i);
128  this->StageNames.AddLast(new TObjString(StageNames[i]));
129  }
130 
131  for (i =0; i < StageList.GetSize(); i++) {
132  //StrApp = static_cast<HistoryStage*>(StageList.At(i))->GetName();
133  tmpStage = static_cast<HistoryStage*>(StageList.At(i));
134  StrApp = tmpStage->GetName();
135  if (!NameAllowed(StrApp)) StageList.Remove(tmpStage);
136  delete StrApp;
137  }
138 }
139 
140 void
141 CWB::History::SetTypeNames(char** TypeNames, int TypeNumber) {
142  int i;
143  /*
144  REMOVED 03/05/2007
145  char* StrApp;
146  HistoryStage* tmpStage;
147  */
148 
149  if (TypeNames == NULL) HistoryException(kBreak, "CWB::History::SetTypeNames", "TypeNames is NULL");
150  this->TypeNames.Delete();
151 
152  for (i = 0; i < TypeNumber; i++) {
153  if (TypeNames[i] == NULL) HistoryException(kBreak, "History:SetTypeNames", "TypeNames[%i] is NULL", i);
154  this->TypeNames.AddLast(new TObjString(TypeNames[i]));
155  }
156 
157 /* WARNING : CHANGING A TYPE ON-THE-FLY ONLY AFFECT NEW HISTORY LINES */
158 /*
159  for (i =0; i < StageList.GetSize(); i++) {
160  tmpStage = static_cast<HistoryStage*>(StageList.At(i));
161  StrApp = tmpStage->GetType();
162  if (!TypeAllowed(StrApp)) StageList.Remove(tmpStage);
163  delete StrApp;
164  }*/
165 
166 }
167 
168 void
169 CWB::History::AddLog(char* Stage, char* Log, TDatime* Time) {
170  HistoryStage* TempStage;
171 
172  if (!StageAllowed(Stage)) HistoryException(kBreak, "CWB::History::AddLog", "Stage not allowed");
173 
174  if (!StageAlreadyPresent(Stage)) {
175  TempStage = new HistoryStage(TypeNames, Stage, NULL, Time);
176  TempStage->SetSortOrder(SortOrder);
177  if (AscendingOrder) TempStage->SetAscendingSortOrder();
178  else TempStage->SetDescendantSortOrder();
179  StageList.AddLast(TempStage);
180  //StageList.AddLast(new HistoryStage(TypeNames, Stage, NULL, Time));
181  }
182 
183  HistoryStage* tmpStage = const_cast<HistoryStage*>(GetStage(Stage));
184  tmpStage->AddLog(Log, Time);
185 }
186 
187 void
188 CWB::History::AddLog(char* Stage, char* Log, int Date, int Time) {
189  HistoryStage* TempStage;
190 
191  if (!StageAllowed(Stage)) HistoryException(kBreak, "CWB::History::AddLog", "Stage not allowed");
192 
193  if (!StageAlreadyPresent(Stage)) {
194  TempStage = new HistoryStage(TypeNames, Stage, NULL, Date, Time);
195  TempStage->SetSortOrder(SortOrder);
196  if (AscendingOrder) TempStage->SetAscendingSortOrder();
197  else TempStage->SetDescendantSortOrder();
198  StageList.AddLast(TempStage);
199  //StageList.AddLast(new HistoryStage(TypeNames, Stage, NULL, Date, Time));
200  }
201 
202  HistoryStage* tmpStage = const_cast<HistoryStage*>(GetStage(Stage));
203  tmpStage->AddLog(Log, Date, Time);
204 }
205 
206 void
207 CWB::History::AddHistory(char* Stage, char* Type, char* History, TDatime* Time) {
208  HistoryStage* TempStage;
209 
210  if (!StageAllowed(Stage)) HistoryException(kBreak, "CWB::History::AddHistory", "Stage not allowed");
211 
212  if (!StageAlreadyPresent(Stage)) {
213  TempStage = new HistoryStage(TypeNames, Stage, NULL, Time);
214  TempStage->SetSortOrder(SortOrder);
215  if (AscendingOrder) TempStage->SetAscendingSortOrder();
216  else TempStage->SetDescendantSortOrder();
217  StageList.AddLast(TempStage);
218  //StageList.AddLast(new HistoryStage(TypeNames, Stage, NULL, Time));
219  }
220 
221  HistoryStage* tmpStage = const_cast<HistoryStage*>(GetStage(Stage));
222  tmpStage->AddHistory(Type, History, NULL, HistoryModify);
223 }
224 
225 void
226 CWB::History::AddHistory(char* Stage, char* Type, char* History, int Date, int Time) {
227  HistoryStage* TempStage;
228 
229  if (!StageAllowed(Stage)) HistoryException(kBreak, "CWB::History::AddHistory", "Stage not allowed");
230 
231  if (!StageAlreadyPresent(Stage)) {
232  TempStage = new HistoryStage(TypeNames, Stage, NULL, Date, Time);
233  TempStage->SetSortOrder(SortOrder);
234  if (AscendingOrder) TempStage->SetAscendingSortOrder();
235  else TempStage->SetDescendantSortOrder();
236  StageList.AddLast(TempStage);
237  //StageList.AddLast(new HistoryStage(TypeNames, Stage, NULL, Date, Time));
238  }
239 
240  HistoryStage* tmpStage = const_cast<HistoryStage*>(GetStage(Stage));
241  tmpStage->AddHistory(Type, History, NULL, HistoryModify);
242 }
243 
244 void
245 CWB::History::SetFilePrefix(char* FilePrefix) {
246  this->FilePrefix.SetString(FilePrefix);
247 }
248 
249 char*
251  return strdup(FilePrefix.GetString().Data());
252 }
253 
254 char*
255 CWB::History::GetHistory(char* StageName, char* Type) {
256  int i;
257  char* StrApp;
258 
259  if (!NameAllowed(StageName)) HistoryException(kBreak, "CWB::History::GetHistory", "Illegal Stage Name");
260  if (!TypeAllowed(Type)) HistoryException(kBreak, "CWB::History::GetHistory", "Illegal Type Name");
261 
262  for (i = 0; i < StageList.GetSize(); i++) {
263  StrApp = static_cast<HistoryStage*>(StageList.At(i))->GetName();
264  if (strcmp(StrApp, StageName) == 0) {
265  delete StrApp;
266  return static_cast<HistoryStage*>(StageList.At(i))->GetHistory(Type);
267  }
268  delete StrApp;
269  }
270  return NULL;
271 }
272 
273 TDatime*
274 CWB::History::GetHistoryDatime(char* StageName, char* Type) {
275  HistoryException(kBreak, "CWB::History::GetHistoryDatime", "Not implemented !!!");
276  return NULL;
277 }
278 
279 int
281  HistoryStage* tmpStage = const_cast<HistoryStage*>(GetStage(Stage));
282  return tmpStage ? tmpStage->GetLogSize() : 0;
283 }
284 
285 char*
286 CWB::History::GetLog(char* Stage, int index) {
287  HistoryStage* tmpStage = const_cast<HistoryStage*>(GetStage(Stage));
288  return tmpStage->GetLogEntry(index);
289 }
290 
291 void
292 CWB::History::Browse(TBrowser *b) {
293  Print();
294 }
295 
296 void
298  /*
299  REMOVED 03/05/2007
300  int i, j, ret;
301  int MaxDate, MaxTime, MaxIndex;
302  char tmpStr[256];
303  char* StrApp1, *StrApp2;
304  TDatime* TimePtr;
305 
306  bool *printDone;
307  */
308 
309  int ret;
310  char tmpStr[256];
311 
312  TRandom3 random;
313  random.SetSeed(0);
314 
315  char cfg_tmp_name[256];
316  sprintf(cfg_tmp_name,"/dev/shm/%f.history.cfg",fabs(random.Uniform()));
317  WriteToFile(cfg_tmp_name);
318 
319  if (getenv("IGEC_HISTORY_VIEWER") != NULL) {
320  sprintf(tmpStr, "%s %s", getenv("IGEC_HISTORY_VIEWER"), cfg_tmp_name);
321  ret = system(tmpStr);
322  if (ret != 0) {
323  sprintf(tmpStr, "vim %s", cfg_tmp_name);
324  system(tmpStr);
325  }
326  }
327  else {
328  sprintf(tmpStr, "vim %s", cfg_tmp_name);
329  system(tmpStr);
330  }
331 
332  sprintf(tmpStr, "rm -f %s", cfg_tmp_name);
333  system(tmpStr);
334 }
335 
336 void
338  /*
339  REMOVED 03/05/2007
340  int i, j, ret;
341  int MaxDate, MaxTime, MaxIndex;
342  char tmpStr[256];
343  char* StrApp1, *StrApp2;
344  TDatime* TimePtr;
345  bool *printDone;
346  */
347 
348  int ret;
349  char tmpStr[256];
350 
351 
352  TRandom3 random;
353  random.SetSeed(0);
354 
355  char cfg_tmp_name[256];
356  sprintf(cfg_tmp_name,"/dev/shm/%f.history.cfg",fabs(random.Uniform()));
357  WriteToFile(cfg_tmp_name, true);
358 
359  if (getenv("IGEC_HISTORY_VIEWER") != NULL) {
360  sprintf(tmpStr, "%s %s", getenv("IGEC_HISTORY_VIEWER"), cfg_tmp_name);
361  ret = system(tmpStr);
362  if (ret != 0) {
363  sprintf(tmpStr, "vim %s", cfg_tmp_name);
364  system(tmpStr);
365  }
366  }
367  else {
368  sprintf(tmpStr, "vim %s", cfg_tmp_name);
369  system(tmpStr);
370  }
371 
372  sprintf(tmpStr, "rm -f %s", cfg_tmp_name);
373  system(tmpStr);
374 }
375 
376 void
378  TDatime now;
379  TString file_name;
380 
381  if (FileName != NULL) file_name = TString(FileName);
382  else file_name = TString(FilePrefix.GetString().Data())+TString(now.AsString())+TString(".cfg");
383 
384  cout << "Dump To File " << file_name.Data() << endl;
385 
386  WriteToFile(const_cast<char*>(file_name.Data()));
387 }
388 
389 void
391  char fname[256];
392  TFile* RootFile;
393 
394  if (FileName != NULL) strcpy(fname, FileName);
395  else {
396  TDatime now;
397  TString file_name = TString(FilePrefix.GetString().Data())+TString(now.AsString())+TString(".root");
398  strcpy(fname, file_name.Data());
399  }
400  cout << "Dump To File " << fname << endl;
401 
402  RootFile = new TFile(fname, "RECREATE");
403  this->Write();
404  RootFile->Close();
405  delete RootFile;
406 }
407 
408 TList*
410  int i;
411  TList *TmpList;
412 
413  TmpList = new TList;
414  for(i = 0; i < StageNames.GetEntries(); i++) {
415  TmpList->AddLast(new TObjString(StageNames.At(i)->GetName()));
416  }
417 
418  return TmpList;
419 }
420 
421 TList*
423  int i;
424  TList *TmpList;
425 
426  TmpList = new TList;
427  for(i = 0; i < TypeNames.GetEntries(); i++) {
428  TmpList->AddLast(new TObjString(TypeNames.At(i)->GetName()));
429  }
430 
431  return TmpList;
432 }
433 
434 bool
436  this->HistoryModify = Modify;
437  return this->HistoryModify;
438 }
439 
440 bool
442  return HistoryModify;
443 }
444 
445 char*
446 CWB::History::AddStage(char* StageName) {
447  if (!HistoryModify)
448  HistoryException(kBreak, "CWB::History::AddStage", "History Modify not allowed");
449 
450  if (NameAllowed(StageName))
451  HistoryException(kBreak, "CWB::History::AddStage", "Stage %s already present", StageName);
452 
453  StageNames.AddLast(new TObjString(StageName));
454 
455  return StageName;
456 }
457 
458 char*
459 CWB::History::RemoveStage(char* StageName) {
460  int i;
461  HistoryStage* tmpStage;
462  char* StrApp;
463  TObjString* TempString;
464 
465  if (!HistoryModify)
466  HistoryException(kBreak, "CWB::History::RemoveStage", "History Modify not allowed");
467 
468  if (!NameAllowed(StageName))
469  HistoryException(kBreak, "CWB::History::RemoveStage", "Stage %s not present", StageName);
470 
471  for (i = 0; i < StageNames.GetSize(); i++) {
472  TempString = static_cast<TObjString*>(StageNames.At(i));
473  if (strcmp(TempString->GetName(), StageName) == 0) StageNames.Remove(TempString);
474  }
475 
476  for (i = 0; i < StageList.GetSize(); i++) {
477  tmpStage = static_cast<HistoryStage*>(StageList.At(i));
478  StrApp = tmpStage->GetName();
479  if (!NameAllowed(StrApp)) StageList.Remove(tmpStage);
480  delete StrApp;
481  }
482 
483  return StageName;
484 }
485 
486 char*
487 CWB::History::AddType(char* TypeName) {
488  if (!HistoryModify)
489  HistoryException(kBreak, "Hsitory::AddType", "History modify not allowed");
490 
491  if (TypeAllowed(TypeName))
492  HistoryException(kBreak, "Hsitory::AddType" , "Type %s already present", TypeName);
493 
494  TypeNames.AddLast(new TObjString(TypeName));
495 
496  for(int i = 0; i < StageList.GetSize(); i++) {
497  static_cast<HistoryStage*>(StageList.At(i))->AddType(TypeName);
498  }
499 
500  return TypeName;
501 }
502 
503 char*
504 CWB::History::RemoveType(char* TypeName) {
505  TObjString* TempString;
506  int i;
507 
508  if (!HistoryModify)
509  HistoryException(kBreak, "Hsitory::RemoveType", "History modify not allowed");
510 
511  if (!TypeAllowed(TypeName))
512  HistoryException(kBreak, "Hsitory::RemoveType" , "Type %s not present", TypeName);
513 
514  for (i = 0; i < TypeNames.GetSize(); i++) {
515  TempString = static_cast<TObjString*>(TypeNames.At(i));
516  if (strcmp(TempString->GetName(), TypeName) == 0) TypeNames.Remove(TempString);
517  }
518 
519  for(i = 0; i < StageList.GetSize(); i++) {
520  static_cast<HistoryStage*>(StageList.At(i))->RemoveType(TypeName);
521  }
522 
523  return TypeName;
524 }
525 
526 char*
527 CWB::History::SetStageComment(char* Stage, char* Comment) {
528  if (!StageAllowed(Stage))
529  HistoryException(kBreak, "CWB::History::SetStageComment", "Stage %s not allowed", Stage);
530 
531  if (!StageAlreadyPresent(Stage))
532  HistoryException(kBreak, "CWB::History::SetStageComment", "Stage %s not present yet", Stage);
533 
534  return const_cast<HistoryStage*>(GetStage(Stage))->SetComment(Comment);
535 }
536 
537 char*
538 CWB::History::SetTypeComment(char* Stage, char* Type, char* Comment) {
539  if (!StageAllowed(Stage))
540  HistoryException(kBreak, "CWB::History::SetTypeComment", "Stage %s not allowed", Stage);
541 
542  if (!StageAlreadyPresent(Stage))
543  HistoryException(kBreak, "CWB::History::SetTypeComment", "Stage %s not present yet", Stage);
544 
545  return const_cast<HistoryStage*>(GetStage(Stage))->SetTypeComment(Type, Comment);
546 }
547 
548 char*
550  if (!StageAllowed(Stage))
551  HistoryException(kBreak, "CWB::History::GetStageComment", "Stage %s not allowed", Stage);
552 
553  if (!StageAlreadyPresent(Stage))
554  HistoryException(kBreak, "CWB::History::GetStageComment", "Stage %s not present", Stage);
555 
556  return const_cast<HistoryStage*>(GetStage(Stage))->GetComment();
557 }
558 
559 char*
560 CWB::History::GetTypeComment(char* Stage, char* Type) {
561  if (!StageAllowed(Stage))
562  HistoryException(kBreak, "CWB::History::GetTypeComment", "Stage %s not allowed", Stage);
563 
564  if (!StageAlreadyPresent(Stage))
565  HistoryException(kBreak, "CWB::History::GetTypeComment", "Stage %s not present", Stage);
566 
567  return const_cast<HistoryStage*>(GetStage(Stage))->GetTypeComment(Type);
568 }
569 
572  int i;
573 
574  this->SortOrder = SortOrder;
575  for (i = 0; i < StageList.GetSize(); i++) {
576  static_cast<HistoryStage*>(StageList.At(i))->SetSortOrder(SortOrder);
577  }
578  return this->SortOrder;
579 }
580 
583  return this->SortOrder;
584 }
585 
586 bool
588  if (SortOrder == InsertionOrder) return true;
589  else return false;
590 }
591 
592 bool
594  if (SortOrder == ElementDate) return true;
595  else return false;
596 }
597 
598 bool
600  if (SortOrder == Alphabetical) return true;
601  else return false;
602 }
603 
604 bool
606  int i;
607 
608  AscendingOrder = true;
609  for (i = 0; i < StageList.GetSize(); i++) {
610  static_cast<HistoryStage*>(StageList.At(i))->SetAscendingSortOrder();
611  }
612  return AscendingOrder;
613 }
614 
615 bool
617  int i;
618 
619  AscendingOrder = false;
620  for (i = 0; i < StageList.GetSize(); i++) {
621  static_cast<HistoryStage*>(StageList.At(i))->SetDescendantSortOrder();
622  }
623  return AscendingOrder;
624 }
625 
626 bool
628  return AscendingOrder;
629 }
630 
631 bool
633  return !AscendingOrder;
634 }
635 
636 void
638  int i;
639 
640  StageList.Sort(AscendingOrder);
641  for (i = 0; i < StageList.GetSize(); i++) {
642  static_cast<HistoryStage*>(StageList.At(i))->Sort();
643  }
644 }
645 
646 TTimeStamp
648  TTimeStamp CreationTT(CreationDate_Sec, CreationDate_NSec);
649 
650  return CreationTT;
651 }
652 
653 TTimeStamp
655  if (!StageAllowed(Stage))
656  HistoryException(kBreak, "CWB::History::GetCreationDate", "Stage %s not allowed", Stage);
657 
658  if (!StageAlreadyPresent(Stage))
659  HistoryException(kBreak, "CWB::History::GetCreationDate", "Stage %s not present yet", Stage);
660 
661  return const_cast<HistoryStage*>(GetStage(Stage))->GetCreationTimeStamp();
662 }
663 
664 void
666  HistoryModify = false;
667  SortOrder = DEFAULT_SORT_ORDER;
668  AscendingOrder = DEFAULT_ASCENDING;
669 }
670 
671 void
673 }
674 
675 const CWB::HistoryStage*
677  int i;
678  char* StrApp;
679 
680  for (i = 0; i < StageList.GetSize(); i++) {
681  HistoryStage* tmpStage = static_cast<HistoryStage*>(StageList.At(i));
682  StrApp = tmpStage->GetName();
683  if (strcmp(StrApp, Name) == 0) {
684  delete StrApp;
685  return tmpStage;
686  }
687  delete StrApp;
688  }
689  return NULL;
690 }
691 
692 bool
693 CWB::History::DuplicateNames(char** NameList, int NameNumber) {
694  int i, j;
695 
696  for (i = 0; i < NameNumber; i++) {
697  for (j = i + 1; j < NameNumber; j++) {
698  if (strcmp(NameList[i], NameList[j]) == 0) return true;
699  }
700  }
701  return false;
702 }
703 
704 void
705 CWB::History::WriteToFile(char* FileName, bool SummaryOnly) {
706  char *StrApp1, *StrApp2, tmpStr[256];
707  int i, j, length;
708  TDatime* TimePtr;
709 
710  ofstream OutFile(FileName, ios::out);
711 
712  if (OutFile.fail()) HistoryException(kBreak, "CWB::History::WriteToFile", "Error opening output file");
713 
714  Sort();
715 
716  for (i = 0; i < StageList.GetSize(); i++) {
717  TDatime tmpTime(static_cast<HistoryStage*>(StageList.At(i))->GetDate(),
718  static_cast<HistoryStage*>(StageList.At(i))->GetTime());
719 
720  StrApp1 = static_cast<HistoryStage*>(StageList.At(i))->GetName();
721  memset(tmpStr, '*', HEADER_WIDTH);
722  tmpStr[HEADER_WIDTH] = 0;
723  length = strlen(StrApp1);
724  tmpStr[(HEADER_WIDTH - length) / 2 - 1] = ' ';
725  for (j = 0; j < length; j++) tmpStr[(HEADER_WIDTH - length) / 2 + j] = StrApp1[j];
726  tmpStr[(HEADER_WIDTH + length) / 2] = ' ';
727  /*
728  sprintf(tmpStr, "Stage Name: %s - Date: %i/%i/%i - Time: %i:%i:%i\n", StrApp1, tmpTime.GetDay(), tmpTime.GetMonth(),
729  tmpTime.GetYear(), tmpTime.GetHour(), tmpTime.GetMinute(), tmpTime.GetSecond());
730  */
731  OutFile << tmpStr << endl;
732  delete StrApp1;
733  StrApp1 = static_cast<HistoryStage*>(StageList.At(i))->GetComment();
734  //if (StrApp1 != NULL) {
735  if (strlen(StrApp1) > 0) {
736  OutFile << StrApp1 << endl;
737  delete StrApp1;
738  }
739  else {
740  sprintf(tmpStr, "Date: %i/%i/%i - Time: %i:%i:%i", tmpTime.GetDay(), tmpTime.GetMonth(),
741  tmpTime.GetYear(), tmpTime.GetHour(), tmpTime.GetMinute(), tmpTime.GetSecond());
742  OutFile << tmpStr << endl;
743  }
744  memset(tmpStr, '*', HEADER_WIDTH);
745  tmpStr[HEADER_WIDTH + 1] = 0;
746  OutFile << tmpStr << endl;
747 
748  if (!SummaryOnly) {
749  if (static_cast<HistoryStage*>(StageList.At(i))->GetHistorySize() > 0) {
750  sprintf(tmpStr, "Stage's History:");
751  OutFile << tmpStr << endl;
752 
753  for (j = 0; j < static_cast<HistoryStage*>(StageList.At(i))->GetHistorySize(); j++) {
754  StrApp2 = static_cast<HistoryStage*>(StageList.At(i))->GetHistoryEntryType(j);
755  OutFile << StrApp2 << ": " << endl;
756  delete StrApp2;
757  StrApp2 = static_cast<HistoryStage*>(StageList.At(i))->GetHistoryEntry(j);
758  OutFile << StrApp2 << endl;
759  delete StrApp2;
760  }
761  }
762 
763  if (static_cast<HistoryStage*>(StageList.At(i))->GetLogSize() > 0) {
764  sprintf(tmpStr, "Stage's Logs:");
765  OutFile << tmpStr << endl;
766 
767  static_cast<HistoryStage*>(StageList.At(i))->SortLogs();
768  for (j = 0; j < static_cast<HistoryStage*>(StageList.At(i))->GetLogSize(); j++) {
769  TimePtr = static_cast<HistoryStage*>(StageList.At(i))->GetLogEntryDatime(j);
770  OutFile << TimePtr->GetDay() << "/" << TimePtr->GetMonth() << "/" << TimePtr->GetYear() << " - ";
771  OutFile << TimePtr->GetHour() << ":" << TimePtr->GetMinute() << ":" << TimePtr->GetSecond() << " ";
772  delete TimePtr;
773  StrApp2 = static_cast<HistoryStage*>(StageList.At(i))->GetLogEntry(j);
774  OutFile << StrApp2 << endl;
775  delete StrApp2;
776  }
777  }
778  }
779  }
780  OutFile << endl << endl;
781  OutFile.close();
782 }
783 
784 int
786  char* StrApp;
787  int Position = -1;
788 
789  for (int i = 0; i < StageList.GetSize(); i++) {
790  StrApp = static_cast<HistoryStage*>(StageList.At(i))->GetName();
791  if (strcmp(StrApp, Name) == 0) {
792  Position = i;
793  }
794  }
795  return Position;
796 }
797 
798 void CWB::History::Streamer(TBuffer &R__b)
799 {
800  // Stream an object of class History.
801  TDatime CreationDatime;
802  TTimeStamp CreationTT;
803 
804  UInt_t R__s, R__c;
805  if (R__b.IsReading()) {
806  Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
807  TObject::Streamer(R__b);
808  StageNames.Streamer(R__b);
809  TypeNames.Streamer(R__b);
810  StageList.Streamer(R__b);
811  FilePrefix.Streamer(R__b);
812  if (R__v > 1) {
813  R__b >> HistoryModify;
814  R__b >> (Int_t&)SortOrder;
815  R__b >> AscendingOrder;
816  if (R__v == 1) {
817  CreationDatime.Streamer(R__b);
818  CreationTT.Set(CreationDatime.GetYear(), CreationDatime.GetMonth(), CreationDatime.GetDay(), CreationDatime.GetHour(), CreationDatime.GetMinute(), CreationDatime.GetSecond(), 0, true, 0);
819  CreationDate_Sec = CreationTT.GetSec();
820  CreationDate_NSec = CreationTT.GetNanoSec();
821  }
822  else {
823  R__b >> CreationDate_Sec;
824  R__b >> CreationDate_NSec;
825  R__b.CheckByteCount(R__s, R__c, CWB::History::IsA());
826  }
827  }
828  else {
829  HistoryModify = false;
830  SortOrder = DEFAULT_SORT_ORDER;
831  AscendingOrder = DEFAULT_ASCENDING;
832  CreationDate_Sec = CreationTT.GetSec();
833  CreationDate_NSec = CreationTT.GetNanoSec();
834  }
835  } else {
836  R__c = R__b.WriteVersion(CWB::History::IsA(), kTRUE);
837  TObject::Streamer(R__b);
838  StageNames.Streamer(R__b);
839  TypeNames.Streamer(R__b);
840  StageList.Streamer(R__b);
841  FilePrefix.Streamer(R__b);
842  R__b << HistoryModify;
843  R__b << (Int_t)SortOrder;
844  R__b << AscendingOrder;
845  R__b << CreationDate_Sec;
846  R__b << CreationDate_NSec;
847  R__b.SetByteCount(R__c, kTRUE);
848  }
849 }
850 
851 void
852 CWB::History::HistoryException(int type, const char *location, const char *msgfmt, ...) {
853  cout << location << " " << msgfmt << endl;
854  exit(1);
855 }
856 
bool IsSortOrderAlphabetical()
Definition: History.cc:599
bool IsSortOrderInsertion()
Definition: History.cc:587
void DumpToROOTFile(char *FileName=NULL)
Definition: History.cc:390
char * RemoveStage(char *StageName)
Definition: History.cc:459
bool SetDescendantSortOrder()
#define DEFAULT_SORT_ORDER
bool IsSortOrderDate()
Definition: History.cc:593
bool HistoryModify
Definition: History.hh:127
bool DuplicateNames(char **NameList, int NameNumber)
Definition: History.cc:693
bool GetDescendantSortOrder()
Definition: History.cc:632
long CreationDate_Sec
Definition: History.hh:131
SortOrderType
bool SetDescendantSortOrder()
Definition: History.cc:616
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
TString("c")
bool TypeAllowed(char *Name)
Definition: History.cc:109
TDatime * GetHistoryDatime(char *StageName, char *Type)
Definition: History.cc:274
void HistoryException(int type, const char *location, const char *msgfmt,...)
Definition: History.cc:852
SortOrderType SetSortOrder(SortOrderType SortOrder)
bool GetHistoryModify()
Definition: History.cc:441
SortOrderType SortOrder
Definition: History.hh:128
void Destroy()
Definition: History.cc:672
long CreationDate_NSec
Definition: History.hh:132
char * RemoveType(char *TypeName)
Definition: History.cc:504
int j
Definition: cwb_net.C:10
i drho i
void SetStageNames(char **StageNames, int StageNumber)
Definition: History.cc:117
ofstream out
Definition: cwb_merge.C:196
#define HEADER_WIDTH
Definition: History.hh:31
tlive_fix Write()
MDC Print()
char * GetStageComment(char *Stage)
Definition: History.cc:549
void Print()
Definition: History.cc:297
virtual void Browse(TBrowser *b)
Definition: History.cc:292
char * GetFilePrefix()
Definition: History.cc:250
char * GetLog(char *Stage, int index)
Definition: History.cc:286
int GetLogSize(char *Stage)
Definition: History.cc:280
void AddLog(char *LogMsg, TDatime *Time=NULL)
char fname[1024]
TList * GetStageNames()
Definition: History.cc:409
char * SetStageComment(char *Stage, char *Comment=NULL)
Definition: History.cc:527
bool StageAlreadyPresent(char *Name)
Definition: History.cc:89
bool GetAscendingSortOrder()
Definition: History.cc:627
TList * GetTypeNames()
Definition: History.cc:422
TList StageNames
Definition: History.hh:121
bool SetHistoryModify(bool Replace=true)
Definition: History.cc:435
bool SetAscendingSortOrder()
bool AscendingOrder
Definition: History.hh:129
char * SetTypeComment(char *Stage, char *Type, char *Comment=NULL)
Definition: History.cc:538
TObjString FilePrefix
Definition: History.hh:125
wavearray< int > index
double fabs(const Complex &x)
Definition: numpy.cc:37
int GetStagePosition(char *Name)
Definition: History.cc:785
bool StageAllowed(char *Name)
Definition: History.cc:81
void AddHistory(char *Type, char *History, char *Comment=NULL, bool Replace=false)
void AddLog(char *Stage, char *Log, TDatime *Time=NULL)
Definition: History.cc:169
bool NameAllowed(char *Name)
Definition: History.cc:104
strcpy(RunLabel, RUN_LABEL)
bool SetAscendingSortOrder()
Definition: History.cc:605
#define DEFAULT_ASCENDING
History(char **StageNames=NULL, int StageNumber=0, char **TypeNames=NULL, int TypeNumber=0, char *FilePrefix=NULL, bool HistoryModify=false)
Definition: History.cc:25
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void SetTypeNames(char **TypeNames, int TypeNumber)
Definition: History.cc:141
char * AddType(char *TypeName)
Definition: History.cc:487
void DumpToTextFile(char *FileName=NULL)
Definition: History.cc:377
char * GetLogEntry(int index)
SortOrderType GetSortOrder()
Definition: History.cc:582
SortOrderType SetSortOrder(SortOrderType SortOrder)
Definition: History.cc:571
char * GetTypeComment(char *Stage, char *Type)
Definition: History.cc:560
void SetFilePrefix(char *FilePrefix)
Definition: History.cc:245
char * GetHistory(char *StageName, char *Type)
Definition: History.cc:255
const CWB::HistoryStage * GetStage(char *Name)
Definition: History.cc:676
void PrintSummary()
Definition: History.cc:337
void WriteToFile(char *FileName, bool SummaryOnly=false)
Definition: History.cc:705
TTimeStamp GetCreationTimeStamp()
Definition: History.cc:647
TList TypeNames
Definition: History.hh:122
double length
Definition: TestBandPass.C:18
Type
Definition: FrDisplay.cc:105
void Init()
Definition: History.cc:665
void AddHistory(char *Stage, char *Type, char *History, TDatime *Time=NULL)
Definition: History.cc:207
void Sort()
Definition: History.cc:637
char * AddStage(char *StageName)
Definition: History.cc:446
exit(0)
TList StageList
Definition: History.hh:124