Gaudi Framework, version v25r0

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

Generated at Mon Feb 17 2014 14:37:40 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004