| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# StatusCode Class Reference

`#include <GaudiKernel/StatusCode.h>`

Collaboration diagram for StatusCode:

[legend]

List of all members.

## Detailed Description

This class is used for returning status codes from appropriate routines.

Author:
  Iain Last

  Pere Mato

  Sebastien Ponce

Definition at line 24 of file StatusCode.h.

## Public Types
enum | { FAILURE = 0, SUCCESS = 1, RECOVERABLE = 2 }
## Public Member Functions
| StatusCode ()
| Constructor.
| StatusCode (unsigned long code, const IssueSeverity &)
| StatusCode (unsigned long code, bool checked=false)
| StatusCode (const StatusCode &sc)
| ~StatusCode ()
| Destructor.
bool | isSuccess () const
| Test for a status code of SUCCESS.
bool | isFailure () const
| Test for a status code of FAILURE.
bool | isRecoverable () const
unsigned long | getCode () const
| Get the status code by value.
void | setCode (unsigned long)
| Set the status code by value.
void | setChecked () const
| Ignore the checking code;.
void | ignore () const
| operator unsigned long () const
| Cast operator.
const IssueSeverity & | severity () const
| Severity.
StatusCode & | operator= (unsigned long value)
| Assignment operator.
StatusCode & | operator= (const StatusCode &rhs)
| operator IgnoreError () const
## Static Public Member Functions
static void | enableChecking ()
static void | disableChecking ()
## Static Protected Member Functions
static IssueSeverity * | cloneSeverity (const IssueSeverity *)
## Protected Attributes
unsigned long | d_code
| The status code.
bool | m_checked
| If the Status code has been checked.
IssueSeverity * | m_severity
| Pointer to a IssueSeverity.
## Static Protected Attributes
static bool | s_checking
| Global flag to control if StatusCode need to be checked.
## Friends
bool | operator< (const StatusCode &a, const StatusCode &b)
| Comparison operator.
bool | operator> (const StatusCode &a, const StatusCode &b)
| Comparison operator.

## Member Enumeration Documentation

anonymous enum

Enumerator:

  FAILURE |
  SUCCESS |
  RECOVERABLE |

Definition at line 26 of file StatusCode.h.

    00026        {
    00027     FAILURE = 0,
    00028     SUCCESS = 1,
    00029     RECOVERABLE = 2
    00030   };

## Constructor & Destructor Documentation

StatusCode::StatusCode | ( |  | ) | `[inline]`

Constructor.

Definition at line 102 of file StatusCode.h.

    00102                              :
    00103   d_code(SUCCESS), m_checked(false), m_severity(0) {}

StatusCode::StatusCode | ( | unsigned long | code,
|  | const IssueSeverity & | sev |
| ) |  |  | `[inline]`

Definition at line 108 of file StatusCode.h.

    00108                                                                             :
    00109   d_code(code),m_checked(false), m_severity(cloneSeverity(&sev)) {
    00110 }

StatusCode::StatusCode | ( | unsigned long | code,
|  | bool | checked = `false` |
| ) |  |  | `[inline]`

Definition at line 105 of file StatusCode.h.

    00105                                                                 :
    00106   d_code(code),m_checked(checked), m_severity(0) {}

StatusCode::StatusCode | ( | const StatusCode & | sc | ) | `[inline]`

Definition at line 112 of file StatusCode.h.

    00112                                                      {
    00113   d_code = rhs.d_code;
    00114   m_checked = rhs.m_checked;
    00115   rhs.m_checked = true;
    00116   m_severity = rhs.m_severity ? cloneSeverity(rhs.m_severity) : 0;
    00117 }

StatusCode::~StatusCode | ( |  | ) |

Destructor.

: (MCl) use backTrace(std::string&, const int, const int) instead

Definition at line 38 of file StatusCode.cpp.

    00038                         {
    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 }

## Member Function Documentation

bool StatusCode::isSuccess | ( |  | ) | const`[inline]`

Test for a status code of SUCCESS.

N.B. This is the only case where a function has succeeded.

Definition at line 129 of file StatusCode.h.

    00129                                         {
    00130   m_checked = true;
    00131   return (d_code == SUCCESS );
    00132 }

bool StatusCode::isFailure | ( |  | ) | const`[inline]`

Test for a status code of FAILURE.

N.B. This is a specific type of failure where there aren't any more appropriate staus codes. To test for any failure use : if ( !StatusCode.isSuccess() ) ...

Definition at line 134 of file StatusCode.h.

    00134                                         {
    00135   m_checked = true;
    00136   return (d_code != SUCCESS );
    00137 }

bool StatusCode::isRecoverable | ( |  | ) | const`[inline]`

Definition at line 139 of file StatusCode.h.

    00139                                             {
    00140   m_checked = true;
    00141   return (d_code == RECOVERABLE);
    00142 }

unsigned long StatusCode::getCode | ( |  | ) | const`[inline]`

Get the status code by value.

Definition at line 144 of file StatusCode.h.

    00144                                                {
    00145   m_checked = true;
    00146   return d_code;
    00147 }

void StatusCode::setCode | ( | unsigned long | value | ) | `[inline]`

Set the status code by value.

Definition at line 149 of file StatusCode.h.

    00149                                                    {
    00150   m_checked = false;
    00151   d_code = value;
    00152 }

void StatusCode::setChecked | ( |  | ) | const`[inline]`

Ignore the checking code;.

Definition at line 154 of file StatusCode.h.

    00154                                          {
    00155   m_checked = true;
    00156 }

void StatusCode::ignore | ( |  | ) | const`[inline]`

Definition at line 158 of file StatusCode.h.

    00158                                      {
    00159   m_checked = true;
    00160 }

StatusCode::operator unsigned long | ( |  | ) | const`[inline]`

Cast operator.

Definition at line 162 of file StatusCode.h.

    00162                                                  {
    00163   m_checked = true;
    00164   return d_code;
    00165 }

const IssueSeverity & StatusCode::severity | ( |  | ) | const

Severity.

Definition at line 32 of file StatusCode.cpp.

    00032                                                 {
    00033   static IssueSeverity dummy;
    00034   if (m_severity) return *m_severity;
    00035   else            return dummy;
    00036 }

StatusCode & StatusCode::operator= | ( | unsigned long | value | ) | `[inline]`

Assignment operator.

Definition at line 167 of file StatusCode.h.

    00167                                                               {
    00168   d_code = value;
    00169   m_checked = false;
    00170   return *this;
    00171 }

StatusCode & StatusCode::operator= | ( | const StatusCode & | rhs | ) | `[inline]`

Definition at line 119 of file StatusCode.h.

    00119                                                               {
    00120   if (this == &rhs) return *this; // Protection against self-assignment
    00121   d_code = rhs.d_code;
    00122   m_checked = rhs.m_checked;
    00123   rhs.m_checked = true;
    00124   if (m_severity) delete m_severity;
    00125   m_severity = rhs.m_severity ? cloneSeverity(rhs.m_severity): 0;
    00126   return *this;
    00127 }

StatusCode::operator IgnoreError | ( |  | ) | const`[inline]`

Definition at line 82 of file StatusCode.h.

    00082                                {
    00083     m_checked = true;
    00084     return IgnoreError();
    00085   }

void StatusCode::enableChecking | ( |  | ) | `[static]`

Definition at line 18 of file StatusCode.cpp.

    00018                                 {
    00019   s_checking = true;
    00020 }

void StatusCode::disableChecking | ( |  | ) | `[static]`

Definition at line 22 of file StatusCode.cpp.

    00022                                  {
    00023   s_checking = false;
    00024 }

IssueSeverity * StatusCode::cloneSeverity | ( | const IssueSeverity * | sev | ) | `[static, protected]`

Definition at line 26 of file StatusCode.cpp.

    00027 {
    00028   if( sev ) return new IssueSeverity(*sev);
    00029   else      return 0;
    00030 }

## Friends And Related Function Documentation

bool operator< | ( | const StatusCode & | a,
|  | const StatusCode & | b |
| ) |  |  | `[friend]`

Comparison operator.

Definition at line 173 of file StatusCode.h.

    00173                                                                    {
    00174   return a.d_code < b.d_code;
    00175 }

bool operator> | ( | const StatusCode & | a,
|  | const StatusCode & | b |
| ) |  |  | `[friend]`

Comparison operator.

Definition at line 177 of file StatusCode.h.

    00177                                                                    {
    00178   return a.d_code > b.d_code;
    00179 }

## Member Data Documentation

unsigned long StatusCode::d_code`[protected]`

The status code.

The status code

Definition at line 93 of file StatusCode.h.

bool StatusCode::m_checked`[mutable, protected]`

If the Status code has been checked.

Definition at line 94 of file StatusCode.h.

IssueSeverity* StatusCode::m_severity`[protected]`

Pointer to a IssueSeverity.

Definition at line 95 of file StatusCode.h.

bool StatusCode::s_checking`[static, protected]`

Global flag to control if StatusCode need to be checked.

Definition at line 97 of file StatusCode.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiKernel/GaudiKernel/StatusCode.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiKernel/src/Lib/StatusCode.cpp