Gaudi Framework, version v21r7

Home   Generated: 22 Jan 2010

StatusCodeSvc Class Reference

#include <StatusCodeSvc.h>

Inheritance diagram for StatusCodeSvc:

Inheritance graph
[legend]
Collaboration diagram for StatusCodeSvc:

Collaboration graph
[legend]

List of all members.

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 filterFnc (std::string)

Private Attributes

StringArrayProperty m_pFilter
BooleanProperty m_abort
BooleanProperty m_suppress
std::map< std::string,
StatCodeDat
m_dat
std::set< std::stringm_filter

Friends

class SvcFactory< StatusCodeSvc >

Classes

struct  StatCodeDat


Detailed Description

Definition at line 14 of file StatusCodeSvc.h.


Constructor & Destructor Documentation

StatusCodeSvc::StatusCodeSvc ( const std::string name,
ISvcLocator svc 
)

Definition at line 15 of file StatusCodeSvc.cpp.

00016   : base_class( name, svc )
00017 {
00018 
00019   declareProperty("Filter",m_pFilter);
00020   declareProperty("AbortOnError",m_abort=false);
00021   declareProperty("SuppressCheck", m_suppress=false);
00022 
00023 }

StatusCodeSvc::~StatusCodeSvc (  )  [virtual]

Definition at line 27 of file StatusCodeSvc.cpp.

00027                               {
00028 
00029 }


Member Function Documentation

StatusCode StatusCodeSvc::initialize (  )  [virtual]

Reimplemented from Service.

Definition at line 35 of file StatusCodeSvc.cpp.

00035                           {
00036 
00037   StatusCode sc = Service::initialize();
00038   if (!sc.isSuccess()) return sc;
00039 
00040   MsgStream log( msgSvc(), name() );
00041   log << MSG::INFO << "initialize" << endmsg;
00042 
00043   std::vector<std::string>::const_iterator itr;
00044   for (itr = m_pFilter.value().begin(); itr != m_pFilter.value().end(); ++itr) {
00045     // we need to do this if someone has gotten to regFnc before initialize
00046     filterFnc(*itr);
00047 
00048     m_filter.insert(*itr);
00049   }
00050 
00051   return StatusCode::SUCCESS;
00052 
00053 }

StatusCode StatusCodeSvc::reinitialize (  )  [virtual]

Reimplemented from Service.

Definition at line 58 of file StatusCodeSvc.cpp.

00058                             {
00059 
00060   MsgStream log( msgSvc(), name() );
00061   log << MSG::INFO << "reinitialize" << endmsg;
00062 
00063   return StatusCode::SUCCESS;
00064 
00065 }

StatusCode StatusCodeSvc::finalize ( void   )  [virtual]

Reimplemented from Service.

Definition at line 69 of file StatusCodeSvc.cpp.

00069                         {
00070 
00071   if (m_dat.size() > 0) {
00072     MsgStream log( msgSvc(), name() );
00073 
00074     log << MSG::INFO << "listing all unchecked return codes:" << endmsg;
00075 
00076     list();
00077 
00078   }
00079 
00080   return StatusCode::SUCCESS;
00081 
00082 }

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

Implements IStatusCodeSvc.

Definition at line 89 of file StatusCodeSvc.cpp.

00089                                                                 {
00090 
00091   if (m_state == Gaudi::StateMachine::OFFLINE ||
00092       m_state == Gaudi::StateMachine::CONFIGURED) {
00093     return;
00094   }
00095 
00096   if (m_filter.find(fnc) != m_filter.end()) {
00097     return;
00098   }
00099 
00100   if (m_abort) {
00101     MsgStream log( msgSvc(), name() );
00102     log << MSG::FATAL << "Unchecked StatusCode in " << fnc << " from lib "
00103         << lib << endmsg;
00104     abort();
00105   }
00106 
00107   string key = fnc + lib;
00108 
00109   map<string,StatCodeDat>::iterator itr = m_dat.find(key);
00110 
00111   if (itr != m_dat.end()) {
00112     itr->second.count += 1;
00113   } else {
00114 
00115     int i1 = lib.rfind("/",lib.length());
00116     string rlib = lib.substr(i1+1,lib.length()-i1-1);
00117 
00118     StatCodeDat dat;
00119     dat.fnc = fnc;
00120     dat.lib = rlib;
00121     dat.count = 1;
00122 
00123     m_dat[key] = dat;
00124   }
00125 
00126 }

void StatusCodeSvc::list (  )  const [virtual]

Implements IStatusCodeSvc.

Definition at line 131 of file StatusCodeSvc.cpp.

00131                           {
00132 
00133   MsgStream log( msgSvc(), name() );
00134   log << MSG::INFO << endl;
00135 
00136   map<string,StatCodeDat>::const_iterator itr;
00137 
00138 #if defined (__GNUC__) && ( __GNUC__ <= 2 )
00139   std::ostrstream os;
00140 #else
00141   std::ostringstream os;
00142 #endif
00143 
00144   os << "Num | Function                       | Source Library" << endl;
00145   os << "----+--------------------------------+-------------------"
00146      << "-----------------------" << endl;
00147 
00148 
00149   for(itr = m_dat.begin(); itr != m_dat.end(); ++itr ) {
00150     StatCodeDat dat = itr->second;
00151 
00152     os.width(3);
00153     os.setf(ios_base::right,ios_base::adjustfield);
00154     os << dat.count;
00155 
00156     os << " | ";
00157     os.width(30);
00158     os.setf(ios_base::left,ios_base::adjustfield);
00159     os << dat.fnc;
00160 
00161     os << " | ";
00162     os.setf(ios_base::left,ios_base::adjustfield);
00163     os << dat.lib;
00164 
00165     os << endl;
00166 
00167   }
00168 
00169 
00170   log << os.str() << endmsg;
00171 
00172 }

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

Implements IStatusCodeSvc.

Definition at line 24 of file StatusCodeSvc.h.

00024 { return m_suppress.value() ; }

void StatusCodeSvc::filterFnc ( std::string  str  )  [private]

Definition at line 177 of file StatusCodeSvc.cpp.

00177                                       {
00178 
00179   std::map<std::string, StatCodeDat>::iterator itr;
00180   for (itr = m_dat.begin(); itr != m_dat.end(); ++itr ) {
00181     if (itr->second.fnc == str) {
00182       m_dat.erase(itr);
00183       return;
00184     }
00185 
00186   }
00187 
00188 }


Friends And Related Function Documentation

friend class SvcFactory< StatusCodeSvc > [friend]

Definition at line 43 of file StatusCodeSvc.h.


Member Data Documentation

Definition at line 45 of file StatusCodeSvc.h.

Definition at line 46 of file StatusCodeSvc.h.

Definition at line 47 of file StatusCodeSvc.h.

Definition at line 49 of file StatusCodeSvc.h.

Definition at line 50 of file StatusCodeSvc.h.


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

Generated at Fri Jan 22 20:42:27 2010 for Gaudi Framework, version v21r7 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004