Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 #include "TGo4Status.h"
00015 
00016 #include <stdarg.h>
00017 #include "Riostream.h"
00018 
00019 #include "TROOT.h"
00020 #include "snprintf.h"
00021 
00022 #include "TGo4Log.h"
00023 
00024 TGo4Status::TGo4Status() :
00025    TNamed()
00026 {
00027 }
00028 
00029 TGo4Status::TGo4Status(const char* name) :
00030    TNamed(name, "This is a Go4 Status Object")
00031 {
00032    GO4TRACE((12,"TGo4Status::TGo4Status(const char*)",__LINE__, __FILE__));
00033 }
00034 
00035 TGo4Status::TGo4Status(const char* name, const char* title) :
00036    TNamed(name, title)
00037 {
00038    GO4TRACE((12,"TGo4Status::TGo4Status(const char*, const char*)",__LINE__, __FILE__));
00039 }
00040 
00041 TGo4Status::~TGo4Status()
00042 {
00043    GO4TRACE((12,"TGo4Status::~TGo4Status()",__LINE__, __FILE__));
00044 }
00045 
00046 void TGo4Status::Print(Option_t* dummy) const
00047 {
00048    
00049    TGo4Status* localthis= const_cast<TGo4Status*>(this);
00050    localthis->PrintStatus();
00051 }
00052 
00053 Int_t TGo4Status::PrintStatus(Text_t* buffer, Int_t buflen)
00054 {
00055    GO4TRACE((12,"TGo4Status::PrintStatus()",__LINE__, __FILE__));
00056 
00057    if(buflen<=0 && buffer!=0) return 0;
00058 
00059    Int_t size = 0;
00060    TString localbuf = TString::Format("G-OOOO-> Status Class %s, name: %s <-OOOO-G\n", ClassName(), GetName());
00061 
00062    if(buffer==0)
00063       std::cout << localbuf << std::endl;
00064    else {
00065       size = localbuf.Length();
00066       if(size>buflen-1) size = buflen-1;
00067       strncpy(buffer,localbuf.Data(), size);
00068    }
00069    return size;
00070 }
00071 
00072 Text_t* TGo4Status::PrintIndent(Text_t* buffer, Int_t& buflen)
00073 {
00074    if(buflen<0 && buffer!=0) return 0;
00075    Int_t restlen=buflen;
00076    Text_t* cursor=buffer;
00077    for (int i = 0; (i < TROOT::GetDirLevel()) && (i< buflen); i++)
00078       {
00079          cursor=PrintBuffer(cursor,restlen," ");
00080       }
00081    buflen=restlen;
00082    return cursor;
00083 }
00084 
00085 Text_t* TGo4Status::PrintBuffer(char* buffer, Int_t& buflen, const char* text,...)
00086 {
00087    if(buffer==0 || buflen<0) return 0;
00088    va_list args;
00089    va_start(args, text);
00090    Int_t size=vsnprintf(buffer, buflen, text, args);
00091    va_end(args);
00092    if(size>buflen || size<0) return 0;
00093    char* current= buffer + size;
00094    buflen-=size;
00095    return current;
00096 }