| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# StatusCode.cpp

Go to the documentation of this file.

    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 const IssueSeverity& StatusCode::severity() const {
    00027   static IssueSeverity dummy;
    00028   if (m_severity) return *m_severity;
    00029   else            return dummy;
    00030 }
    00031
    00032 StatusCode::~StatusCode() {
    00033   if(s_checking) {
    00034
    00035     if (!m_checked ) {
    00036
    00037       SmartIF<IMessageSvc> msg(Gaudi::svcLocator());
    00038
    00039       SmartIF<IStatusCodeSvc> scs(Gaudi::svcLocator()->service("StatusCodeSvc"));
    00040
    00041       const size_t depth = 21;
    00042       void* addresses[depth];
    00043
    00044       std::string lib, fnc;
    00045       void* addr = 0;
    00047       if (System::backTrace(addresses, depth)) {
    00048
    00049         if (System::getStackLevel(addresses[2], addr, fnc, lib)) {
    00050
    00051           if (scs) {
    00052             scs->regFnc(fnc,lib);
    00053           } else {
    00054             if (msg) {
    00055               MsgStream log(msg,"StatusCode");
    00056               log << MSG::WARNING << "Unchecked in " << fnc << " " << lib << endmsg;
    00057             } else {
    00058               std::cout << MSG::WARNING << "Unchecked in " << fnc << " " << lib << std::endl;
    00059             }
    00060           }
    00061
    00062         }
    00063
    00064       }
    00065     }
    00066   }
    00067 }
    00068