ROOT  6.06/09
Reference Guide
TProofMonSender.cxx
Go to the documentation of this file.
1 // @(#)root/proofplayer:$Id$
2 // Author: G.Ganis July 2011
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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 // //
15 // TProofMonSender //
16 // //
17 // Provides the interface for PROOF monitoring to different writers. //
18 // Allows to decouple the information sent from the backend. //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 
22 #include "TProofDebug.h"
23 #include "TProofMonSender.h"
24 
25 ////////////////////////////////////////////////////////////////////////////////
26 /// Parse send options from string 'sendopts'.
27 /// Format is:
28 /// "[-,+]S[n]|[-,+]D[m]|[-,+]F[j]"
29 /// where:
30 /// 1. The big letter refers to the 'table' following
31 ///
32 /// S table with summary log
33 /// D table with dataset info
34 /// F table files info
35 ///
36 /// 2. The '-,+' in front disables/enables the related table; if
37 /// absent '+' is assumed
38 ///
39 /// 3. The number after the letter is the version of the related
40 /// table
41 ///
42 /// Returns -1 if nothing is enabled; 0 otherwise
43 
45 {
46 
47  // Must have something to parse
48  if (sendopts && strlen(sendopts) > 0) {
49 
50  PDB(kMonitoring,1) Info("SetSendOptions", "sendopts: '%s'", sendopts);
51 
52  Bool_t doit = kTRUE;
53  Char_t t = 0;
54  Int_t v = -1;
55  TString oos(sendopts), oo;
56  Ssiz_t from = 0;
57  while (oos.Tokenize(oo, from, ":")) {
58  PDB(kMonitoring,2) Info("SetSendOptions", "oo: '%s'", oo.Data());
59  // Parse info
60  doit = kTRUE;
61  if (oo.BeginsWith("+")) oo.Remove(0,1);
62  if (oo.BeginsWith("-")) { doit = kFALSE; oo.Remove(0,1); }
63  PDB(kMonitoring,2) Info("SetSendOptions", "oo: '%s' doit:%d", oo.Data(), doit);
64  t = oo[0];
65  oo.Remove(0,1);
66  PDB(kMonitoring,2) Info("SetSendOptions", "oo: '%s' doit:%d t:'%c'", oo.Data(), doit, t);
67  v = -1;
68  if (!oo.IsNull() && oo.IsDigit()) v = oo.Atoi();
69  PDB(kMonitoring,2) Info("SetSendOptions", "oo: '%s' doit:%d t:'%c' v:%d", oo.Data(), doit, t, v);
70  // Fill relevant variables
72  if (t == 'D') cbit = kSendDataSetInfo;
73  if (t == 'F') cbit = kSendFileInfo;
74  if (doit)
75  SetBit(cbit);
76  else
77  ResetBit(cbit);
78  if (v > -1) {
79  if (t == 'S') fSummaryVrs = v;
80  if (t == 'D') fDataSetInfoVrs = v;
81  if (t == 'F') fFileInfoVrs = v;
82  }
83  }
84  }
85 
86  // Something must be enabled
88  Warning("SetSendOptions", "all tables are disabled!");
89  return -1;
90  }
91 
92  // Notify
93  TString snot = TString::Format("%s: sending:", GetTitle());
94  if (TestBit(kSendSummary)) snot += TString::Format(" 'summary' (v:%d)", fSummaryVrs);
95  if (TestBit(kSendDataSetInfo)) snot += TString::Format(" 'dataset info' (v:%d)", fDataSetInfoVrs);
96  if (TestBit(kSendFileInfo)) snot += TString::Format(" 'file info' (v:%d)", fFileInfoVrs);
97  Info("SetSendOptions", "%s", snot.Data());
98 
99  // Done
100  return 0;
101 }
102 
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
Int_t SetSendOptions(const char *)
Parse send options from string 'sendopts'.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
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 SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
const char * Data() const
Definition: TString.h:349
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2334
#define PDB(mask, level)
Definition: TProofDebug.h:58
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1964
SVector< double, 2 > v
Definition: Dict.h:5
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
Bool_t IsNull() const
Definition: TString.h:387
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
int Ssiz_t
Definition: RtypesCore.h:63
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1806
char Char_t
Definition: RtypesCore.h:29
void ResetBit(UInt_t f)
Definition: TObject.h:172
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904