00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ObjectStatus.h"
00015
00016 #include "Riostream.h"
00017 #include "TDatime.h"
00018 #include "TClass.h"
00019
00020 #include "TGo4Log.h"
00021 #include "TGo4Picture.h"
00022
00023 TGo4ObjectStatus::TGo4ObjectStatus() :
00024 TGo4Status(),
00025 fiObjectSize(0),
00026 fbResetProtect(kFALSE),
00027 fbDeleteProtect(kTRUE),
00028 fxObjectClass(),
00029 fxStatusTime()
00030 {
00031 }
00032
00033 TGo4ObjectStatus::TGo4ObjectStatus(TObject* object, Bool_t withtime) :
00034 TGo4Status("Initname","InitTitle"),
00035 fiObjectSize(0),
00036 fbResetProtect(kFALSE),
00037 fbDeleteProtect(kTRUE),
00038 fxObjectClass(),
00039 fxStatusTime()
00040 {
00041 GO4TRACE((15,"TGo4ObjectStatus::TGo4ObjectStatus(TNamed*)",__LINE__, __FILE__));
00042 if(object) {
00043 SetName(object->GetName());
00044 SetTitle(object->GetTitle());
00045 fxObjectClass = object->ClassName();
00046 fiObjectSize = object->IsA()->Size();
00047 if (object->InheritsFrom(TGo4Picture::Class()))
00048 fiObjectSize = ((TGo4Picture*) object)->GetTotalSize();
00049 fbDeleteProtect = !object->TestBit(TGo4Status::kGo4CanDelete);
00050 fbResetProtect = object->TestBit(TGo4Status::kGo4NoReset);
00051 } else {
00052 SetName("Unknown Name");
00053 SetTitle("Unknown Title");
00054 fxObjectClass="Unknown Class";
00055 }
00056
00057 if (withtime) {
00058 TDatime now;
00059 fxStatusTime = now.AsSQLString();
00060 }
00061
00062
00063 }
00064
00065 TGo4ObjectStatus::~TGo4ObjectStatus()
00066 {
00067 GO4TRACE((15,"TGo4ObjectStatus::~TGo4ObjectStatus()",__LINE__, __FILE__));
00068
00069 }
00070
00071 Int_t TGo4ObjectStatus::PrintStatus(Text_t* buffer, Int_t buflen)
00072 {
00073 GO4TRACE((12,"TGo4ObjectStatus::PrintStatus()",__LINE__, __FILE__));
00074 if(buflen<=0 && buffer!=0) return 0;
00075 Int_t locallen=2048;
00076 Text_t localbuf[2048];
00077 Text_t* current=localbuf;
00078 Int_t size=0;
00079 Int_t restlen=locallen;
00080 current=PrintIndent(current,restlen);
00081 current=PrintBuffer(current,restlen,"G-OOOO-> Object Status Class Printout <-OOOO-G\n");
00082 current=PrintIndent(current,restlen);
00083 current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00084 current=PrintIndent(current,restlen);
00085 current=PrintBuffer(current,restlen, " Object name: \t\t%s\n",GetName());
00086 current=PrintIndent(current,restlen);
00087 current=PrintBuffer(current,restlen, " Object title: \t\t%s\n",GetTitle());
00088 current=PrintIndent(current,restlen);
00089 current=PrintBuffer(current,restlen, " Object class: \t\t%s\n",GetObjectClass());
00090 current=PrintIndent(current,restlen);
00091 current=PrintBuffer(current,restlen, " Object size: \t\t%d byte\n",GetObjectSize());
00092 current=PrintIndent(current,restlen);
00093 current=PrintBuffer(current,restlen, " Clear protection: \t\t%d\n",IsResetProtect());
00094 current=PrintIndent(current,restlen);
00095 current=PrintBuffer(current,restlen, " Delete protection: \t\t%d\n",IsDeleteProtect());
00096 current=PrintIndent(current,restlen);
00097 current=PrintBuffer(current,restlen, " Status creation time: \t%s\n",GetTimeString());
00098 current=PrintIndent(current,restlen);
00099 current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
00100 if(buffer==0)
00101 {
00102 std::cout << localbuf << std::endl;
00103 }
00104 else
00105 {
00106 size=locallen-restlen;
00107 if(size>buflen-1)
00108 size=buflen-1;
00109 strncpy(buffer,localbuf,size);
00110 }
00111 return size;
00112 }