|
Gaudi Framework, version v21r11 |
| Home | Generated: 30 Sep 2010 |
#include <StatusCodeSvc.h>
Public Member Functions | |
| virtual StatusCode | initialize () |
| virtual StatusCode | reinitialize () |
| virtual StatusCode | finalize () |
| virtual void | regFnc (const std::string &func, const std::string &lib) |
| virtual void | list () const |
| virtual bool | suppressCheck () const |
| StatusCodeSvc (const std::string &name, ISvcLocator *svc) | |
| virtual | ~StatusCodeSvc () |
Private Member Functions | |
| void | parseFilter (const std::string &str, std::string &fnc, std::string &lib) |
| void | filterFnc (const std::string &) |
| void | filterLib (const std::string &) |
Private Attributes | |
| StringArrayProperty | m_pFilter |
| BooleanProperty | m_abort |
| BooleanProperty | m_suppress |
| BooleanProperty | m_dict |
| std::map< std::string, StatCodeDat > | m_dat |
| std::set< std::string > | m_filterfnc |
| std::set< std::string > | m_filterlib |
Friends | |
| class | SvcFactory< StatusCodeSvc > |
Classes | |
| struct | StatCodeDat |
Definition at line 14 of file StatusCodeSvc.h.
| StatusCodeSvc::StatusCodeSvc | ( | const std::string & | name, | |
| ISvcLocator * | svc | |||
| ) |
Definition at line 25 of file StatusCodeSvc.cpp.
00026 : base_class( name, svc ) 00027 { 00028 00029 declareProperty("Filter",m_pFilter); 00030 declareProperty("AbortOnError",m_abort=false); 00031 declareProperty("SuppressCheck", m_suppress=false); 00032 declareProperty("IgnoreDicts",m_dict=true); 00033 00034 }
| StatusCodeSvc::~StatusCodeSvc | ( | ) | [virtual] |
| StatusCode StatusCodeSvc::initialize | ( | ) | [virtual] |
Reimplemented from Service.
Definition at line 46 of file StatusCodeSvc.cpp.
00046 { 00047 00048 StatusCode sc = Service::initialize(); 00049 if (!sc.isSuccess()) return sc; 00050 00051 MsgStream log( msgSvc(), name() ); 00052 log << MSG::INFO << "initialize" << endmsg; 00053 00054 std::vector<std::string>::const_iterator itr; 00055 for (itr = m_pFilter.value().begin(); itr != m_pFilter.value().end(); ++itr) { 00056 // we need to do this if someone has gotten to regFnc before initialize 00057 00058 string fnc,lib; 00059 parseFilter(*itr,fnc,lib); 00060 00061 if (fnc != "") { 00062 filterFnc(fnc); 00063 m_filterfnc.insert(fnc); 00064 } 00065 00066 if (lib != "") { 00067 filterLib(lib); 00068 m_filterlib.insert(lib); 00069 } 00070 00071 } 00072 00073 return StatusCode::SUCCESS; 00074 00075 }
| StatusCode StatusCodeSvc::reinitialize | ( | ) | [virtual] |
| StatusCode StatusCodeSvc::finalize | ( | ) | [virtual] |
Reimplemented from Service.
Definition at line 91 of file StatusCodeSvc.cpp.
00091 { 00092 00093 if (m_dat.size() > 0) { 00094 MsgStream log( msgSvc(), name() ); 00095 00096 log << MSG::INFO << "listing all unchecked return codes:" << endmsg; 00097 00098 list(); 00099 00100 } 00101 00102 return StatusCode::SUCCESS; 00103 00104 }
| void StatusCodeSvc::regFnc | ( | const std::string & | func, | |
| const std::string & | lib | |||
| ) | [virtual] |
Implements IStatusCodeSvc.
Definition at line 111 of file StatusCodeSvc.cpp.
00111 { 00112 00113 if (m_state == Gaudi::StateMachine::OFFLINE || 00114 m_state == Gaudi::StateMachine::CONFIGURED) { 00115 return; 00116 } 00117 00118 if (m_dict && lib.rfind("Dict.so") == (lib.length()-7) ) { 00119 return; 00120 } 00121 00122 int i1 = lib.rfind("/",lib.length()); 00123 string rlib = lib.substr(i1+1,lib.length()-i1-1); 00124 00125 00126 if (m_filterfnc.find(fnc) != m_filterfnc.end() || 00127 m_filterlib.find(rlib) != m_filterlib.end() ) { 00128 return; 00129 } 00130 00131 if (m_abort) { 00132 MsgStream log( msgSvc(), name() ); 00133 log << MSG::FATAL << "Unchecked StatusCode in " << fnc << " from lib " 00134 << lib << endmsg; 00135 abort(); 00136 } 00137 00138 string key = fnc + lib; 00139 00140 map<string,StatCodeDat>::iterator itr = m_dat.find(key); 00141 00142 if (itr != m_dat.end()) { 00143 itr->second.count += 1; 00144 } else { 00145 00146 int i1 = lib.rfind("/",lib.length()); 00147 string rlib = lib.substr(i1+1,lib.length()-i1-1); 00148 00149 StatCodeDat dat; 00150 dat.fnc = fnc; 00151 dat.lib = rlib; 00152 dat.count = 1; 00153 00154 m_dat[key] = dat; 00155 } 00156 00157 }
| void StatusCodeSvc::list | ( | ) | const [virtual] |
Implements IStatusCodeSvc.
Definition at line 162 of file StatusCodeSvc.cpp.
00162 { 00163 00164 MsgStream log( msgSvc(), name() ); 00165 log << MSG::INFO << endl; 00166 00167 map<string,StatCodeDat>::const_iterator itr; 00168 00169 #if defined (__GNUC__) && ( __GNUC__ <= 2 ) 00170 std::ostrstream os; 00171 #else 00172 std::ostringstream os; 00173 #endif 00174 00175 os << "Num | Function | Source Library" << endl; 00176 os << "----+--------------------------------+-------------------" 00177 << "-----------------------" << endl; 00178 00179 00180 for(itr = m_dat.begin(); itr != m_dat.end(); ++itr ) { 00181 StatCodeDat dat = itr->second; 00182 00183 os.width(3); 00184 os.setf(ios_base::right,ios_base::adjustfield); 00185 os << dat.count; 00186 00187 os << " | "; 00188 os.width(30); 00189 os.setf(ios_base::left,ios_base::adjustfield); 00190 os << dat.fnc; 00191 00192 os << " | "; 00193 os.setf(ios_base::left,ios_base::adjustfield); 00194 os << dat.lib; 00195 00196 os << endl; 00197 00198 } 00199 00200 00201 log << os.str() << endmsg; 00202 00203 }
| virtual bool StatusCodeSvc::suppressCheck | ( | ) | const [inline, virtual] |
Implements IStatusCodeSvc.
Definition at line 24 of file StatusCodeSvc.h.
00024 { return m_suppress.value() ; }
| void StatusCodeSvc::parseFilter | ( | const std::string & | str, | |
| std::string & | fnc, | |||
| std::string & | lib | |||
| ) | [private] |
Definition at line 239 of file StatusCodeSvc.cpp.
00239 { 00240 00241 00242 string::size_type loc = str.find("="); 00243 if (loc == std::string::npos) { 00244 fnc = str; 00245 lib = ""; 00246 } else { 00247 string key,val; 00248 key = str.substr(0,loc); 00249 val = str.substr(loc+1,str.length()-loc-1); 00250 00251 toupper(key); 00252 00253 if (key == "FCN" || key == "FNC") { 00254 fnc = val; 00255 lib = ""; 00256 } else if (key == "LIB") { 00257 fnc = ""; 00258 lib = val; 00259 } else { 00260 fnc = ""; 00261 lib = ""; 00262 00263 MsgStream log( msgSvc(), name() ); 00264 log << MSG::WARNING << "ignoring unknown token in Filter: " << str 00265 << endmsg; 00266 } 00267 } 00268 00269 }
| void StatusCodeSvc::filterFnc | ( | const std::string & | str | ) | [private] |
Definition at line 208 of file StatusCodeSvc.cpp.
00208 { 00209 00210 std::map<std::string, StatCodeDat>::iterator itr; 00211 for (itr = m_dat.begin(); itr != m_dat.end(); ++itr ) { 00212 if (itr->second.fnc == str) { 00213 m_dat.erase(itr); 00214 return; 00215 } 00216 00217 } 00218 00219 }
| void StatusCodeSvc::filterLib | ( | const std::string & | str | ) | [private] |
Definition at line 223 of file StatusCodeSvc.cpp.
00223 { 00224 00225 std::map<std::string, StatCodeDat>::iterator itr; 00226 for (itr = m_dat.begin(); itr != m_dat.end(); ++itr ) { 00227 if (itr->second.lib == str) { 00228 m_dat.erase(itr); 00229 return; 00230 } 00231 00232 } 00233 00234 }
friend class SvcFactory< StatusCodeSvc > [friend] |
Definition at line 45 of file StatusCodeSvc.h.
StringArrayProperty StatusCodeSvc::m_pFilter [private] |
Definition at line 47 of file StatusCodeSvc.h.
BooleanProperty StatusCodeSvc::m_abort [private] |
Definition at line 48 of file StatusCodeSvc.h.
BooleanProperty StatusCodeSvc::m_suppress [private] |
Definition at line 48 of file StatusCodeSvc.h.
BooleanProperty StatusCodeSvc::m_dict [private] |
Definition at line 48 of file StatusCodeSvc.h.
std::map<std::string,StatCodeDat> StatusCodeSvc::m_dat [private] |
Definition at line 50 of file StatusCodeSvc.h.
std::set<std::string> StatusCodeSvc::m_filterfnc [private] |
Definition at line 51 of file StatusCodeSvc.h.
std::set<std::string> StatusCodeSvc::m_filterlib [private] |
Definition at line 51 of file StatusCodeSvc.h.