GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ObjectStatus.cxx
Go to the documentation of this file.
1 // $Id: TGo4ObjectStatus.cxx 2736 2020-04-15 16:11:19Z 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 fuer 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 <iostream>
17 
18 #include "TDatime.h"
19 #include "TClass.h"
20 
21 #include "TGo4Log.h"
22 #include "TGo4Picture.h"
23 
25  TGo4Status(),
26  fiObjectSize(0),
27  fbResetProtect(kFALSE),
28  fbDeleteProtect(kTRUE),
29  fxObjectClass(),
30  fxStatusTime()
31 {
32 }
33 
34 TGo4ObjectStatus::TGo4ObjectStatus(TObject* object, Bool_t withtime) :
35  TGo4Status("Initname","InitTitle"),
36  fiObjectSize(0),
37  fbResetProtect(kFALSE),
38  fbDeleteProtect(kTRUE),
39  fxObjectClass(),
40  fxStatusTime()
41 {
42  GO4TRACE((15,"TGo4ObjectStatus::TGo4ObjectStatus(TNamed*)",__LINE__, __FILE__));
43  if(object) {
44  SetName(object->GetName());
45  SetTitle(object->GetTitle());
46  fxObjectClass = object->ClassName();
47  fiObjectSize = object->IsA()->Size();
48  if (object->InheritsFrom(TGo4Picture::Class()))
49  fiObjectSize = ((TGo4Picture*) object)->GetTotalSize();
50  fbDeleteProtect = !object->TestBit(TGo4Status::kGo4CanDelete);
51  fbResetProtect = object->TestBit(TGo4Status::kGo4NoReset);
52  } else {
53  SetName("Unknown Name");
54  SetTitle("Unknown Title");
55  fxObjectClass="Unknown Class";
56  }
57 
58  if (withtime) {
59  TDatime now;
60  fxStatusTime = now.AsSQLString();
61  }
62  // we might suppress time information for substatus objects
63  // for performance reason
64 }
65 
67 {
68  GO4TRACE((15,"TGo4ObjectStatus::~TGo4ObjectStatus()",__LINE__, __FILE__));
69 
70 }
71 
72 Int_t TGo4ObjectStatus::PrintStatus(Text_t* buffer, Int_t buflen)
73 {
74  GO4TRACE((12,"TGo4ObjectStatus::PrintStatus()",__LINE__, __FILE__));
75  if(buflen<=0 && buffer!=0) return 0;
76  Int_t locallen=2048;
77  Text_t localbuf[2048];
78  Text_t* current=localbuf;
79  Int_t size=0;
80  Int_t restlen=locallen;
81  current=PrintIndent(current,restlen);
82  current=PrintBuffer(current,restlen,"G-OOOO-> Object Status Class Printout <-OOOO-G\n");
83  current=PrintIndent(current,restlen);
84  current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
85  current=PrintIndent(current,restlen);
86  current=PrintBuffer(current,restlen, " Object name: \t\t%s\n",GetName());
87  current=PrintIndent(current,restlen);
88  current=PrintBuffer(current,restlen, " Object title: \t\t%s\n",GetTitle());
89  current=PrintIndent(current,restlen);
90  current=PrintBuffer(current,restlen, " Object class: \t\t%s\n",GetObjectClass());
91  current=PrintIndent(current,restlen);
92  current=PrintBuffer(current,restlen, " Object size: \t\t%d byte\n",GetObjectSize());
93  current=PrintIndent(current,restlen);
94  current=PrintBuffer(current,restlen, " Clear protection: \t\t%d\n",IsResetProtect());
95  current=PrintIndent(current,restlen);
96  current=PrintBuffer(current,restlen, " Delete protection: \t\t%d\n",IsDeleteProtect());
97  current=PrintIndent(current,restlen);
98  current=PrintBuffer(current,restlen, " Status creation time: \t%s\n",GetTimeString());
99  current=PrintIndent(current,restlen);
100  current = PrintBuffer(current, restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
101  if (buffer == 0) {
102  std::cout << localbuf << std::endl;
103  } else {
104  size = locallen - restlen;
105  if (size > buflen - 1)
106  size = buflen - 1;
107  strncpy(buffer, localbuf, size);
108  }
109  return size;
110 }
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:84
Int_t GetObjectSize() const
virtual ~TGo4ObjectStatus()