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>

Public Types

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

Public Member Functions

 StatusCode ()
 Constructor. More...
 
 StatusCode (unsigned long code, const IssueSeverity &sev)
 
 StatusCode (unsigned long code, bool checked=false)
 
 StatusCode (const StatusCode &rhs)
 
GAUDI_API ~StatusCode ()
 Destructor. More...
 
bool isSuccess () const
 Test for a status code of SUCCESS. More...
 
bool isFailure () const
 Test for a status code of FAILURE. More...
 
bool isRecoverable () const
 
unsigned long getCode () const
 Get the status code by value. More...
 
void setCode (unsigned long value)
 Set the status code by value. More...
 
void setChecked () const
 Ignore the checking code;. More...
 
void ignore () const
 
 operator unsigned long () const
 Cast operator. More...
 
GAUDI_API const IssueSeverityseverity () const
 Severity. More...
 
StatusCodeoperator= (unsigned long value)
 Assignment operator. More...
 
StatusCodeoperator= (const StatusCode &rhs)
 
 operator IgnoreError () const
 

Static Public Member Functions

static GAUDI_API void enableChecking ()
 
static GAUDI_API void disableChecking ()
 

Protected Types

typedef boost::shared_ptr
< IssueSeverity
SeverityPtr
 

Protected Attributes

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

Static Protected Attributes

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

Friends

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

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 147 of file StatusCode.h.

Member Enumeration Documentation

anonymous enum
Enumerator
FAILURE 
SUCCESS 
RECOVERABLE 

Definition at line 32 of file StatusCode.h.

Constructor & Destructor Documentation

StatusCode::StatusCode ( )
inline

Constructor.

Definition at line 39 of file StatusCode.h.

39  :
40  d_code(SUCCESS), m_checked(false), m_severity() {}
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
SeverityPtr m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:149
unsigned long d_code
The status code.
Definition: StatusCode.h:138
StatusCode::StatusCode ( unsigned long  code,
const IssueSeverity sev 
)
inline

Definition at line 41 of file StatusCode.h.

41  :
42  d_code(code),m_checked(false), m_severity() {
43  try { // ensure that we do not throw even if the we cannot copy the severity
45  }
46  catch (...) {}
47  }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
SeverityPtr m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:149
unsigned long d_code
The status code.
Definition: StatusCode.h:138
boost::shared_ptr< IssueSeverity > SeverityPtr
Definition: StatusCode.h:147
StatusCode::StatusCode ( unsigned long  code,
bool  checked = false 
)
inline

Definition at line 48 of file StatusCode.h.

48  :
49  d_code(code),m_checked(checked), m_severity() {}
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
SeverityPtr m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:149
unsigned long d_code
The status code.
Definition: StatusCode.h:138
StatusCode::StatusCode ( const StatusCode rhs)
inline

Definition at line 51 of file StatusCode.h.

51  :
52  d_code(rhs.d_code), m_checked(rhs.m_checked),
54  { rhs.m_checked = true; }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
SeverityPtr m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:149
unsigned long d_code
The status code.
Definition: StatusCode.h:138
StatusCode::~StatusCode ( )

Destructor.

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

Definition at line 33 of file StatusCode.cpp.

33  {
34  if(UNLIKELY(s_checking)) {
35 
36  if (!m_checked && !GaudiException::s_proc && !std::uncaught_exception() ) {
37 
39 
40  SmartIF<IStatusCodeSvc> scs(Gaudi::svcLocator()->service("StatusCodeSvc"));
41 
42  const size_t depth = 21;
43  void* addresses[depth];
44 
45  std::string lib, fnc;
46  void* addr = 0;
48  if (System::backTrace(addresses, depth)) {
49 
50  if (System::getStackLevel(addresses[2], addr, fnc, lib)) {
51 
52  if (scs) {
53  scs->regFnc(fnc,lib);
54  } else {
55  if (msg) {
56  MsgStream log(msg,"StatusCode");
57  log << MSG::WARNING << "Unchecked in " << fnc << " " << lib << endmsg;
58  } else {
59  std::cout << MSG::WARNING << "Unchecked in " << fnc << " " << lib << std::endl;
60  }
61  }
62 
63  }
64 
65  }
66  }
67  }
68 }
#define UNLIKELY(x)
Definition: Kernel.h:127
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
static bool s_proc
"previous" element in the linked list
GAUDI_API int backTrace(void **addresses, const int depth)
GAUDI_API ISvcLocator * svcLocator()
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:151
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Function Documentation

void StatusCode::disableChecking ( )
static

Definition at line 23 of file StatusCode.cpp.

23  {
24  s_checking = false;
25 }
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:151
void StatusCode::enableChecking ( )
static

Definition at line 19 of file StatusCode.cpp.

19  {
20  s_checking = true;
21 }
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:151
unsigned long StatusCode::getCode ( ) const
inline

Get the status code by value.

Definition at line 79 of file StatusCode.h.

79  {
80  m_checked = true;
81  return d_code;
82  }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
unsigned long d_code
The status code.
Definition: StatusCode.h:138
void StatusCode::ignore ( ) const
inline

Definition at line 94 of file StatusCode.h.

94 { setChecked(); }
void setChecked() const
Ignore the checking code;.
Definition: StatusCode.h:91
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 72 of file StatusCode.h.

72 { return !isSuccess(); }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
bool StatusCode::isRecoverable ( ) const
inline

Definition at line 73 of file StatusCode.h.

73  {
74  m_checked = true;
75  return (d_code == RECOVERABLE);
76  }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
unsigned long d_code
The status code.
Definition: StatusCode.h:138
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 62 of file StatusCode.h.

62  {
63  m_checked = true;
64  return (d_code == SUCCESS);
65  }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
unsigned long d_code
The status code.
Definition: StatusCode.h:138
StatusCode::operator IgnoreError ( ) const
inline

Definition at line 127 of file StatusCode.h.

127  {
128  m_checked = true;
129  return IgnoreError();
130  }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
StatusCode::operator unsigned long ( ) const
inline

Cast operator.

Definition at line 97 of file StatusCode.h.

97 { return getCode(); }
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:79
StatusCode& StatusCode::operator= ( unsigned long  value)
inline

Assignment operator.

Definition at line 103 of file StatusCode.h.

103  {
104  setCode(value);
105  return *this;
106  }
void setCode(unsigned long value)
Set the status code by value.
Definition: StatusCode.h:85
StatusCode& StatusCode::operator= ( const StatusCode rhs)
inline

Definition at line 107 of file StatusCode.h.

107  {
108  if (this == &rhs) return *this; // Protection against self-assignment
109  d_code = rhs.d_code;
110  m_checked = rhs.m_checked;
111  rhs.m_checked = true;
112  m_severity = rhs.m_severity;
113  return *this;
114  }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
SeverityPtr m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:149
unsigned long d_code
The status code.
Definition: StatusCode.h:138
void StatusCode::setChecked ( ) const
inline

Ignore the checking code;.

Definition at line 91 of file StatusCode.h.

91  {
92  m_checked = true;
93  }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
void StatusCode::setCode ( unsigned long  value)
inline

Set the status code by value.

Definition at line 85 of file StatusCode.h.

85  {
86  m_checked = false;
87  d_code = value;
88  }
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:139
unsigned long d_code
The status code.
Definition: StatusCode.h:138
const IssueSeverity & StatusCode::severity ( ) const

Severity.

Definition at line 27 of file StatusCode.cpp.

27  {
28  static IssueSeverity dummy;
29  if (m_severity) return *m_severity;
30  else return dummy;
31 }
SeverityPtr m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:149

Friends And Related Function Documentation

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

Comparison operator.

Definition at line 117 of file StatusCode.h.

117  {
118  return a.d_code < b.d_code;
119  }
unsigned long d_code
The status code.
Definition: StatusCode.h:138
bool operator> ( const StatusCode a,
const StatusCode b 
)
friend

Comparison operator.

Definition at line 122 of file StatusCode.h.

122  {
123  return a.d_code > b.d_code;
124  }
unsigned long d_code
The status code.
Definition: StatusCode.h:138

Member Data Documentation

unsigned long StatusCode::d_code
protected

The status code.

The status code

Definition at line 138 of file StatusCode.h.

bool StatusCode::m_checked
mutableprotected

If the Status code has been checked.

Definition at line 139 of file StatusCode.h.

SeverityPtr StatusCode::m_severity
protected

Pointer to a IssueSeverity.

Definition at line 149 of file StatusCode.h.

bool StatusCode::s_checking
staticprotected

Global flag to control if StatusCode need to be checked.

Definition at line 151 of file StatusCode.h.


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