ROOT  6.06/09
Reference Guide
TProofOutputList.cxx
Go to the documentation of this file.
1 // @(#)root/proofplayer:$Id$
2 // Author: G. Ganis 04/08/2010
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TProofOutputList //
15 // //
16 // Derivation of TList with an overload of ls() and Print() allowing //
17 // to filter out some of the variables. //
18 // //
19 //////////////////////////////////////////////////////////////////////////
20 
21 #include "TObjString.h"
22 #include "TProof.h"
23 #include "TProofOutputList.h"
24 #include "TRegexp.h"
25 #include "TString.h"
26 
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Constructor
31 
32 TProofOutputList::TProofOutputList(const char *dontshow) : TList()
33 {
34  fDontShow = new TList();
35  TString regs(dontshow), reg;
36  Int_t from = 0;
37  while (regs.Tokenize(reg, from, ",")) {
38  fDontShow->Add(new TObjString(reg));
39  }
40 }
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Destructor
44 
46 {
49 }
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// Attach to list 'alist'
53 
55 {
56  if (!alist) return;
57 
58  if (GetSize() > 0) Clear();
59 
60  TIter nxo(alist);
61  TObject *obj = 0;
62  while ((obj = nxo())) { Add(obj); }
64 }
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// List the content of the list
68 
69 void TProofOutputList::ls(Option_t *option) const
70 {
71  TString opt(option);
72  opt.ToUpper();
73  if (opt.BeginsWith("ALL")) {
74  opt.Remove(0,3);
75  TList::ls(opt);
76  } else {
77  TIter nxos(fDontShow);
78  TObjString *os = 0;
79  TList doShow;
80  doShow.SetOwner(kFALSE);
81 
82  Bool_t hasmissing = kFALSE;
83  TIter nxo(this);
84  TObject *obj = 0;
85  while ((obj = nxo())) {
86  TString s = obj->GetName();
87  if (s == kPROOF_MissingFiles) {
88  TList *mf = dynamic_cast<TList *> (obj);
89  if (mf && mf->GetSize() > 0) hasmissing = kTRUE;
90  } else {
91  nxos.Reset();
92  Bool_t doadd = kTRUE;
93  while ((os = (TObjString *) nxos())) {
94  TRegexp rg(os->GetName(), kTRUE);
95  if (s.Index(rg) != kNPOS) {
96  doadd = kFALSE;
97  break;
98  }
99  }
100  if (doadd) doShow.Add(obj);
101  }
102  }
103  doShow.ls(option);
104  // Notify if missing files were found
105  if (hasmissing)
106  Printf(" +++ Missing files list not empty: use ShowMissingFiles to display it +++");
107  }
108  // Done
109  return;
110 }
111 
112 
113 ////////////////////////////////////////////////////////////////////////////////
114 /// Print the content of the list
115 
117 {
118  TString opt(option);
119  opt.ToUpper();
120  if (opt.BeginsWith("ALL")) {
121  opt.Remove(0,3);
122  TList::Print(opt);
123  } else {
124  TIter nxos(fDontShow);
125  TObjString *os = 0;
126  TList doShow;
127  doShow.SetOwner(kFALSE);
128 
129  Bool_t hasmissing = kFALSE;
130  TIter nxo(this);
131  TObject *obj = 0;
132  while ((obj = nxo())) {
133  TString s = obj->GetName();
134  if (s == kPROOF_MissingFiles) {
135  TList *mf = dynamic_cast<TList *> (obj);
136  if (mf && mf->GetSize() > 0) hasmissing = kTRUE;
137  } else {
138  nxos.Reset();
139  Bool_t doadd = kTRUE;
140  while ((os = (TObjString *) nxos())) {
141  TRegexp rg(os->GetName());
142  if (s.Index(rg) != kNPOS) {;
143  doadd = kFALSE;
144  break;
145  }
146  }
147  if (doadd) doShow.Add(obj);
148  }
149  }
150  doShow.Print(option);
151  // Notify if missing files were found
152  if (hasmissing)
153  Printf(" +++ Missing files list not empty: use ShowMissingFiles to display it +++");
154  }
155  // Done
156  return;
157 }
const char * GetName() const
Returns name of object.
Definition: TObjString.h:42
Collectable string class.
Definition: TObjString.h:32
virtual void ls(Option_t *option="") const
List (ls) all objects in this collection.
const char Option_t
Definition: RtypesCore.h:62
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1101
Regular expression class.
Definition: TRegexp.h:35
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:558
void Reset()
Definition: TCollection.h:161
#define SafeDelete(p)
Definition: RConfig.h:436
A doubly linked list.
Definition: TList.h:47
virtual void Print(Option_t *option="") const
Print the content of the list.
ClassImp(TProofOutputList) TProofOutputList
Constructor.
#define Printf
Definition: TGeoToOCC.h:18
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
virtual Int_t GetSize() const
Definition: TCollection.h:95
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
const char *const kPROOF_MissingFiles
Definition: TProof.h:160
virtual ~TProofOutputList()
Destructor.
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:348
Mother of all ROOT objects.
Definition: TObject.h:58
virtual void Add(TObject *obj)
Definition: TList.h:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
virtual void ls(Option_t *option="") const
List the content of the list.
void AttachList(TList *alist)
Attach to list 'alist'.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj