GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4AnalysisObjectNames.cxx
Go to the documentation of this file.
1 // $Id: TGo4AnalysisObjectNames.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 
15 
16 #include "Riostream.h"
17 #include "TROOT.h"
18 #include "TFolder.h"
19 #include "TGo4Log.h"
20 
22  TGo4Status(),
23  fxTopFolder(0)
24 {
25 }
26 
28  TGo4Status(name),
29  fxTopFolder(0)
30 {
31  GO4TRACE((15,"TGo4AnalysisObjectnames::TGo4AnalysisObjectnames(const char*)",__LINE__, __FILE__));
32 }
33 
35 {
36 GO4TRACE((15,"TGo4AnalysisObjectnames::~TGo4AnalysisObjectnames()",__LINE__, __FILE__));
37  if(fxTopFolder!=0) {
38  delete fxTopFolder;
39  fxTopFolder=0;
40  }
41 }
42 
44 {
45  if(fxTopFolder!=0)
46  return dynamic_cast<TList*> (fxTopFolder->GetListOfFolders());
47  else
48  return 0;
49 }
50 
52 {
53  TFolder* reval=fxTopFolder;
54  if(chown) fxTopFolder=0;
55  return reval;
56 }
57 
58 
59 Int_t TGo4AnalysisObjectNames::PrintStatus(Text_t* buffer, Int_t buflen)
60 {
61  GO4TRACE((12,"TGo4AnalysisObjectNames::PrintStatus()",__LINE__, __FILE__));
62  //
63  if(buflen<=0 && buffer!=0)
64  return 0;
65  gROOT->SetDirLevel(0);
66  Int_t locallen=64000;
67  Text_t localbuf[64000];
68  Int_t size=0;
69  Text_t* current=localbuf;
70  Int_t restlen=locallen;
71  current=PrintBuffer(localbuf,restlen,"G-OOOO-> Analysis Object Names Printout <-OOOO-G\n");
72  current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
73  Int_t delta=PrintFolder(fxTopFolder, current, restlen);
74  restlen-=delta;
75  current+= delta;
76  if(buffer==0)
77  {
78  std::cout << localbuf << std::endl;
79  }
80  else
81  {
82  size=locallen-restlen;
83  if(size>buflen-1)
84  size=buflen-1;
85  strncpy(buffer,localbuf,size);
86  }
87  return size;
88 }
89 
90 Int_t TGo4AnalysisObjectNames::PrintFolder(TFolder* fold, Text_t * buf, Int_t buflen)
91 {
92  GO4TRACE((12,"TGo4AnalysisObjectNames::PrintFolder()",__LINE__, __FILE__));
93  //
94  if(buf!=0 && buflen<=0)
95  {
96  std::cout <<"PrintFolder returns nop" << std::endl;
97  return 0;
98  }
99  gROOT->IncreaseDirLevel();
100  Int_t locallen=64000;
101  Text_t localbuf[64000];
102  Int_t size=0;
103  Text_t* current=localbuf;
104  Int_t restlen=locallen;
105  if(fold!=0) {
106  current=PrintIndent(current,restlen);
107  current=PrintBuffer(current,restlen,"G-OOOO-> Status Folder %s Printout <-OOOO-G\n", fold->GetName());
108  current=PrintIndent(current,restlen);
109  current=PrintBuffer(current,restlen,"G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
110  //objectlist=dynamic_cast<TList*> (fold->GetListOfFolders());
111  //std::cout << "----------- processing Print Folder "<< std::endl;
112 
113  TIter iter(fold->GetListOfFolders());
114  TObject* entry=0;
115 
116  while((entry=iter()) !=0) {
117  if(entry->InheritsFrom(TFolder::Class()))
118  {
119  // found subfolder, process in recursion
120  TFolder* subobj= dynamic_cast<TFolder*> (entry);
121  Int_t delta=PrintFolder(subobj, current, restlen);
122  restlen-=delta;
123  current+= delta;
124  }
125  else if (entry->InheritsFrom(TGo4Status::Class()))
126  {
127  TGo4Status* subobj= dynamic_cast<TGo4Status*> (entry);
128  Int_t delta=subobj->PrintStatus(current,restlen);
129  restlen-=delta;
130  current+=delta;
131  }
132  else
133  {
134  entry->ls();
135  // unknown object
136  }
137  } // while
138  current=PrintIndent(current,restlen);
139  current=PrintBuffer(current,restlen, "G-OOOO-> ---------------------------------------------- <-OOOO-G\n");
140  }
141 
142  if(buf==0)
143  {
144  std::cout << localbuf << std::endl;
145  }
146  else
147  {
148  size=locallen-restlen;
149  if(size>buflen-1)
150  size=buflen-1;
151  strncpy(buf,localbuf,size);
152 
153  }
154  gROOT->DecreaseDirLevel();
155  return size;
156 }
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
Int_t PrintFolder(TFolder *fold, Text_t *buf, Int_t buflen=0)
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
TFolder * GetNamesFolder(Bool_t chown=kFALSE)
#define GO4TRACE(X)
Definition: TGo4Log.h:26
static Text_t * PrintBuffer(char *buffer, Int_t &buflen, const char *text,...)
Definition: TGo4Status.cxx:85