21 #include "TObjString.h"
24 TTimeStamp CreationTT;
29 if ((HistoryTypes != NULL) && (TypeNumber > 0)){
30 for (
int i = 0;
i < TypeNumber;
i++) {
31 if (HistoryTypes[
i] == NULL)
HistoryStageException(kBreak,
"CWB::HistoryStage::HistoryStage",
"HistoryTypes[%i] is NULL",
i);
32 this->HistoryTypes.AddLast(
new TObjString(HistoryTypes[
i]));
36 if (Name != NULL)
SetName(Name);
39 this->
Date = Time->GetDate();
40 this->Time = Time->GetTime();
44 this->
Date = tmpTime.GetDate();
45 this->Time = tmpTime.GetTime();
50 TTimeStamp CreationTT;
53 CreationDate_Sec = CreationTT.GetSec();
54 CreationDate_NSec = CreationTT.GetNanoSec();
55 if (Name == NULL) HistoryStageException(kBreak,
"CWB::HistoryStage::HistoryStage",
"Name is NULL");
57 for (
int i = 0;
i < HistoryTypes.GetSize();
i++) {
58 TObjString *tmpString =
static_cast<TObjString*
>(HistoryTypes.At(
i));
59 this->HistoryTypes.AddLast(tmpString);
62 if (Name != NULL)
SetName(Name);
63 if (Comment != NULL) SetComment(Comment);
65 this->Date = Time->GetDate();
66 this->Time = Time->GetTime();
70 this->Date = tmpTime.GetDate();
71 this->Time = tmpTime.GetTime();
76 TTimeStamp CreationTT;
79 CreationDate_Sec = CreationTT.GetSec();
80 CreationDate_NSec = CreationTT.GetNanoSec();
81 if (HistoryTypes == NULL) HistoryStageException(kBreak,
"CWB::HistoryStage::HistoryStage",
"HistoryType is NULL");
82 if (Name == NULL) HistoryStageException(kBreak,
"CWB::HistoryStage::HistoryStage",
"Name is NULL");
84 for (
int i = 0;
i < TypeNumber;
i++) {
85 if (HistoryTypes[
i] == NULL) HistoryStageException(kBreak,
"CWB::HistoryStage::HistoryStage",
"HistoryTypes[%i] is NULL",
i);
86 this->HistoryTypes.AddLast(
new TObjString(HistoryTypes[
i]));
95 TTimeStamp CreationTT;
97 CreationDate_Sec = CreationTT.GetSec();
98 CreationDate_NSec = CreationTT.GetNanoSec();
99 if (Name == NULL) HistoryStageException(kBreak,
"HistoryStage::HistoryStage",
"Name is NULL");
101 for (
int i = 0;
i < HistoryTypes.GetSize();
i++) {
102 TObjString *tmpString =
static_cast<TObjString*
>(HistoryTypes.At(
i));
103 this->HistoryTypes.AddLast(tmpString);
118 if (HistoryStage.
Name != NULL) this->
Name = strdup(HistoryStage.
Name);
119 else this->
Name = NULL;
124 for (i = 0; i < HistoryStage.
HistoryTypes.GetSize(); i++) {
127 for (i = 0; i < HistoryStage.
History.GetSize(); i++) {
130 for (i = 0; i < HistoryStage.
Logs.GetSize(); i++) {
145 if (Name == NULL) HistoryStageException(kBreak,
"HistoryStage::SetName",
"Name is NULL");
153 if (Comment == NULL) HistoryStageException(kBreak,
"HistoryStage::SetComment",
"Comment is NULL");
161 this->Date = Time->GetDate();
162 this->Time = Time->GetTime();
177 if (HistoryTypes == NULL) HistoryStageException(kBreak,
"HistoryStage::SetTypes",
"HistoryType is NULL");
179 this->HistoryTypes.Delete();
181 for (i = 0; i < TypeNumber; i++) {
182 this->HistoryTypes.AddLast(
new TObjString(HistoryTypes[i]));
185 for (i = 0; i <
History.GetSize(); i++) {
188 if (!TypeAllowed(StrApp))
History.Remove(HistoryLineApp);
197 char *TempString = NULL;
199 if (!TypeAllowed(Type))
200 HistoryStageException(kBreak,
"CWB::HistoryStage::SetTypeComment",
"Type %s not allowed", Type);
202 if (!TypeAlreadyPresent(Type))
203 HistoryStageException(kBreak,
"CWB::HistoryStage::SetTypeComment",
"Type %s not present yet", Type);
205 for(i = 0; i <
History.GetSize(); i++) {
217 if (Name == NULL)
return NULL;
218 else return strdup(Name);
223 if (Comment == NULL)
return NULL;
224 else return strdup(Comment);
239 return new TDatime(Date, Time);
246 char *TempString = NULL, *TempComment = NULL;
248 if (!TypeAllowed(Type))
249 HistoryStageException(kBreak,
"CWB::HistoryStage::GetTypeComment",
"Type %s not allowed", Type);
251 if (!TypeAlreadyPresent(Type))
252 HistoryStageException(kBreak,
"CWB::HistoryStage::GetTypeComment",
"Type %s not present yet", Type);
254 for(i = 0; i <
History.GetSize(); i++) {
257 if (strcmp(TempString, Type) == 0) TempComment = TempHistory->
GetHistoryComment();
272 Logs.AddLast(TempLog);
284 Logs.AddLast(TempLog);
293 if (!TypeAllowed(Type)) HistoryStageException(kBreak,
"CWB::HistoryStage::AddHistory",
"Type not allowed");
294 if (TypeAlreadyPresent(Type)) {
295 if (!Replace) HistoryStageException(kBreak,
"CWB::HistoryStage::AddHistory",
"Type already present");
297 for (i = 0; i < this->History.GetSize(); i++) {
298 StrApp =
static_cast<HistoryLine*
>(this->History.At(i))->GetHistoryType();
299 if (strcmp(StrApp, Type) == 0) {
300 this->History.Remove(this->History.At(i));
307 TempHistory =
new HistoryLine(Type, Comment, History);
311 this->History.AddLast(TempHistory);
321 return Logs.GetSize();
326 if ((index < 0) || (index >=
History.GetSize())) HistoryStageException(kBreak,
"CWB::HistoryStage::GetHistoryEntry",
"Index (%i) out of bounds", index);
333 if ((index < 0) || (index >=
History.GetSize())) HistoryStageException(kBreak,
"CWB::HistoryStage::GetHistoryEntryType",
"Index (%i) out of bounds", index);
340 if ((index < 0) || (index >= Logs.GetSize())) HistoryStageException(kBreak,
"CWB::HistoryStage::GetLogEntry",
"Index (%i) out of bounds", index);
341 else return static_cast<HistoryLogLine*
>(Logs.At(index))->GetLogStr();
347 if ((index < 0) || (index >= Logs.GetSize())) HistoryStageException(kBreak,
"CWB::HistoryStage::GetLogEntryDate",
"Index (%i) out of bounds", index);
348 else return static_cast<HistoryLogLine*
>(Logs.At(index))->GetLogDate();
354 if ((index < 0) || (index >= Logs.GetSize())) HistoryStageException(kBreak,
"CWB::HistoryStage::GetLogEntryTime",
"Index (%i) out of bounds", index);
355 else return static_cast<HistoryLogLine*
>(Logs.At(index))->GetLogTime();
361 if ((index < 0) || (index >= Logs.GetSize())) HistoryStageException(kBreak,
"CWB::HistoryStage::GetLogEntryDatime",
"Index (%i) out of bounds", index);
362 else return static_cast<HistoryLogLine*
>(Logs.At(index))->GetLogDatime();
371 if (!TypeAllowed(Type)) HistoryStageException(kBreak,
"CWB::HistoryStage::GetHistory",
" Illegal Type");
373 for (i = 0; i <
History.GetSize(); i++) {
375 if (strcmp(StrApp, Type) == 0) {
386 Logs.Sort(Ascending);
396 if (strcmp(StrApp, Type) == 0) {
408 for (
int i = 0;
i < HistoryTypes.GetSize();
i++) {
410 if (strcmp(Type, static_cast<TObjString*>(HistoryTypes.At(
i))->GetName()) == 0)
return true;
422 TDatime tmpTime(Date, Time);
425 cout <<
"Stage Time : " << tmpTime.GetYear() <<
"/" << tmpTime.GetMonth() <<
"/" << tmpTime.GetDay() <<
" - ";
426 cout << tmpTime.GetHour() <<
":" << tmpTime.GetMinute() <<
":" << tmpTime.GetSecond() << endl;
427 cout << Name <<
"'s History" << endl;
429 for (i = 0; i <
History.GetSize(); i++) {
433 cout << Name <<
"'s Logs" << endl;
434 for (i = 0; i < Logs.GetSize(); i++) {
451 if (this->CreationDate_Sec < static_cast<HistoryStage*>(const_cast<TObject*>(Obj))->CreationDate_Sec) Result = -1;
452 else if (this->CreationDate_Sec > static_cast<HistoryStage*>(const_cast<TObject*>(Obj))->CreationDate_Sec) Result = 1;
453 else if (this->CreationDate_NSec < static_cast<HistoryStage*>(const_cast<TObject*>(Obj))->CreationDate_NSec) Result = -1;
454 else if (this->CreationDate_NSec > static_cast<HistoryStage*>(const_cast<TObject*>(Obj))->CreationDate_NSec) Result = 1;
458 if (this->Date < static_cast<HistoryStage*>(const_cast<TObject*>(Obj))->Date) Result = -1;
459 else if (this->Date > static_cast<HistoryStage*>(const_cast<TObject*>(Obj))->Date) Result = 1;
464 Result = strcmp(this->Name, StrTmp);
468 Result = strcmp(this->Comment, StrTmp);
483 if (TypeAllowed(TypeName))
484 HistoryStageException(kBreak,
"CWB::HistoryStage::AddType",
"Type %s already present", TypeName);
486 HistoryTypes.AddLast(
new TObjString(TypeName));
494 TObjString* TempString;
498 if (!TypeAllowed(TypeName))
499 HistoryStageException(kBreak,
"CWB::HistoryStage::RemoveType",
"Type %s not present", TypeName);
501 for (i = 0; i < HistoryTypes.GetSize(); i++) {
502 TempString =
static_cast<TObjString*
>(HistoryTypes.At(i));
503 if (strcmp(TempString->GetName(), TypeName) == 0) HistoryTypes.Remove(TempString);
506 for (i = 0; i <
History.GetSize(); i++) {
509 if (!TypeAllowed(StrApp))
History.Remove(tmpHistory);
520 this->SortOrder = SortOrder;
521 for (i = 0; i <
History.GetSize(); i++) {
524 for (i = 0; i < Logs.GetSize(); i++) {
525 static_cast<HistoryLogLine*
>(Logs.At(i))->SetSortOrder(SortOrder);
527 return this->SortOrder;
557 AscendingOrder =
true;
558 for (i = 0; i <
History.GetSize(); i++) {
561 for (i = 0; i < Logs.GetSize(); i++) {
562 static_cast<HistoryLogLine*
>(Logs.At(i))->SetAscendingSortOrder();
564 return AscendingOrder;
571 AscendingOrder =
false;
572 for (i = 0; i <
History.GetSize(); i++) {
575 for (i = 0; i < Logs.GetSize(); i++) {
576 static_cast<HistoryLogLine*
>(Logs.At(i))->SetDescendantSortOrder();
578 return AscendingOrder;
583 return AscendingOrder;
588 return !AscendingOrder;
594 Logs.Sort(AscendingOrder);
599 TTimeStamp CreationTT(CreationDate_Sec, CreationDate_NSec);
614 Comment =
new char[1];
622 if (Name != NULL)
delete Name;
623 if (Comment != NULL)
delete Name;
629 if (this->Name != NULL)
delete this->Name;
632 NameLength = strlen(Name) + 1;
633 this->Name =
new char[NameLength];
638 this->Name =
new char[1];
645 if (this->Comment != NULL)
delete this->Comment;
647 if (Comment != NULL) {
648 CommentLength = strlen(Comment) + 1;
649 this->Comment =
new char[CommentLength];
650 strcpy(this->Comment, Comment);
654 this->Comment =
new char[1];
655 this->Comment[0] = 0;
659 void CWB::HistoryStage::Streamer(TBuffer &R__b)
662 TDatime CreationDatime;
663 TTimeStamp CreationTT;
666 if (R__b.IsReading()) {
667 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v) { }
668 TObject::Streamer(R__b);
671 HistoryTypes.Streamer(R__b);
674 Name =
new char[NameLength];
675 R__b.ReadFastArray(Name,NameLength);
676 History.Streamer(R__b);
679 R__b >> CommentLength;
681 Comment =
new char[CommentLength];
682 R__b.ReadFastArray(Comment,CommentLength);
683 R__b >> (Int_t&)SortOrder;
684 R__b >> AscendingOrder;
686 CreationDatime.Streamer(R__b);
687 CreationTT.Set(CreationDatime.GetYear(), CreationDatime.GetMonth(), CreationDatime.GetDay(), CreationDatime.GetHour(), CreationDatime.GetMinute(), CreationDatime.GetSecond(), 0,
true, 0);
688 CreationDate_Sec = CreationTT.GetSec();
689 CreationDate_NSec = CreationTT.GetNanoSec();
692 R__b >> CreationDate_Sec;
693 R__b >> CreationDate_NSec;
694 R__b.CheckByteCount(R__s, R__c, CWB::HistoryStage::IsA());
702 CreationDate_Sec = CreationTT.GetSec();
703 CreationDate_NSec = CreationTT.GetNanoSec();
706 R__c = R__b.WriteVersion(CWB::HistoryStage::IsA(), kTRUE);
707 TObject::Streamer(R__b);
710 HistoryTypes.Streamer(R__b);
712 R__b.WriteFastArray(Name,NameLength);
713 History.Streamer(R__b);
715 R__b << CommentLength;
716 R__b.WriteFastArray(Comment,CommentLength);
717 R__b << (Int_t)SortOrder;
718 R__b << AscendingOrder;
719 R__b << CreationDate_Sec;
720 R__b << CreationDate_NSec;
721 R__b.SetByteCount(R__c, kTRUE);
727 cout << location <<
" " << msgfmt << endl;
bool SetDescendantSortOrder()
void HistoryStageException(int type, const char *location, const char *msgfmt,...)
#define DEFAULT_SORT_ORDER
TDatime * GetLogEntryDatime(int index)
bool SetAscendingSortOrder()
bool TypeAllowed(char *Type)
plot hist2D SetName("WSeries-1")
char * RemoveType(char *TypeName)
SortOrderType SetSortOrder(SortOrderType SortOrder)
SortOrderType SetSortOrder(SortOrderType SortOrder)
bool SetDescendantSortOrder()
virtual void Browse(TBrowser *b)
bool IsSortOrderInsertion()
char * GetHistoryComment()
bool SetDescendantSortOrder()
void SetTypes(char **HistoryTypes, int TypeNumber)
void SetTime(TDatime *Time)
HistoryStage(char **HistoryTypes=NULL, int TypeNumber=0, char *Name=NULL, char *Comment=NULL, TDatime *Time=NULL)
SortOrderType SetSortOrder(SortOrderType SortOrder)
bool IsSortOrderAlphabetical()
int Compare(const TObject *Obj) const
char * SetName(char *Name)
void AddLog(char *LogMsg, TDatime *Time=NULL)
char * GetHistory(char *Type)
char * GetHistoryEntryType(int index)
bool GetDescendantSortOrder()
char * AddType(char *TypeName)
char * GetHistoryEntry(int index)
TTimeStamp GetCreationTimeStamp()
bool SetAscendingSortOrder()
bool SetAscendingSortOrder()
char * SetComment(char *Comment)
int GetLogEntryDate(int index)
void AddHistory(char *Type, char *History, char *Comment=NULL, bool Replace=false)
SortOrderType GetSortOrder()
int GetLogEntryTime(int index)
strcpy(RunLabel, RUN_LABEL)
#define DEFAULT_ASCENDING
bool GetAscendingSortOrder()
char * GetLogEntry(int index)
bool TypeAlreadyPresent(char *Type)
char * SetTypeComment(char *Type, char *Comment)
char * SetHistoryComment(char *Comment)
char * GetTypeComment(char *Type)
void SortLogs(bool Ascending=true)
void CommentSet(char *Comment)