All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StatusCode Class Reference

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

#include <GaudiKernel/StatusCode.h>

Classes

class  ScopedDisableChecking
 Simple RAII class to ignore unchecked StatusCode instances in a scope. More...
 

Public Types

enum  { FAILURE = 0, SUCCESS = 1, RECOVERABLE = 2 }
 
enum  { FAILURE = 0, SUCCESS = 1, RECOVERABLE = 2 }
 

Public Member Functions

 StatusCode ()
 Constructor.
 
 StatusCode (unsigned long code, const IssueSeverity &sev)
 
 StatusCode (unsigned long code, bool checked=false)
 
 StatusCode (const StatusCode &rhs)
 
 StatusCode (StatusCode &&rhs)
 Move constructor.
 
 ~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 value)
 Set the status code by value.
 
void setChecked () const
 Ignore the checking code;.
 
void ignore () const
 
 operator unsigned long () const
 Cast operator.
 
GAUDI_API const IssueSeverityseverity () const
 Severity.
 
StatusCodeoperator= (unsigned long value)
 Assignment operator.
 
StatusCodeoperator= (const StatusCode &rhs)
 
 operator IgnoreError () const
 
 StatusCode ()
 Constructor.
 
 StatusCode (unsigned long code, const IssueSeverity &sev)
 
 StatusCode (unsigned long code, bool checked=false)
 
 StatusCode (const StatusCode &rhs)
 
 StatusCode (StatusCode &&rhs)
 Move constructor.
 
 ~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 value)
 Set the status code by value.
 
void setChecked () const
 Ignore the checking code;.
 
void ignore () const
 
 operator unsigned long () const
 Cast operator.
 
GAUDI_API const IssueSeverityseverity () const
 Severity.
 
StatusCodeoperator= (unsigned long value)
 Assignment operator.
 
StatusCodeoperator= (const StatusCode &rhs)
 
 operator IgnoreError () const
 

Static Public Member Functions

static GAUDI_API void enableChecking ()
 
static GAUDI_API void disableChecking ()
 
static GAUDI_API bool checkingEnabled ()
 
static GAUDI_API void enableChecking ()
 
static GAUDI_API void disableChecking ()
 
static GAUDI_API bool checkingEnabled ()
 

Protected Types

typedef boost::shared_ptr
< IssueSeverity
SeverityPtr
 
typedef boost::shared_ptr
< IssueSeverity
SeverityPtr
 

Protected Attributes

unsigned long d_code
 The status code.
 
bool m_checked
 If the Status code has been checked.
 
SeverityPtr m_severity
 Pointer to a IssueSeverity.
 

Static Protected Attributes

static bool s_checking
 Global flag to control if StatusCode need to be checked.
 

Private Member Functions

void check ()
 
void check ()
 

Friends

bool operator< (const StatusCode &a, const StatusCode &b)
 Comparison operator.
 
bool operator> (const StatusCode &a, const StatusCode &b)
 Comparison operator.
 
bool operator< (const StatusCode &a, const StatusCode &b)
 Comparison operator.
 
bool operator> (const StatusCode &a, const StatusCode &b)
 Comparison operator.
 

Detailed Description

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

Author
Iain Last
Pere Mato
Sebastien Ponce

Definition at line 30 of file StatusCode.h.

Member Typedef Documentation

typedef boost::shared_ptr<IssueSeverity> StatusCode::SeverityPtr
protected

Definition at line 186 of file StatusCode.h.

typedef boost::shared_ptr<IssueSeverity> StatusCode::SeverityPtr
protected

Definition at line 186 of file StatusCode.h.

Member Enumeration Documentation

anonymous enum
Enumerator:
FAILURE 
SUCCESS 
RECOVERABLE 

Definition at line 32 of file StatusCode.h.

{
FAILURE = 0,
SUCCESS = 1,
};
anonymous enum
Enumerator:
FAILURE 
SUCCESS 
RECOVERABLE 

Definition at line 32 of file StatusCode.h.

{
FAILURE = 0,
SUCCESS = 1,
};

Constructor & Destructor Documentation

StatusCode::StatusCode ( )
inline

Constructor.

Definition at line 39 of file StatusCode.h.

StatusCode::StatusCode ( unsigned long  code,
const IssueSeverity sev 
)
inline

Definition at line 41 of file StatusCode.h.

:
d_code(code),m_checked(false), m_severity() {
try { // ensure that we do not throw even if we cannot copy the severity
#if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) && ! defined(__GCCXML__)
m_severity = std::make_shared<IssueSeverity>(sev);
#else
#endif
}
catch (...) {}
}
StatusCode::StatusCode ( unsigned long  code,
bool  checked = false 
)
inline

Definition at line 52 of file StatusCode.h.

:
d_code(code),m_checked(checked), m_severity() {}
StatusCode::StatusCode ( const StatusCode rhs)
inline

Definition at line 55 of file StatusCode.h.

:
{ rhs.m_checked = true; }
StatusCode::StatusCode ( StatusCode &&  rhs)
inline

Move constructor.

Definition at line 62 of file StatusCode.h.

:
m_severity( std::move(rhs.m_severity) )
{ rhs.m_checked = true; }
StatusCode::~StatusCode ( )
inline

Destructor.

Definition at line 69 of file StatusCode.h.

{ if (UNLIKELY(s_checking)) check(); }
StatusCode::StatusCode ( )
inline

Constructor.

Definition at line 39 of file StatusCode.h.

StatusCode::StatusCode ( unsigned long  code,
const IssueSeverity sev 
)
inline

Definition at line 41 of file StatusCode.h.

:
d_code(code),m_checked(false), m_severity() {
try { // ensure that we do not throw even if we cannot copy the severity
#if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) && ! defined(__GCCXML__)
m_severity = std::make_shared<IssueSeverity>(sev);
#else
#endif
}
catch (...) {}
}
StatusCode::StatusCode ( unsigned long  code,
bool  checked = false 
)
inline

Definition at line 52 of file StatusCode.h.

:
d_code(code),m_checked(checked), m_severity() {}
StatusCode::StatusCode ( const StatusCode rhs)
inline

Definition at line 55 of file StatusCode.h.

:
{ rhs.m_checked = true; }
StatusCode::StatusCode ( StatusCode &&  rhs)
inline

Move constructor.

Definition at line 62 of file StatusCode.h.

:
m_severity( std::move(rhs.m_severity) )
{ rhs.m_checked = true; }
StatusCode::~StatusCode ( )
inline

Destructor.

Definition at line 69 of file StatusCode.h.

{ if (UNLIKELY(s_checking)) check(); }

Member Function Documentation

void StatusCode::check ( )
private
Fix-Me:
: (MCl) use backTrace(std::string&, const int, const int) instead

Definition at line 37 of file StatusCode.cpp.

{
if (!m_checked && !GaudiException::s_proc && !std::uncaught_exception() ) {
SmartIF<IStatusCodeSvc> scs(Gaudi::svcLocator()->service("StatusCodeSvc"));
const size_t depth = 21;
void* addresses[depth];
std::string lib, fnc;
void* addr = 0;
if (System::backTrace(addresses, depth)) {
for(size_t idx: {2, 3})
if (System::getStackLevel(addresses[idx], addr, fnc, lib) &&
fnc != "StatusCode::~StatusCode()") {
if (scs) {
scs->regFnc(fnc, lib);
} else {
MsgStream log(msg, "StatusCode");
log << MSG::WARNING << "Unchecked in " << fnc
<< " (" << lib << ")" << endmsg;
}
break;
}
}
}
}
void StatusCode::check ( )
private
bool StatusCode::checkingEnabled ( )
static

Definition at line 27 of file StatusCode.cpp.

{
return s_checking;
}
static GAUDI_API bool StatusCode::checkingEnabled ( )
static
void StatusCode::disableChecking ( )
static

Definition at line 23 of file StatusCode.cpp.

{
s_checking = false;
}
static GAUDI_API void StatusCode::disableChecking ( )
static
void StatusCode::enableChecking ( )
static

Definition at line 19 of file StatusCode.cpp.

{
s_checking = true;
}
static GAUDI_API void StatusCode::enableChecking ( )
static
unsigned long StatusCode::getCode ( ) const
inline

Get the status code by value.

Definition at line 92 of file StatusCode.h.

{
m_checked = true;
return d_code;
}
unsigned long StatusCode::getCode ( ) const
inline

Get the status code by value.

Definition at line 92 of file StatusCode.h.

{
m_checked = true;
return d_code;
}
void StatusCode::ignore ( ) const
inline

Definition at line 107 of file StatusCode.h.

{ setChecked(); }
void StatusCode::ignore ( ) const
inline

Definition at line 107 of file StatusCode.h.

{ setChecked(); }
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 status codes. To test for any failure use : if ( !StatusCode.isSuccess() ) ...

Definition at line 85 of file StatusCode.h.

{ return !isSuccess(); }
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 status codes. To test for any failure use : if ( !StatusCode.isSuccess() ) ...

Definition at line 85 of file StatusCode.h.

{ return !isSuccess(); }
bool StatusCode::isRecoverable ( ) const
inline

Definition at line 86 of file StatusCode.h.

{
m_checked = true;
return (d_code == RECOVERABLE);
}
bool StatusCode::isRecoverable ( ) const
inline

Definition at line 86 of file StatusCode.h.

{
m_checked = true;
return (d_code == RECOVERABLE);
}
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 75 of file StatusCode.h.

{
m_checked = true;
return (d_code == SUCCESS);
}
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 75 of file StatusCode.h.

{
m_checked = true;
return (d_code == SUCCESS);
}
StatusCode::operator IgnoreError ( ) const
inline

Definition at line 140 of file StatusCode.h.

{
m_checked = true;
return IgnoreError();
}
StatusCode::operator IgnoreError ( ) const
inline

Definition at line 140 of file StatusCode.h.

{
m_checked = true;
return IgnoreError();
}
StatusCode::operator unsigned long ( ) const
inline

Cast operator.

Definition at line 110 of file StatusCode.h.

{ return getCode(); }
StatusCode::operator unsigned long ( ) const
inline

Cast operator.

Definition at line 110 of file StatusCode.h.

{ return getCode(); }
StatusCode& StatusCode::operator= ( unsigned long  value)
inline

Assignment operator.

Definition at line 116 of file StatusCode.h.

{
return *this;
}
StatusCode& StatusCode::operator= ( unsigned long  value)
inline

Assignment operator.

Definition at line 116 of file StatusCode.h.

{
return *this;
}
StatusCode& StatusCode::operator= ( const StatusCode rhs)
inline

Definition at line 120 of file StatusCode.h.

{
if (this == &rhs) return *this; // Protection against self-assignment
d_code = rhs.d_code;
rhs.m_checked = true;
return *this;
}
StatusCode& StatusCode::operator= ( const StatusCode rhs)
inline

Definition at line 120 of file StatusCode.h.

{
if (this == &rhs) return *this; // Protection against self-assignment
d_code = rhs.d_code;
rhs.m_checked = true;
return *this;
}
void StatusCode::setChecked ( ) const
inline

Ignore the checking code;.

Definition at line 104 of file StatusCode.h.

{
m_checked = true;
}
void StatusCode::setChecked ( ) const
inline

Ignore the checking code;.

Definition at line 104 of file StatusCode.h.

{
m_checked = true;
}
void StatusCode::setCode ( unsigned long  value)
inline

Set the status code by value.

Definition at line 98 of file StatusCode.h.

{
m_checked = false;
}
void StatusCode::setCode ( unsigned long  value)
inline

Set the status code by value.

Definition at line 98 of file StatusCode.h.

{
m_checked = false;
}
const IssueSeverity & StatusCode::severity ( ) const

Severity.

Definition at line 31 of file StatusCode.cpp.

{
static IssueSeverity dummy;
if (m_severity) return *m_severity;
else return dummy;
}
GAUDI_API const IssueSeverity& StatusCode::severity ( ) const

Severity.

Friends And Related Function Documentation

bool operator< ( const StatusCode a,
const StatusCode b 
)
friend

Comparison operator.

Definition at line 130 of file StatusCode.h.

{
return a.d_code < b.d_code;
}
bool operator< ( const StatusCode a,
const StatusCode b 
)
friend

Comparison operator.

Definition at line 130 of file StatusCode.h.

{
return a.d_code < b.d_code;
}
bool operator> ( const StatusCode a,
const StatusCode b 
)
friend

Comparison operator.

Definition at line 135 of file StatusCode.h.

{
return a.d_code > b.d_code;
}
bool operator> ( const StatusCode a,
const StatusCode b 
)
friend

Comparison operator.

Definition at line 135 of file StatusCode.h.

{
return a.d_code > b.d_code;
}

Member Data Documentation

unsigned long StatusCode::d_code
protected

The status code.

The status code

Definition at line 177 of file StatusCode.h.

bool StatusCode::m_checked
mutableprotected

If the Status code has been checked.

Definition at line 178 of file StatusCode.h.

SeverityPtr StatusCode::m_severity
protected

Pointer to a IssueSeverity.

Definition at line 188 of file StatusCode.h.

static bool StatusCode::s_checking
staticprotected

Global flag to control if StatusCode need to be checked.

Definition at line 190 of file StatusCode.h.


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