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