Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 /** \class TProofMonSender
14 \ingroup proofkernel
15 
16 Provides the interface for PROOF monitoring to different writers.
17 Allows to decouple the information sent from the backend.
18 
19 */
20 
21 #include "TProofDebug.h"
22 #include "TProofMonSender.h"
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Parse send options from string 'sendopts'.
26 /// Format is:
27 /// "[-,+]S[n]|[-,+]D[m]|[-,+]F[j]"
28 /// where:
29 /// 1. The big letter refers to the 'table' following
30 ///
31 /// S table with summary log
32 /// D table with dataset info
33 /// F table files info
34 ///
35 /// 2. The '-,+' in front disables/enables the related table; if
36 /// absent '+' is assumed
37 ///
38 /// 3. The number after the letter is the version of the related
39 /// table
40 ///
41 /// Returns -1 if nothing is enabled; 0 otherwise
42 
43 Int_t TProofMonSender::SetSendOptions(const char *sendopts)
44 {
45 
46  // Must have something to parse
47  if (sendopts && strlen(sendopts) > 0) {
48 
49  PDB(kMonitoring,1) Info("SetSendOptions", "sendopts: '%s'", sendopts);
50 
51  Bool_t doit = kTRUE;
52  Char_t t = 0;
53  Int_t v = -1;
54  TString oos(sendopts), oo;
55  Ssiz_t from = 0;
56  while (oos.Tokenize(oo, from, ":")) {
57  PDB(kMonitoring,2) Info("SetSendOptions", "oo: '%s'", oo.Data());
58  // Parse info
59  doit = kTRUE;
60  if (oo.BeginsWith("+")) oo.Remove(0,1);
61  if (oo.BeginsWith("-")) { doit = kFALSE; oo.Remove(0,1); }
62  PDB(kMonitoring,2) Info("SetSendOptions", "oo: '%s' doit:%d", oo.Data(), doit);
63  t = oo[0];
64  oo.Remove(0,1);
65  PDB(kMonitoring,2) Info("SetSendOptions", "oo: '%s' doit:%d t:'%c'", oo.Data(), doit, t);
66  v = -1;
67  if (!oo.IsNull() && oo.IsDigit()) v = oo.Atoi();
68  PDB(kMonitoring,2) Info("SetSendOptions", "oo: '%s' doit:%d t:'%c' v:%d", oo.Data(), doit, t, v);
69  // Fill relevant variables
70  TProofMonSender::EConfigBits cbit = kSendSummary;
71  if (t == 'D') cbit = kSendDataSetInfo;
72  if (t == 'F') cbit = kSendFileInfo;
73  if (doit)
74  SetBit(cbit);
75  else
76  ResetBit(cbit);
77  if (v > -1) {
78  if (t == 'S') fSummaryVrs = v;
79  if (t == 'D') fDataSetInfoVrs = v;
80  if (t == 'F') fFileInfoVrs = v;
81  }
82  }
83  }
84 
85  // Something must be enabled
86  if (!(TestBit(kSendSummary) || TestBit(kSendDataSetInfo) || TestBit(kSendFileInfo))) {
87  Warning("SetSendOptions", "all tables are disabled!");
88  return -1;
89  }
90 
91  // Notify
92  TString snot = TString::Format("%s: sending:", GetTitle());
93  if (TestBit(kSendSummary)) snot += TString::Format(" 'summary' (v:%d)", fSummaryVrs);
94  if (TestBit(kSendDataSetInfo)) snot += TString::Format(" 'dataset info' (v:%d)", fDataSetInfoVrs);
95  if (TestBit(kSendFileInfo)) snot += TString::Format(" 'file info' (v:%d)", fFileInfoVrs);
96  Info("SetSendOptions", "%s", snot.Data());
97 
98  // Done
99  return 0;
100 }
101