Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HistoryLogLine.cc
Go to the documentation of this file.
1 /***************************************************************************
2  HistoryLogLine.cpp - description
3  -------------------
4  begin : ven set 2 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 "HistoryLogLine.hh"
19 
20 CWB::HistoryLogLine::HistoryLogLine(char* LogStr, TDatime* Time) {
21  TTimeStamp CreationTT;
22 
23  Init();
24  CreationDate_Sec = CreationTT.GetSec();
25  CreationDate_NSec = CreationTT.GetNanoSec();
26  if (Time != NULL) {
27  this->Date = Time->GetDate();
28  this->Time = Time->GetTime();
29  }
30  else {
31  TDatime tmpTime;
32  this->Date = tmpTime.GetDate();
33  this->Time = tmpTime.GetTime();
34  }
35 
36  if (LogStr != NULL) {
37  LogLength = strlen(LogStr) + 1;
38  Log = new char[LogLength];
39  strcpy(Log, LogStr);
40  }
41  else {
42  LogLength = 1;
43  Log = new char[1];
44  Log[0] = 0;
45  }
46 }
47 
48 CWB::HistoryLogLine::HistoryLogLine(char* LogStr, int Date, int Time) {
49  TTimeStamp CreationTT;
50 
51  Init();
52  CreationDate_Sec = CreationTT.GetSec();
53  CreationDate_NSec = CreationTT.GetNanoSec();
54  this->Date = Date;
55  this->Time = Time;
56  if (LogStr != NULL) {
57  LogLength = strlen(LogStr) + 1;
58  Log = new char[LogLength];
59  strcpy(Log, LogStr);
60  }
61  else {
62  LogLength = 1;
63  Log = new char[1];
64  Log[0] = 0;
65  }
66 }
67 
68 CWB::HistoryLogLine::HistoryLogLine(const HistoryLogLine& LogLine) : TObject(LogLine) {
69  this->Date = LogLine.Date;
70  this->Time = LogLine.Time;
71  this->LogLength = LogLine.LogLength;
72  this->Log = strdup(LogLine.Log);
73  this->SortOrder = LogLine.SortOrder;
74  this->AscendingOrder = LogLine.AscendingOrder;
75  this->CreationDate_Sec = LogLine.CreationDate_Sec;
76  this->CreationDate_NSec = LogLine.CreationDate_NSec;
77 }
78 
80  Destroy();
81 }
82 
83 void
84 CWB::HistoryLogLine::SetLog(char* LogStr, TDatime* Time) {
85  delete Log;
86 
87  this->Date = Time->GetDate();
88  this->Time = Time->GetTime();
89  if (LogStr != NULL) {
90  LogLength = strlen(LogStr) + 1;
91  Log = new char[LogLength];
92  strcpy(Log, LogStr);
93  }
94  else {
95  LogLength = 1;
96  Log = new char[1];
97  Log[0] = 0;
98  }
99 }
100 
101 void
102 CWB::HistoryLogLine::SetLog(char* LogStr, int Date, int Time) {
103  delete Log;
104 
105  this->Date = Date;
106  this->Time = Time;
107  if (LogStr != NULL) {
108  LogLength = strlen(LogStr) + 1;
109  Log = new char[LogLength];
110  strcpy(Log, LogStr);
111  }
112  else {
113  LogLength = 1;
114  Log = new char[1];
115  Log[0] = 0;
116  }
117 }
118 
119 void
120 CWB::HistoryLogLine::SetLogTime(int Date, int Time) {
121  this->Date = Date;
122  this->Time = Time;
123 }
124 
125 void
127  this->Date = Time->GetDate();
128  this->Time = Time->GetTime();
129 }
130 
131 char*
133  delete this->Log;
134 
135  if (Log != NULL) {
136  LogLength = strlen(Log) + 1;
137  this->Log = new char[LogLength] + 1;
138  strcpy(this->Log, Log);
139  }
140  else {
141  LogLength = 1;
142  Log = new char[1];
143  Log[0] = 0;
144  }
145 
146  return Log;
147 }
148 
149 char*
151  return strdup(Log);
152 }
153 
154 int
156  return Date;
157 }
158 
159 int
161  return Time;
162 }
163 
164 TDatime*
166  return new TDatime(Date, Time);
167 }
168 
169 void
171  Print();
172 }
173 
174 void
176  TDatime tmpTime(Date, Time);
177  cout << "Log Time: " << tmpTime.GetDay() << "/" << tmpTime.GetMonth() << "/" << tmpTime.GetYear() << " - ";
178  cout << tmpTime.GetHour() << ":" << tmpTime.GetMinute() << ":" << tmpTime.GetSecond() << endl;
179  cout << Log << endl;
180 }
181 
182 bool
184  return true;
185 }
186 
187 int
188 CWB::HistoryLogLine::Compare(const TObject* Obj) const {
189  int Result;
190 
191  if (this->Date < static_cast<HistoryLogLine*>(const_cast<TObject*>(Obj))->Date) Result = -1;
192  else if (this->Date > static_cast<HistoryLogLine*>(const_cast<TObject*>(Obj))->Date) Result = 1;
193  else {
194  if (this->Time < static_cast<HistoryLogLine*>(const_cast<TObject*>(Obj))->Time) Result = -1;
195  else if (this->Time > static_cast<HistoryLogLine*>(const_cast<TObject*>(Obj))->Time) Result = 1;
196  else Result = strcmp(this->Log, static_cast<HistoryLogLine*>(const_cast<TObject*>(Obj))->Log);
197  }
198 
199  return Result;
200 }
201 
204  this->SortOrder = SortOrder;
205  return this->SortOrder;
206 }
207 
210  return SortOrder;
211 }
212 
213 bool
215  if (SortOrder == InsertionOrder) return true;
216  else return false;
217 }
218 
219 bool
221  if (SortOrder == ElementDate) return true;
222  else return false;
223 }
224 
225 bool
227  if (SortOrder == Alphabetical) return true;
228  else return false;
229 }
230 
231 bool
233  AscendingOrder = true;
234  return AscendingOrder;
235 }
236 
237 bool
239  AscendingOrder = false;
240  return AscendingOrder;
241 }
242 
243 bool
245  return AscendingOrder;
246 }
247 
248 bool
250  return !AscendingOrder;
251 }
252 
253 TTimeStamp
255  TTimeStamp CreationTT(CreationDate_Sec, CreationDate_NSec);
256  return CreationTT;
257 }
258 
259 void
261  LogLength = 0;
262  Log = NULL;
263  SortOrder = DEFAULT_SORT_ORDER;
264  AscendingOrder = DEFAULT_ASCENDING;
265 }
266 
267 void
269  if (Log != NULL) delete Log;
270 }
271 
272 void CWB::HistoryLogLine::Streamer(TBuffer &R__b)
273 {
274  // Stream an object of class HistoryLogLine.
275  TDatime CreationDatime;
276  TTimeStamp CreationTT;
277 
278  UInt_t R__s, R__c;
279  if (R__b.IsReading()) {
280  Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
281  TObject::Streamer(R__b);
282  R__b >> Date;
283  R__b >> Time;
284  R__b >> LogLength;
285  delete [] Log;
286  Log = new char[LogLength];
287  R__b.ReadFastArray(Log,LogLength);
288  if (R__v > 1) {
289  R__b >> (Int_t&)SortOrder;
290  R__b >> AscendingOrder;
291  if (R__v == 1) {
292  CreationDatime.Streamer(R__b);
293  CreationTT.Set(CreationDatime.GetYear(), CreationDatime.GetMonth(), CreationDatime.GetDay(), CreationDatime.GetHour(), CreationDatime.GetMinute(), CreationDatime.GetSecond(), 0, true, 0);
294  CreationDate_Sec = CreationTT.GetSec();
295  CreationDate_NSec = CreationTT.GetNanoSec();
296  }
297  else {
298  R__b >> CreationDate_Sec;
299  R__b >> CreationDate_NSec;
300  }
301  R__b.CheckByteCount(R__s, R__c, CWB::HistoryLogLine::IsA());
302  }
303  else {
304  SortOrder = DEFAULT_SORT_ORDER;
305  AscendingOrder = DEFAULT_ASCENDING;
306  CreationDate_Sec = CreationTT.GetSec();
307  CreationDate_NSec = CreationTT.GetNanoSec();
308  }
309  } else {
310  R__c = R__b.WriteVersion(CWB::HistoryLogLine::IsA(), kTRUE);
311  TObject::Streamer(R__b);
312  R__b << Date;
313  R__b << Time;
314  R__b << LogLength;
315  R__b.WriteFastArray(Log,LogLength);
316  R__b << (Int_t)SortOrder;
317  R__b << AscendingOrder;
318  R__b << CreationDate_Sec;
319  R__b << CreationDate_NSec;
320  R__b.SetByteCount(R__c, kTRUE);
321  }
322 }
#define DEFAULT_SORT_ORDER
void Init()
Definition: ChirpMass.C:280
TTimeStamp GetCreationTimeStamp()
SortOrderType
SortOrderType GetSortOrder()
SortOrderType SetSortOrder(SortOrderType SortOrder)
TDatime * GetLogDatime()
MDC Print()
void SetLogTime(int Date, int Time)
int Compare(const TObject *Obj) const
bool IsSortable() const
virtual void Browse(TBrowser *b)
char * SetLogStr(char *Log)
strcpy(RunLabel, RUN_LABEL)
#define DEFAULT_ASCENDING
SortOrderType SortOrder
HistoryLogLine(char *LogStr=NULL, TDatime *Time=NULL)
void SetLog(char *LogStr, TDatime *Time=NULL)