| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends

# StatusCodeSvc Class Reference

`#include <StatusCodeSvc.h>`

Inheritance diagram for StatusCodeSvc:
[legend]
Collaboration diagram for StatusCodeSvc:
[legend]

List of all members.

## Classes
struct | StatCodeDat
## 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 >

## Detailed Description

Definition at line 14 of file StatusCodeSvc.h.

## Constructor & Destructor Documentation

StatusCodeSvc::StatusCodeSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

Definition at line 18 of file StatusCodeSvc.cpp.

      : base_class( name, svc )
    {

      declareProperty("Filter",m_pFilter);
      declareProperty("AbortOnError",m_abort=false);
      declareProperty("SuppressCheck", m_suppress=false);
      declareProperty("IgnoreDicts",m_dict=true);

    }

StatusCodeSvc::~StatusCodeSvc | ( | ) | `[virtual]`

Definition at line 31 of file StatusCodeSvc.cpp.

                                  {

    }

## Member Function Documentation

void StatusCodeSvc::filterFnc | ( | const std::string & | str ) | `[private]`

Definition at line 200 of file StatusCodeSvc.cpp.

                                                 {

      std::map<std::string, StatCodeDat>::iterator itr;
      for (itr = m_dat.begin(); itr != m_dat.end(); ++itr ) {
        if (itr->second.fnc == str) {
          m_dat.erase(itr);
          return;
        }

      }

    }

void StatusCodeSvc::filterLib | ( | const std::string & | str ) | `[private]`

Definition at line 215 of file StatusCodeSvc.cpp.

                                                 {

      std::map<std::string, StatCodeDat>::iterator itr;
      for (itr = m_dat.begin(); itr != m_dat.end(); ++itr ) {
        if (itr->second.lib == str) {
          m_dat.erase(itr);
          return;
        }

      }

    }

StatusCode StatusCodeSvc::finalize | ( | void | ) | `[virtual]`

Reimplemented from Service.

Definition at line 84 of file StatusCodeSvc.cpp.

                            {

      if (m_dat.size() > 0) {
        MsgStream log( msgSvc(), name() );

        log << MSG::INFO << "listing all unchecked return codes:" << endmsg;

        list();

      }

      return StatusCode::SUCCESS;

    }

StatusCode StatusCodeSvc::initialize | ( | ) | `[virtual]`

Reimplemented from Service.

Definition at line 39 of file StatusCodeSvc.cpp.

                              {

      StatusCode sc = Service::initialize();
      if (!sc.isSuccess()) return sc;

      MsgStream log( msgSvc(), name() );
      log << MSG::INFO << "initialize" << endmsg;

      std::vector<std::string>::const_iterator itr;
      for (itr = m_pFilter.value().begin(); itr != m_pFilter.value().end(); ++itr) {
        // we need to do this if someone has gotten to regFnc before initialize

        string fnc,lib;
        parseFilter(*itr,fnc,lib);

        if (fnc != "") {
          filterFnc(fnc);
          m_filterfnc.insert(fnc);
        }

        if (lib != "") {
          filterLib(lib);
          m_filterlib.insert(lib);
        }

      }

      return StatusCode::SUCCESS;

    }

void StatusCodeSvc::list | ( | ) | const`[virtual]`

Implements IStatusCodeSvc.

Definition at line 154 of file StatusCodeSvc.cpp.

                              {

      MsgStream log( msgSvc(), name() );
      log << MSG::INFO << endl;

      map<string,StatCodeDat>::const_iterator itr;

    #if defined (__GNUC__) && ( __GNUC__ <= 2 )
      std::ostrstream os;
    #else
      std::ostringstream os;
    #endif

      os << "Num | Function                       | Source Library" << endl;
      os << "----+--------------------------------+-------------------"
         << "-----------------------" << endl;

      for(itr = m_dat.begin(); itr != m_dat.end(); ++itr ) {
        StatCodeDat dat = itr->second;

        os.width(3);
        os.setf(ios_base::right,ios_base::adjustfield);
        os << dat.count;

        os << " | ";
        os.width(30);
        os.setf(ios_base::left,ios_base::adjustfield);
        os << dat.fnc;

        os << " | ";
        os.setf(ios_base::left,ios_base::adjustfield);
        os << dat.lib;

        os << endl;

      }

      log << os.str() << endmsg;

    }

void StatusCodeSvc::parseFilter | ( | const std::string & | str,
|  | std::string & | fnc,
|  | std::string & | lib
| ) |  | `[private]`

Definition at line 231 of file StatusCodeSvc.cpp.

                                                                          {

      string::size_type loc = str.find("=");
      if (loc == std::string::npos) {
        fnc = str;
        lib = "";
      } else {
        string key,val;
        key = str.substr(0,loc);
        val = str.substr(loc+1,str.length()-loc-1);

        toupper(key);

        if (key == "FCN" || key == "FNC") {
          fnc = val;
          lib = "";
        } else if (key == "LIB") {
          fnc = "";
          lib = val;
        } else {
          fnc = "";
          lib = "";

          MsgStream log( msgSvc(), name() );
          log << MSG::WARNING << "ignoring unknown token in Filter: " << str
              << endmsg;
        }
      }

    }

void StatusCodeSvc::regFnc | ( | const std::string & | func,
|  | const std::string & | lib
| ) |  | `[virtual]`

Implements IStatusCodeSvc.

Definition at line 104 of file StatusCodeSvc.cpp.

                                                                    {

      if (m_state == Gaudi::StateMachine::OFFLINE ||
          m_state == Gaudi::StateMachine::CONFIGURED) {
        return;
      }

      if (m_dict && lib.rfind("Dict.so") == (lib.length()-7) ) {
        return;
      }

      {
        const string rlib = lib.substr(lib.rfind("/") + 1);

        if (m_filterfnc.find(fnc) != m_filterfnc.end() ||
            m_filterlib.find(rlib) != m_filterlib.end() ) {
          return;
        }
      }

      if (m_abort) {
        MsgStream log( msgSvc(), name() );
        log << MSG::FATAL << "Unchecked StatusCode in " << fnc << " from lib "
            << lib << endmsg;
        abort();
      }

      string key = fnc + lib;

      map<string,StatCodeDat>::iterator itr = m_dat.find(key);

      if (itr != m_dat.end()) {
        itr->second.count += 1;
      } else {

        const string rlib = lib.substr(lib.rfind("/") + 1);

        StatCodeDat dat;
        dat.fnc = fnc;
        dat.lib = rlib;
        dat.count = 1;

        m_dat[key] = dat;
      }

    }

StatusCode StatusCodeSvc::reinitialize | ( | ) | `[virtual]`

Reimplemented from Service.

Definition at line 73 of file StatusCodeSvc.cpp.

                                {

      MsgStream log( msgSvc(), name() );
      log << MSG::INFO << "reinitialize" << endmsg;

      return StatusCode::SUCCESS;

    }

virtual bool StatusCodeSvc::suppressCheck | ( | ) | const`[inline, virtual]`

Implements IStatusCodeSvc.

Definition at line 24 of file StatusCodeSvc.h.

    { return m_suppress.value() ; }

## Friends And Related Function Documentation

friend class SvcFactory< StatusCodeSvc >`[friend]`

Definition at line 45 of file StatusCodeSvc.h.

## Member Data Documentation

BooleanProperty StatusCodeSvc::m_abort`[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.

BooleanProperty StatusCodeSvc::m_dict`[private]`

Definition at line 48 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.

StringArrayProperty StatusCodeSvc::m_pFilter`[private]`

Definition at line 47 of file StatusCodeSvc.h.

BooleanProperty StatusCodeSvc::m_suppress`[private]`

Definition at line 48 of file StatusCodeSvc.h.

The documentation for this class was generated from the following files:

- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiSvc/src/StatusCodeSvc/StatusCodeSvc.h
- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiSvc/src/StatusCodeSvc/StatusCodeSvc.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines