GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Status.cxx
Go to the documentation of this file.
1 // $Id: TGo4Status.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 "TGo4Status.h"
15 
16 #include <stdarg.h>
17 #include "Riostream.h"
18 
19 #include "TROOT.h"
20 #include "snprintf.h"
21 
22 #include "TGo4Log.h"
23 
25  TNamed()
26 {
27 }
28 
29 TGo4Status::TGo4Status(const char* name) :
30  TNamed(name, "This is a Go4 Status Object")
31 {
32  GO4TRACE((12,"TGo4Status::TGo4Status(const char*)",__LINE__, __FILE__));
33 }
34 
35 TGo4Status::TGo4Status(const char* name, const char* title) :
36  TNamed(name, title)
37 {
38  GO4TRACE((12,"TGo4Status::TGo4Status(const char*, const char*)",__LINE__, __FILE__));
39 }
40 
42 {
43  GO4TRACE((12,"TGo4Status::~TGo4Status()",__LINE__, __FILE__));
44 }
45 
46 void TGo4Status::Print(Option_t* dummy) const
47 {
48  // this trick is needed since root defines Print as const function...
49  TGo4Status* localthis= const_cast<TGo4Status*>(this);
50  localthis->PrintStatus();
51 }
52 
53 Int_t TGo4Status::PrintStatus(Text_t* buffer, Int_t buflen)
54 {
55  GO4TRACE((12,"TGo4Status::PrintStatus()",__LINE__, __FILE__));
56 
57  if(buflen<=0 && buffer!=0) return 0;
58 
59  Int_t size = 0;
60  TString localbuf = TString::Format("G-OOOO-> Status Class %s, name: %s <-OOOO-G\n", ClassName(), GetName());
61 
62  if(buffer==0)
63  std::cout << localbuf << std::endl;
64  else {
65  size = localbuf.Length();
66  if(size>buflen-1) size = buflen-1;
67  strncpy(buffer,localbuf.Data(), size);
68  }
69  return size;
70 }
71 
72 Text_t* TGo4Status::PrintIndent(Text_t* buffer, Int_t& buflen)
73 {
74  if(buflen<0 && buffer!=0) return 0;
75  Int_t restlen=buflen;
76  Text_t* cursor=buffer;
77  for (int i = 0; (i < TROOT::GetDirLevel()) && (i< buflen); i++)
78  {
79  cursor=PrintBuffer(cursor,restlen," ");
80  }
81  buflen=restlen;
82  return cursor;
83 }
84 
85 Text_t* TGo4Status::PrintBuffer(char* buffer, Int_t& buflen, const char* text,...)
86 {
87  if(buffer==0 || buflen<0) return 0;
88  va_list args;
89  va_start(args, text);
90  Int_t size=vsnprintf(buffer, buflen, text, args);
91  va_end(args);
92  if(size>buflen || size<0) return 0;
93  char* current= buffer + size;
94  buflen-=size;
95  return current;
96 }
virtual void Print(Option_t *dummy="") const
Definition: TGo4Status.cxx:46
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
Definition: TGo4Status.cxx:53
static Text_t * PrintIndent(Text_t *buffer, Int_t &buflen)
Definition: TGo4Status.cxx:72
#define GO4TRACE(X)
Definition: TGo4Log.h:26
static Text_t * PrintBuffer(char *buffer, Int_t &buflen, const char *text,...)
Definition: TGo4Status.cxx:85
virtual ~TGo4Status()
Definition: TGo4Status.cxx:41