Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StatusCodeSvc.cpp
Go to the documentation of this file.
1 #include "StatusCodeSvc.h"
5 
6 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7 
8 using namespace std;
9 //
11 //
12 inline void toupper(std::string &s)
13 {
14  std::transform(s.begin(), s.end(), s.begin(),
15  (int(*)(int)) toupper);
16 }
17 
19  : base_class( name, svc )
20 {
21 
22  declareProperty("Filter",m_pFilter);
23  declareProperty("AbortOnError",m_abort=false);
24  declareProperty("SuppressCheck", m_suppress=false);
25  declareProperty("IgnoreDicts",m_dict=true);
26 
27 }
28 
29 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
30 
32 
33 }
34 
35 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
36 
37 
40 
42  if (!sc.isSuccess()) return sc;
43 
44  MsgStream log( msgSvc(), name() );
45  log << MSG::INFO << "initialize" << endmsg;
46 
48  for (itr = m_pFilter.value().begin(); itr != m_pFilter.value().end(); ++itr) {
49  // we need to do this if someone has gotten to regFnc before initialize
50 
51  string fnc,lib;
52  parseFilter(*itr,fnc,lib);
53 
54  if (fnc != "") {
55  filterFnc(fnc);
56  m_filterfnc.insert(fnc);
57  }
58 
59  if (lib != "") {
60  filterLib(lib);
61  m_filterlib.insert(lib);
62  }
63 
64  }
65 
66  return StatusCode::SUCCESS;
67 
68 }
69 
70 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
71 
74 
75  MsgStream log( msgSvc(), name() );
76  log << MSG::INFO << "reinitialize" << endmsg;
77 
78  return StatusCode::SUCCESS;
79 
80 }
81 
82 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
85 
86  if (m_dat.size() > 0) {
87  MsgStream log( msgSvc(), name() );
88 
89  log << MSG::INFO << "listing all unchecked return codes:" << endmsg;
90 
91  list();
92 
93  }
94 
95  return StatusCode::SUCCESS;
96 
97 }
98 
99 
100 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
101 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
102 
103 void
105 
108  return;
109  }
110 
111  if (m_dict && lib.rfind("Dict.so") == (lib.length()-7) ) {
112  return;
113  }
114 
115  {
116  const string rlib = lib.substr(lib.rfind("/") + 1);
117 
118  if (m_filterfnc.find(fnc) != m_filterfnc.end() ||
119  m_filterlib.find(rlib) != m_filterlib.end() ) {
120  return;
121  }
122  }
123 
124  if (m_abort) {
125  MsgStream log( msgSvc(), name() );
126  log << MSG::FATAL << "Unchecked StatusCode in " << fnc << " from lib "
127  << lib << endmsg;
128  abort();
129  }
130 
131  string key = fnc + lib;
132 
134 
135  if (itr != m_dat.end()) {
136  itr->second.count += 1;
137  } else {
138 
139  const string rlib = lib.substr(lib.rfind("/") + 1);
140 
141  StatCodeDat dat;
142  dat.fnc = fnc;
143  dat.lib = rlib;
144  dat.count = 1;
145 
146  m_dat[key] = dat;
147  }
148 
149 }
150 
151 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
152 
153 void
155 
156  MsgStream log( msgSvc(), name() );
157  log << MSG::INFO << endl;
158 
160 
161 #if defined (__GNUC__) && ( __GNUC__ <= 2 )
162  std::ostrstream os;
163 #else
165 #endif
166 
167  os << "Num | Function | Source Library" << endl;
168  os << "----+--------------------------------+-------------------"
169  << "-----------------------" << endl;
170 
171 
172  for(itr = m_dat.begin(); itr != m_dat.end(); ++itr ) {
173  StatCodeDat dat = itr->second;
174 
175  os.width(3);
176  os.setf(ios_base::right,ios_base::adjustfield);
177  os << dat.count;
178 
179  os << " | ";
180  os.width(30);
181  os.setf(ios_base::left,ios_base::adjustfield);
182  os << dat.fnc;
183 
184  os << " | ";
185  os.setf(ios_base::left,ios_base::adjustfield);
186  os << dat.lib;
187 
188  os << endl;
189 
190  }
191 
192 
193  log << os.str() << endmsg;
194 
195 }
196 
197 
198 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
199 void
201 
203  for (itr = m_dat.begin(); itr != m_dat.end(); ++itr ) {
204  if (itr->second.fnc == str) {
205  m_dat.erase(itr);
206  return;
207  }
208 
209  }
210 
211 }
212 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
213 
214 void
216 
218  for (itr = m_dat.begin(); itr != m_dat.end(); ++itr ) {
219  if (itr->second.lib == str) {
220  m_dat.erase(itr);
221  return;
222  }
223 
224  }
225 
226 }
227 
228 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
229 
230 void
231 StatusCodeSvc::parseFilter(const string& str, string& fnc, string& lib) {
232 
233 
234  string::size_type loc = str.find("=");
235  if (loc == std::string::npos) {
236  fnc = str;
237  lib = "";
238  } else {
239  string key,val;
240  key = str.substr(0,loc);
241  val = str.substr(loc+1,str.length()-loc-1);
242 
243  toupper(key);
244 
245  if (key == "FCN" || key == "FNC") {
246  fnc = val;
247  lib = "";
248  } else if (key == "LIB") {
249  fnc = "";
250  lib = val;
251  } else {
252  fnc = "";
253  lib = "";
254 
255  MsgStream log( msgSvc(), name() );
256  log << MSG::WARNING << "ignoring unknown token in Filter: " << str
257  << endmsg;
258  }
259  }
260 
261 }
262 
263 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
264 

Generated at Wed Nov 28 2012 12:17:11 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004