Logo coherent WaveBurst  
Library Reference Guide
Logo
HistoryParamFileTest.C
Go to the documentation of this file.
1 //
2 // Test History Class
3 // Author : Gabriele Vedovato
4 
5 {
6 
7  #define IFILE_NAME "parameters_nslag.C"
8 
9 
10  ifstream in;
11  in.open(IFILE_NAME,ios::in);
12  if (!in.good()) {cout << "Error Opening File : " << IFILE_NAME << endl;exit(1);}
13 
14  char historyBuffer[10000000];
15 
16  char istringa[8192];
17  int historyLength = 0;
19  while (1) {
20  in.getline(istringa,8192);
21  if (!in.good()) break;
22  cout << istringa << endl;
23  int len = strlen(istringa);
24  istringa[len]=0x0a;
25  strncpy(historyBuffer+historyLength,istringa,len+1);
26  historyLength += len+1;
27  }
28  istringa[historyLength]=0x0;
29 
30 //cout << historyBuffer << endl;
31 
32 /* Al costruttore vanno passati nome e numero degli stages e dei tipi ammessi per ognuno dei precedenti.
33  L'elenco degli stage e dei tipi attualmente deve essere un vettore di stringhe
34 */
35 
36 char* Stages[3];
37 Stages[0] = new char[256];
38 Stages[1] = new char[256];
39 Stages[2] = new char[256];
40 strcpy(Stages[0], "PRODUCTION");
41 strcpy(Stages[1], "SIMULATION");
42 strcpy(Stages[2], "POST_PRODUCTION");
43 
44 char* Types[2];
45 Types[0] = new char[256];
46 Types[1] = new char[256];
47 strcpy(Types[0], "ROOTLOGON");
48 strcpy(Types[1], "PARAMETERS");
49 
50 CWB::History HistoryTest(Stages, 2, Types, 2);
51 
52 /* Al solito sono presenti una schiera di metodi per verificare se uno Stage/Tipo e' ammesso
53  (StageAllowed(char* Name)/TypeAllowed(char* Name)), se e' gia' presente (StageAlreadyPresent(char* Name)), etc
54  A titolo di esempio:
55 */
56 /*
57 cout << HistoryTest.StageAllowed("FME 1") << endl;
58 cout << HistoryTest.StageAllowed("FME 3") << endl;
59 cout << HistoryTest.StageAlreadyPresent("FME 1") << endl;
60 cout << HistoryTest.StageAlreadyPresent("FME 3") << endl;
61 */
62 /* L'aggiunta di informazioni di Log avviene mediante il metodo
63  void AddLog(char* Stage, char* Log, TDatime* Time = NULL)
64  oppure
65  void AddLog(char* Stage, char* Log, TDatime* Time = NULL)
66  In cui deve essere indicato lo stage di appartenenza e il testo del Log.
67  Il log viene annotato con la data specificata, altrimenti con l'ora di sistema corrispondente all'inserimento
68 */
69 
70 /*
71 HistoryTest.AddLog("FME 1", "LOG1");
72 HistoryTest.AddLog("FME 1", "LOG2");
73 HistoryTest.AddLog("FME 2", "LOG3");
74 */
75 /*
76  L'inserimento di voci dell'History avviene mediante il metodo
77  void AddHistory(char* Stage, char* Type, char* History, TDatime* Time = NULL)
78  oppure
79  void AddHistory(char* Stage, char* Type, char* History, int Date, int Time)
80  con le stesse modalita' del Log
81 */
82 
83 HistoryTest.AddHistory((char*)"PRODUCTION", (char*)"PARAMETERS", historyBuffer);
84 HistoryTest.AddLog((char*)"PRODUCTION", (char*)"LOG1");
85 
86 /*
87  Per visualizzare l'History e' possibile chiamare il metodo Print (utilizzato anche Browse),
88 */
89 
91 
92 /*
93  Altrimenti e' possibile richiamare le singole voci appartenentu ad uno stage/tipo con il metodo GetHistory.
94  Richiamato con la stringa rappresentante lo stage e il tipo, questo ritornera' una copia
95  della stringa corrispondente all'History oppure, se la voce non e' presente, NULL.
96  Ad esempio:
97 */
98 
99 //cout << HistoryTest.GetHistory("FME 2", "Tipo 1") << endl;
100 
101  TFile *froot = new TFile("FileHist.root", "RECREATE");
102  HistoryTest.Write();
103  froot->Close();
104  exit(0);
105 }
TString live
int historyLength
TString("c")
CWB::History HistoryTest(Stages, 2, Types, 2)
exit(0)
TFile * froot
void Print()
Definition: History.cc:315
#define IFILE_NAME
char * Stages[3]
strcpy(Stages[0], "PRODUCTION")
ifstream in
char istringa[8192]
char * Types[2]
void AddLog(char *Stage, char *Log, TDatime *Time=NULL)
Definition: History.cc:187
char historyBuffer[10000000]
void AddHistory(char *Stage, char *Type, char *History, TDatime *Time=NULL)
Definition: History.cc:225