![]() |
|
|
Generated: 24 Nov 2008 |
00001 #define GAUDIKERNEL_STATUSCODE_CPP 1 00002 00003 #include "GaudiKernel/StatusCode.h" 00004 #include "GaudiKernel/System.h" 00005 #include "GaudiKernel/Bootstrap.h" 00006 #include "GaudiKernel/IMessageSvc.h" 00007 #include "GaudiKernel/IStatusCodeSvc.h" 00008 #include "GaudiKernel/ISvcLocator.h" 00009 #include "GaudiKernel/MsgStream.h" 00010 #include "GaudiKernel/IssueSeverity.h" 00011 #include <fstream> 00012 #include <iostream> 00013 #include <sstream> 00014 #include <stdlib.h> 00015 00016 bool StatusCode::s_checking(false); 00017 00018 void StatusCode::enableChecking() { 00019 s_checking = true; 00020 } 00021 00022 void StatusCode::disableChecking() { 00023 s_checking = false; 00024 } 00025 00026 IssueSeverity* StatusCode::cloneSeverity(const IssueSeverity* sev) 00027 { 00028 if( sev ) return new IssueSeverity(*sev); 00029 else return 0; 00030 } 00031 00032 const IssueSeverity& StatusCode::severity() const { 00033 static IssueSeverity dummy; 00034 if (m_severity) return *m_severity; 00035 else return dummy; 00036 } 00037 00038 StatusCode::~StatusCode() { 00039 if(s_checking) { 00040 00041 if (!m_checked ) { 00042 00043 IMessageSvc* msg = 0 ; 00044 if(Gaudi::svcLocator()->service("MessageSvc", msg, true).isFailure()) { 00045 msg = 0 ; // one cannot rely on the returned value on the previous line 00046 } 00047 00048 IStatusCodeSvc *scs = 0 ; 00049 if (Gaudi::svcLocator()->service("StatusCodeSvc",scs,true).isFailure()) { 00050 scs = 0 ; // one cannot rely on the returned value on the previous line 00051 } 00052 00053 const size_t depth = 21; 00054 void* addresses[depth]; 00055 00056 std::string lib, fnc; 00057 void* addr = 0; 00059 if (System::backTrace(addresses, depth)) { 00060 00061 if (System::getStackLevel(addresses[2], addr, fnc, lib)) { 00062 00063 if (scs) { 00064 scs->regFnc(fnc,lib); 00065 } else { 00066 if (msg) { 00067 MsgStream log(msg,"StatusCode"); 00068 log << MSG::WARNING << "Unchecked in " << fnc << " " << lib << endmsg; 00069 } else { 00070 std::cout << MSG::WARNING << "Unchecked in " << fnc << " " << lib << std::endl; 00071 } 00072 } 00073 00074 } 00075 00076 } 00077 if (msg) msg->release(); 00078 if (scs) scs->release(); 00079 } 00080 } 00081 if (m_severity) delete m_severity; 00082 } 00083