GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ObjectStatus.cxx
Go to the documentation of this file.
1 // $Id: TGo4ObjectStatus.cxx 999 2013-07-25 11:58:59Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4ObjectStatus.h"
15 
16 #include "Riostream.h"
17 #include "TDatime.h"
18 #include "TClass.h"
19 
20 #include "TGo4Log.h"
21 #include "TGo4Picture.h"
22 
24  TGo4Status(),
25  fiObjectSize(0),
26  fbResetProtect(kFALSE),
27  fbDeleteProtect(kTRUE),
28  fxObjectClass(),
29  fxStatusTime()
30 {
31 }
32 
33 TGo4ObjectStatus::TGo4ObjectStatus(TObject* object, Bool_t withtime) :
34  TGo4Status("Initname","InitTitle"),
35  fiObjectSize(0),
36  fbResetProtect(kFALSE),
37  fbDeleteProtect(kTRUE),
38  fxObjectClass(),
39  fxStatusTime()
40 {
41  GO4TRACE((15,"TGo4ObjectStatus::TGo4ObjectStatus(TNamed*)",__LINE__, __FILE__));
42  if(object) {
43  SetName(object->GetName());
44  SetTitle(object->GetTitle());
45  fxObjectClass = object->ClassName();
46  fiObjectSize = object->IsA()->Size();
47  if (object->InheritsFrom(TGo4Picture::Class()))
48  fiObjectSize = ((TGo4Picture*) object)->GetTotalSize();
49  fbDeleteProtect = !object->TestBit(TGo4Status::kGo4CanDelete);
50  fbResetProtect = object->TestBit(TGo4Status::kGo4NoReset);
51  } else {
52  SetName("Unknown Name");
53  SetTitle("Unknown Title");
54  fxObjectClass="Unknown Class";
55  }
56 
57  if (withtime) {
58  TDatime now;
59  fxStatusTime = now.AsSQLString();
60  }
61  // we might suppress time information for substatus objects
62  // for performance reason
63 }
64 
66 {
67  GO4TRACE((15,"TGo4ObjectStatus::~TGo4ObjectStatus()",__LINE__, __FILE__));
68 
69 }
70 
71 Int_t TGo4ObjectStatus::PrintStatus(Text_t* buffer, Int_t buflen)
72 {
73  GO4TRACE((12,"TGo4ObjectStatus::PrintStatus()",__LINE__, __FILE__));
74  if(buflen<=0 && buffer!=0) return 0;
75  Int_t locallen=2048;
76  Text_t localbuf[2048];
77  Text_t* current=localbuf;
78  Int_t size=0;
79  Int_t restlen=locallen;
80  current=PrintIndent(current,restlen);
81  current=PrintBuffer(current,restlen,"G-OOOO-> Object Status Class Printout <-OOOO-G\n");
82  current=PrintIndent(current,restlen);
83  current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
84  current=PrintIndent(current,restlen);
85  current=PrintBuffer(current,restlen, " Object name: \t\t%s\n",GetName());
86  current=PrintIndent(current,restlen);
87  current=PrintBuffer(current,restlen, " Object title: \t\t%s\n",GetTitle());
88  current=PrintIndent(current,restlen);
89  current=PrintBuffer(current,restlen, " Object class: \t\t%s\n",GetObjectClass());
90  current=PrintIndent(current,restlen);
91  current=PrintBuffer(current,restlen, " Object size: \t\t%d byte\n",GetObjectSize());
92  current=PrintIndent(current,restlen);
93  current=PrintBuffer(current,restlen, " Clear protection: \t\t%d\n",IsResetProtect());
94  current=PrintIndent(current,restlen);
95  current=PrintBuffer(current,restlen, " Delete protection: \t\t%d\n",IsDeleteProtect());
96  current=PrintIndent(current,restlen);
97  current=PrintBuffer(current,restlen, " Status creation time: \t%s\n",GetTimeString());
98  current=PrintIndent(current,restlen);
99  current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
100  if(buffer==0)
101  {
102  std::cout << localbuf << std::endl;
103  }
104  else
105  {
106  size=locallen-restlen;
107  if(size>buflen-1)
108  size=buflen-1;
109  strncpy(buffer,localbuf,size);
110  }
111  return size;
112 }
Bool_t IsDeleteProtect() const
Bool_t IsResetProtect() const
static Text_t * PrintIndent(Text_t *buffer, Int_t &buflen)
Definition: TGo4Status.cxx:72
const char * GetTimeString() const
const char * GetObjectClass() const
#define GO4TRACE(X)
Definition: TGo4Log.h:26
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
static Text_t * PrintBuffer(char *buffer, Int_t &buflen, const char *text,...)
Definition: TGo4Status.cxx:85
Int_t GetObjectSize() const
virtual ~TGo4ObjectStatus()