| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Friends | List of all members
StatusCode Class Referencefinal

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

`#include <GaudiKernel/StatusCode.h>`

Collaboration diagram for StatusCode:
[legend]

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

## Public Types
enum | { FAILURE = 0, SUCCESS = 1, RECOVERABLE = 2 }

## Public Member Functions
| StatusCode ()=default
| Constructor. More...
| StatusCode (unsigned long code, IssueSeverity &&sev)
| StatusCode (IssueSeverity &&is)
| StatusCode (unsigned long code, bool checked=false)
| StatusCode (const StatusCode &rhs)
| StatusCode (StatusCode &&rhs) noexcept
| Move constructor. More...
| ~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 IssueSeverity & | severity () const
| Severity. More...
StatusCode & | operator= (unsigned long value)
| Assignment operator. More...
StatusCode & | operator= (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 ()

## Protected Attributes
unsigned long | d_code = SUCCESS
| The status code. More...
bool | m_checked = false
| If the Status code has been checked. More...
std::shared_ptr< const IssueSeverity > | 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...

## Private Member Functions
void | check ()

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

## Member Enumeration Documentation

anonymous enum

Enumerator
FAILURE |
SUCCESS |
RECOVERABLE |

Definition at line 31 of file StatusCode.h.

31 { FAILURE = 0, SUCCESS = 1, RECOVERABLE = 2 };
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::RECOVERABLE
Definition: StatusCode.h:31

## Constructor & Destructor Documentation

StatusCode::StatusCode | ( |  | ) |
| default

Constructor.

StatusCode::StatusCode | ( | unsigned long | code,
|  | IssueSeverity && | sev
| ) |  |
| inline

Definition at line 36 of file StatusCode.h.

36 : d_code( code )
37 {
38 try { // ensure that we do not throw even if we cannot move the severity
39 m_severity = std::make_shared<const IssueSeverity>( std::move( sev ) );
40 } catch ( ... ) {
41 }
42 }
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182
std::move
T move(T...args)
StatusCode::m_severity
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:184

StatusCode::StatusCode | ( | IssueSeverity && | is | ) |
| inline

Definition at line 44 of file StatusCode.h.

45 : StatusCode( is.getLevel() == IssueSeverity::RECOVERABLE
46 ? StatusCode::RECOVERABLE
47 : ( is.getLevel() < IssueSeverity::ERROR ? StatusCode::SUCCESS : StatusCode::FAILURE ),
48 std::move( is ) )
49 {
50 }
IssueSeverity::RECOVERABLE
Definition: IssueSeverity.h:36
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
IssueSeverity::ERROR
Definition: IssueSeverity.h:37
std::move
T move(T...args)
StatusCode::RECOVERABLE
Definition: StatusCode.h:31
StatusCode::StatusCode
StatusCode()=default
Constructor.
IssueSeverity::getLevel
IssueSeverity::Level getLevel() const
Definition: IssueSeverity.h:57

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

Definition at line 52 of file StatusCode.h.

52 : d_code( code ), m_checked( checked ) {}
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182

StatusCode::StatusCode | ( | const StatusCode & | rhs | ) |
| inline

Definition at line 54 of file StatusCode.h.

54 : d_code( rhs.d_code ), m_checked( rhs.m_checked ), m_severity( rhs.m_severity )
55 {
56 rhs.m_checked = true;
57 }
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182
StatusCode::m_severity
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:184

StatusCode::StatusCode | ( | StatusCode && | rhs | ) |
| inline noexcept

Move constructor.

Definition at line 60 of file StatusCode.h.

61 : d_code( rhs.d_code ), m_checked( rhs.m_checked ), m_severity( std::move( rhs.m_severity ) )
62 {
63 rhs.m_checked = true;
64 }
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182
std::move
T move(T...args)
StatusCode::m_severity
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:184

StatusCode::~StatusCode | ( |  | ) |
| inline

Destructor.

Definition at line 67 of file StatusCode.h.

68 {
69 if ( UNLIKELY( s_checking ) ) check();
70 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
StatusCode::check
void check()
Definition: StatusCode.cpp:31
StatusCode::s_checking
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:186

## Member Function Documentation

void StatusCode::check | ( |  | ) |
| private

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

Definition at line 31 of file StatusCode.cpp.

32 {
33
34 if ( !m_checked && !GaudiException::s_proc && !std::uncaught_exception() ) {
35
36 auto msg = Gaudi::svcLocator()->as<IMessageSvc>();
37 auto scs = Gaudi::svcLocator()->service<IStatusCodeSvc>( "StatusCodeSvc" );
38
39 const size_t depth = 21;
40 void* addresses[depth];
41
42 std::string lib, fnc;
43 void* addr = nullptr;
45 if ( System::backTrace( addresses, depth ) ) {
46
47 for ( size_t idx : {2, 3} ) {
48 if ( System::getStackLevel( addresses[idx], addr, fnc, lib ) && fnc != "StatusCode::~StatusCode()" ) {
49
50 if ( scs ) {
51 scs->regFnc( fnc, lib );
52 } else {
53 MsgStream log( msg, "StatusCode" );
54 log << MSG::WARNING << "Unchecked in " << fnc << " (" << lib << ")" << endmsg;
55 }
56 break;
57 }
58 }
59 }
60 }
61 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
System::getStackLevel
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
GaudiException::s_proc
static bool s_proc
"previous" element in the linked list
Definition: GaudiException.h:178
ISvcLocator::as
SmartIF< IFace > as()
Definition: ISvcLocator.h:109
System::backTrace
GAUDI_API int backTrace(void **addresses, const int depth)
std::string
STL class.
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
std::uncaught_exception
T uncaught_exception(T...args)
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
MSG::WARNING
Definition: IMessageSvc.h:16
IStatusCodeSvc
Definition: IStatusCodeSvc.h:7
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

bool StatusCode::checkingEnabled | ( |  | ) |
| static

Definition at line 23 of file StatusCode.cpp.

23 { return s_checking; }
StatusCode::s_checking
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:186

void StatusCode::disableChecking | ( |  | ) |
| static

Definition at line 21 of file StatusCode.cpp.

21 { s_checking = false; }
StatusCode::s_checking
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:186

void StatusCode::enableChecking | ( |  | ) |
| static

Definition at line 19 of file StatusCode.cpp.

19 { s_checking = true; }
StatusCode::s_checking
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:186

unsigned long StatusCode::getCode | ( |  | ) | const
| inline

Get the status code by value.

Definition at line 94 of file StatusCode.h.

95 {
96 m_checked = true;
97 return d_code;
98 }
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182

void StatusCode::ignore | ( |  | ) | const
| inline

Definition at line 109 of file StatusCode.h.

109 { setChecked(); }
StatusCode::setChecked
void setChecked() const
Ignore the checking code;.
Definition: StatusCode.h:108

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

86 { return !isSuccess(); }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75

bool StatusCode::isRecoverable | ( |  | ) | const
| inline

Definition at line 87 of file StatusCode.h.

88 {
89 m_checked = true;
90 return ( d_code == RECOVERABLE );
91 }
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182
StatusCode::RECOVERABLE
Definition: StatusCode.h:31

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.

76 {
77 m_checked = true;
78 return ( d_code == SUCCESS );
79 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182

StatusCode::operator IgnoreError | ( |  | ) | const
| inline

Definition at line 140 of file StatusCode.h.

141 {
142 m_checked = true;
143 return IgnoreError();
144 }
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
IgnoreError
Definition: StatusCode.h:24

StatusCode::operator unsigned long | ( |  | ) | const
| inline

Cast operator.

Definition at line 112 of file StatusCode.h.

112 { return getCode(); }
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:94

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

Assignment operator.

Definition at line 118 of file StatusCode.h.

119 {
120 setCode( value );
121 return *this;
122 }
StatusCode::setCode
void setCode(unsigned long value)
Set the status code by value.
Definition: StatusCode.h:101

StatusCode& StatusCode::operator= | ( | const StatusCode & | rhs | ) |
| inline

Definition at line 123 of file StatusCode.h.

124 {
125 if ( this == &rhs ) return *this; // Protection against self-assignment
126 d_code = rhs.d_code;
127 m_checked = rhs.m_checked;
128 rhs.m_checked = true;
129 m_severity = rhs.m_severity;
130 return *this;
131 }
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182
StatusCode::m_severity
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:184

void StatusCode::setChecked | ( |  | ) | const
| inline

Ignore the checking code;.

Definition at line 108 of file StatusCode.h.

108 { m_checked = true; }
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183

void StatusCode::setCode | ( | unsigned long | value | ) |
| inline

Set the status code by value.

Definition at line 101 of file StatusCode.h.

102 {
103 m_checked = false;
104 d_code = value;
105 }
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182

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

Severity.

Definition at line 25 of file StatusCode.cpp.

26 {
27 static const IssueSeverity dummy;
28 return m_severity ? *m_severity : dummy;
29 }
IssueSeverity
Definition: IssueSeverity.h:23
StatusCode::m_severity
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:184

## Friends And Related Function Documentation

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

Comparison operator.

Definition at line 134 of file StatusCode.h.

134 { return a.d_code < b.d_code; }
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182

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

Comparison operator.

Definition at line 137 of file StatusCode.h.

137 { return a.d_code > b.d_code; }
StatusCode::d_code
unsigned long d_code
The status code.
Definition: StatusCode.h:182

## Member Data Documentation

unsigned long StatusCode::d_code = SUCCESS
| protected

The status code.

The status code

Definition at line 182 of file StatusCode.h.

bool StatusCode::m_checked = false
| mutable protected

If the Status code has been checked.

Definition at line 183 of file StatusCode.h.

std::shared_ptr<const IssueSeverity> StatusCode::m_severity
| protected

Pointer to a IssueSeverity.

Definition at line 184 of file StatusCode.h.

bool StatusCode::s_checking
| static protected

Global flag to control if StatusCode need to be checked.

Definition at line 186 of file StatusCode.h.

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

- GaudiKernel/GaudiKernel/StatusCode.h
- GaudiKernel/src/Lib/StatusCode.cpp