The Gaudi Framework  v33r0 (d5ea422b)
StatusCode Class Referencefinal

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

#include <GaudiKernel/StatusCode.h>

Collaboration diagram for StatusCode:

Classes

class  Category
 The category assigned to a StatusCode. More...
 
class  ScopedDisableChecking
 Simple RAII class to ignore unchecked StatusCode instances in a scope. More...
 

Public Types

enum  ErrorCode : code_t { ErrorCode::FAILURE = 0, ErrorCode::SUCCESS = 1, ErrorCode::RECOVERABLE = 2 }
 
typedef unsigned long code_t
 type of StatusCode value More...
 

Public Member Functions

 StatusCode ()=default
 Default constructor. More...
 
template<typename T , typename = std::enable_if_t<is_StatusCode_enum<T>::value>>
 StatusCode (T sc, bool checked=false) noexcept
 Constructor from enum type (allowing implicit conversion) More...
 
 StatusCode (code_t code, const StatusCode::Category &cat=default_category(), bool checked=false) noexcept
 Constructor from code_t in the default category (explicit conversion only) More...
 
 StatusCode (code_t code, bool checked) noexcept
 Constructor from code_t and category (explicit conversion only) More...
 
 StatusCode (const StatusCode &rhs) noexcept
 Copy constructor. More...
 
 StatusCode (StatusCode &&rhs) noexcept
 Move constructor. More...
 
 ~StatusCode ()
 Destructor. More...
 
StatusCodeoperator= (const StatusCode &rhs) noexcept
 
bool isSuccess () const
 
bool isFailure () const
 
bool isRecoverable () const
 
 operator bool () const
 Shorthand for isSuccess() More...
 
code_t getCode () const
 Retrieve value ("checks" the StatusCode) More...
 
const StatusCodesetChecked (bool checked=true) const
 Check/uncheck StatusCode. More...
 
StatusCodesetChecked (bool checked=true)
 
const StatusCodeignore () const
 Ignore/check StatusCode. More...
 
StatusCodeignore ()
 
template<typename F , typename... ARGS>
StatusCode andThen (F &&f, ARGS &&... args) const
 Chain code blocks making the execution conditional a success result. More...
 
template<typename F , typename... ARGS>
StatusCode orElse (F &&f, ARGS &&... args) const
 Chain code blocks making the execution conditional a failure result. More...
 
StatusCode orThrow (std::string message, std::string tag) const
 Throw a GaudiException in case of failures. More...
 
bool checked () const
 Has the StatusCode been checked? More...
 
const StatusCode::CategorygetCategory () const
 Retrieve category (does not "check" the StatusCode) More...
 
std::string message () const
 Description (or name) of StatusCode value. More...
 
StatusCodeoperator&= (const StatusCode &rhs)
 Ternary logic operator with RECOVERABLE being the "third" state. More...
 
StatusCodeoperator|= (const StatusCode &rhs)
 Ternary logic operator with RECOVERABLE being the "third" state. More...
 

Static Public Member Functions

static const Categorydefault_category () noexcept
 Default Gaudi StatusCode category. More...
 
static GAUDI_API void enableChecking ()
 
static GAUDI_API void disableChecking ()
 
static GAUDI_API bool checkingEnabled ()
 

Static Public Attributes

constexpr static const auto SUCCESS = ErrorCode::SUCCESS
 
constexpr static const auto FAILURE = ErrorCode::FAILURE
 
constexpr static const auto RECOVERABLE = ErrorCode::RECOVERABLE
 

Private Member Functions

ErrorCode default_value () const
 Project onto the default StatusCode values. More...
 
void check ()
 Do StatusCode check. More...
 
void i_doThrow (std::string message, std::string tag) const
 Helper function to avoid circular dependency between GaudiException.h and StatusCode.h. More...
 
template<typename F , typename... ARGS, typename = std::enable_if_t<std::is_invocable_v<F, ARGS...>>>
StatusCode i_invoke (F &&f, ARGS &&... args) const
 Helper to invoke a callable and return the resulting StatusCode or this, if the callable returns void. More...
 

Private Attributes

const Categorym_cat {&default_category()}
 The status code category. More...
 
code_t m_code {static_cast<code_t>( ErrorCode::SUCCESS )}
 The status code value. More...
 
bool m_checked {false}
 If the StatusCode has been checked. More...
 

Static Private Attributes

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

Friends

std::ostreamoperator<< (std::ostream &s, const StatusCode &sc)
 
bool operator== (const StatusCode &lhs, const StatusCode &rhs)
 Check if StatusCode value and category are the same. More...
 
bool operator!= (const StatusCode &lhs, const StatusCode &rhs)
 
bool operator< (const StatusCode &lhs, const StatusCode &rhs)
 Comparison (values are grouped by category first) More...
 

Detailed Description

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

A StatusCode is comprised of an (integer) value and a category (similar to std::error_code). By default StatusCodes are created within a default StatusCode::Category, which defines the isSuccess(), isFailure() and isRecoverable() behaviour depending on the value of the StatusCode. This behaviour can be modified by defining a custom StatusCode::Category and overriding the respective methods.

To define a new StatusCode::Category, do the following:

Combining StatusCodes
  • The bitwise logic operators (&, |, &=, |=) can be used to combine StatusCodes and follows three-valued (ternary) logic with RECOVERABLE being the third state. No short-circuiting is applied:
    StatusCode sc = sc1 & sc2;
    sc |= sc3;
  • The boolean logic operators (&&, ||) perform regular two-valued logic only considering success/failure. The usual short-circuiting applies:
    bool b = sc1 && sc2;
Note
The StatusCode values 0 and 1 are considered FAILURE/SUCCESS for all categories, i.e.
Remarks
See https://akrzemi1.wordpress.com/2017/07/12/your-own-error-code for details on the underlying design

Definition at line 61 of file StatusCode.h.

Member Typedef Documentation

◆ code_t

typedef unsigned long StatusCode::code_t

type of StatusCode value

Definition at line 63 of file StatusCode.h.

Member Enumeration Documentation

◆ ErrorCode

Enumerator
FAILURE 
SUCCESS 
RECOVERABLE 

Definition at line 65 of file StatusCode.h.

65 : code_t { FAILURE = 0, SUCCESS = 1, RECOVERABLE = 2 };
constexpr static const auto RECOVERABLE
Definition: StatusCode.h:98
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
constexpr static const auto FAILURE
Definition: StatusCode.h:97
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:63

Constructor & Destructor Documentation

◆ StatusCode() [1/6]

StatusCode::StatusCode ( )
default

Default constructor.

◆ StatusCode() [2/6]

template<typename T , typename = std::enable_if_t<is_StatusCode_enum<T>::value>>
StatusCode::StatusCode ( sc,
bool  checked = false 
)
inlinenoexcept

Constructor from enum type (allowing implicit conversion)

Definition at line 105 of file StatusCode.h.

105  {
106  *this = StatusCode( static_cast<StatusCode::code_t>( sc ), is_StatusCode_enum<T>::instance );
107  m_checked = checked;
108  }
bool checked() const
Has the StatusCode been checked?
Definition: StatusCode.h:242
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
StatusCode()=default
Default constructor.

◆ StatusCode() [3/6]

StatusCode::StatusCode ( code_t  code,
const StatusCode::Category cat = default_category(),
bool  checked = false 
)
inlineexplicitnoexcept

Constructor from code_t in the default category (explicit conversion only)

Definition at line 111 of file StatusCode.h.

113  : m_cat( &cat ), m_code( code ), m_checked( checked ) {}
bool checked() const
Has the StatusCode been checked?
Definition: StatusCode.h:242
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

◆ StatusCode() [4/6]

StatusCode::StatusCode ( code_t  code,
bool  checked 
)
inlineexplicitnoexcept

Constructor from code_t and category (explicit conversion only)

Definition at line 116 of file StatusCode.h.

116 : StatusCode( code, default_category(), checked ) {}
bool checked() const
Has the StatusCode been checked?
Definition: StatusCode.h:242
static const Category & default_category() noexcept
Default Gaudi StatusCode category.
Definition: StatusCode.h:357
StatusCode()=default
Default constructor.

◆ StatusCode() [5/6]

StatusCode::StatusCode ( const StatusCode rhs)
inlinenoexcept

Copy constructor.

Definition at line 119 of file StatusCode.h.

119  : m_cat( rhs.m_cat ), m_code( rhs.m_code ), m_checked( rhs.m_checked ) {
120  rhs.m_checked = true;
121  }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

◆ StatusCode() [6/6]

StatusCode::StatusCode ( StatusCode &&  rhs)
inlinenoexcept

Move constructor.

Definition at line 124 of file StatusCode.h.

124  : m_cat( rhs.m_cat ), m_code( rhs.m_code ), m_checked( rhs.m_checked ) {
125  rhs.m_checked = true;
126  }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

◆ ~StatusCode()

StatusCode::~StatusCode ( )
inline

Destructor.

Definition at line 129 of file StatusCode.h.

129  {
130  if ( UNLIKELY( s_checking ) ) check();
131  }
#define UNLIKELY(x)
Definition: Kernel.h:106
void check()
Do StatusCode check.
Definition: StatusCode.cpp:59
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:306

Member Function Documentation

◆ andThen()

template<typename F , typename... ARGS>
StatusCode StatusCode::andThen ( F &&  f,
ARGS &&...  args 
) const
inline

Chain code blocks making the execution conditional a success result.

The chained execution stops on the first non-success StatusCode in the chain and returns it, or continues until the end and returns the last produced StatusCode.

For example:

StatusCode myFunction() {
return subFunction()
.andThen([]() {
do_something();
})
.andThen(anotherFunction)
.andThen([]() {
if (is_special_case())
return do_something_else();
});
}

Definition at line 194 of file StatusCode.h.

194  {
195  if ( isFailure() ) return *this;
196  return i_invoke( std::forward<F>( f ), std::forward<ARGS>( args )... );
197  }
StatusCode i_invoke(F &&f, ARGS &&... args) const
Helper to invoke a callable and return the resulting StatusCode or this, if the callable returns void...
Definition: StatusCode.h:316
bool isFailure() const
Definition: StatusCode.h:141

◆ check()

void StatusCode::check ( )
private

Do StatusCode check.

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

Definition at line 59 of file StatusCode.cpp.

59  {
60 
61  if ( !m_checked && !GaudiException::s_proc && !std::uncaught_exceptions() ) {
62 
63  auto msg = Gaudi::svcLocator()->as<IMessageSvc>();
64  auto scs = Gaudi::svcLocator()->service<IStatusCodeSvc>( "StatusCodeSvc" );
65 
66  const size_t depth = 21;
67  void* addresses[depth];
68 
69  std::string lib, fnc;
70  void* addr = nullptr;
72  if ( System::backTrace( addresses, depth ) ) {
73 
74  for ( size_t idx : {2, 3} ) {
75  // When running address sanitizer builds with -fno-omit-frame-pointer
76  // StatusCode::check() might appear as the function name, so skip.
77  if ( System::getStackLevel( addresses[idx], addr, fnc, lib ) && fnc != "StatusCode::~StatusCode()" &&
78  fnc != "StatusCode::check()" ) {
79  if ( scs ) {
80  scs->regFnc( fnc, lib );
81  } else {
82  MsgStream log( msg, "StatusCode" );
83  log << MSG::WARNING << "Unchecked in " << fnc << " (" << lib << ")" << endmsg;
84  }
85  break;
86  }
87  }
88  }
89  }
90 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
static bool s_proc
"previous" element in the linked list
SmartIF< IFace > as()
Definition: ISvcLocator.h:113
GAUDI_API int backTrace(void **addresses, const int depth)
STL class.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:86
GAUDI_API ISvcLocator * svcLocator()
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:47
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ checked()

bool StatusCode::checked ( ) const
inline

Has the StatusCode been checked?

Definition at line 242 of file StatusCode.h.

242 { return m_checked; }
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305

◆ checkingEnabled()

bool StatusCode::checkingEnabled ( )
static

Definition at line 57 of file StatusCode.cpp.

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

◆ default_category()

const StatusCode::Category & StatusCode::default_category ( )
inlinestaticnoexcept

Default Gaudi StatusCode category.

Definition at line 357 of file StatusCode.h.

◆ default_value()

StatusCode::ErrorCode StatusCode::default_value ( ) const
inlineprivate

Project onto the default StatusCode values.

Definition at line 371 of file StatusCode.h.

371  {
372  bool save_checked = m_checked; // Preserve checked status
374  m_checked = save_checked;
375  return r;
376 }
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
bool isSuccess() const
Definition: StatusCode.h:361
bool isRecoverable() const
Definition: StatusCode.h:366

◆ disableChecking()

void StatusCode::disableChecking ( )
static

Definition at line 55 of file StatusCode.cpp.

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

◆ enableChecking()

void StatusCode::enableChecking ( )
static

Definition at line 53 of file StatusCode.cpp.

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

◆ getCategory()

const StatusCode::Category& StatusCode::getCategory ( ) const
inline

Retrieve category (does not "check" the StatusCode)

Definition at line 245 of file StatusCode.h.

245 { return *m_cat; }
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

◆ getCode()

code_t StatusCode::getCode ( ) const
inline

Retrieve value ("checks" the StatusCode)

Definition at line 148 of file StatusCode.h.

148  {
149  m_checked = true;
150  return m_code;
151  }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305

◆ i_doThrow()

void StatusCode::i_doThrow ( std::string  message,
std::string  tag 
) const
private

Helper function to avoid circular dependency between GaudiException.h and StatusCode.h.

Definition at line 92 of file StatusCode.cpp.

92  {
93  throw GaudiException{std::move( message ), std::move( tag ), *this};
94 }
Define general base for Gaudi exception.
T move(T... args)
std::string message() const
Description (or name) of StatusCode value.
Definition: StatusCode.h:248

◆ i_invoke()

template<typename F , typename... ARGS, typename = std::enable_if_t<std::is_invocable_v<F, ARGS...>>>
StatusCode StatusCode::i_invoke ( F &&  f,
ARGS &&...  args 
) const
inlineprivate

Helper to invoke a callable and return the resulting StatusCode or this, if the callable returns void.

Definition at line 316 of file StatusCode.h.

316  {
317  if constexpr ( std::is_invocable_r_v<StatusCode, F, ARGS...> ) {
318  return std::invoke( std::forward<F>( f ), std::forward<ARGS>( args )... );
319  } else {
320  // static_assert( std::is_same_v<void,std::invoke_result_t<F,ARGS...>>); // how paranoid should this be?
321  std::invoke( std::forward<F>( f ), std::forward<ARGS>( args )... );
322  return *this;
323  }
324  }

◆ ignore() [1/2]

const StatusCode& StatusCode::ignore ( ) const
inline

Ignore/check StatusCode.

Definition at line 164 of file StatusCode.h.

164  {
165  setChecked( true );
166  return *this;
167  }
const StatusCode & setChecked(bool checked=true) const
Check/uncheck StatusCode.
Definition: StatusCode.h:154

◆ ignore() [2/2]

StatusCode& StatusCode::ignore ( )
inline

Definition at line 168 of file StatusCode.h.

168  {
169  setChecked( true );
170  return *this;
171  }
const StatusCode & setChecked(bool checked=true) const
Check/uncheck StatusCode.
Definition: StatusCode.h:154

◆ isFailure()

bool StatusCode::isFailure ( ) const
inline

Definition at line 141 of file StatusCode.h.

141 { return !isSuccess(); }
bool isSuccess() const
Definition: StatusCode.h:361

◆ isRecoverable()

bool StatusCode::isRecoverable ( ) const
inline

Definition at line 366 of file StatusCode.h.

366  {
367  m_checked = true;
368  return m_cat->isRecoverable( m_code );
369 }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
virtual bool isRecoverable(code_t code) const
Is code considered recoverable ?
Definition: StatusCode.h:89
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

◆ isSuccess()

bool StatusCode::isSuccess ( ) const
inline

Definition at line 361 of file StatusCode.h.

361  {
362  m_checked = true;
363  return ( m_code == static_cast<code_t>( ErrorCode::SUCCESS ) || m_cat->isSuccess( m_code ) );
364 }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
virtual bool isSuccess(code_t code) const
Is code considered success ?
Definition: StatusCode.h:86
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

◆ message()

std::string StatusCode::message ( ) const
inline

Description (or name) of StatusCode value.

Definition at line 248 of file StatusCode.h.

248 { return getCategory().message( m_code ); }
code_t m_code
The status code value.
Definition: StatusCode.h:304
const StatusCode::Category & getCategory() const
Retrieve category (does not "check" the StatusCode)
Definition: StatusCode.h:245
virtual std::string message(code_t code) const
Description for code within this category.
Definition: StatusCode.h:82

◆ operator bool()

StatusCode::operator bool ( ) const
inlineexplicit

Shorthand for isSuccess()

Definition at line 145 of file StatusCode.h.

145 { return isSuccess(); }
bool isSuccess() const
Definition: StatusCode.h:361

◆ operator&=()

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

Ternary logic operator with RECOVERABLE being the "third" state.

Definition at line 387 of file StatusCode.h.

387  {
388  // Ternary AND lookup matrix
389  static constexpr StatusCode::code_t AND[3][3] = {{0, 0, 0}, {0, 1, 2}, {0, 2, 2}};
390 
391  StatusCode::code_t l = static_cast<StatusCode::code_t>( default_value() );
392  StatusCode::code_t r = static_cast<StatusCode::code_t>( rhs.default_value() );
393  m_code = AND[l][r];
394  rhs.m_checked = true;
395  return *this;
396 }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
dictionary l
Definition: gaudirun.py:543
ErrorCode default_value() const
Project onto the default StatusCode values.
Definition: StatusCode.h:371
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:63

◆ operator=()

StatusCode& StatusCode::operator= ( const StatusCode rhs)
inlinenoexcept

Definition at line 133 of file StatusCode.h.

133  {
134  m_cat = rhs.m_cat;
135  m_code = rhs.m_code;
136  m_checked = std::exchange( rhs.m_checked, true );
137  return *this;
138  }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

◆ operator|=()

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

Ternary logic operator with RECOVERABLE being the "third" state.

Definition at line 398 of file StatusCode.h.

398  {
399  // Ternary OR lookup matrix
400  static constexpr StatusCode::code_t OR[3][3] = {{0, 1, 2}, {1, 1, 1}, {2, 1, 2}};
401 
402  StatusCode::code_t l = static_cast<StatusCode::code_t>( default_value() );
403  StatusCode::code_t r = static_cast<StatusCode::code_t>( rhs.default_value() );
404  m_code = OR[l][r];
405  rhs.m_checked = true;
406  return *this;
407 }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
dictionary l
Definition: gaudirun.py:543
ErrorCode default_value() const
Project onto the default StatusCode values.
Definition: StatusCode.h:371
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:63

◆ orElse()

template<typename F , typename... ARGS>
StatusCode StatusCode::orElse ( F &&  f,
ARGS &&...  args 
) const
inline

Chain code blocks making the execution conditional a failure result.

Inverse of StatusCode::andThen(), the passed function gets invoked only if if the StatusCode is a failure, in which case it either pass it on or overrides it, If the StatusCode is a success, it is passed on.

For example:

StatusCode myFunction() {
return subFunction()
.andThen([]() {
do_something();
})
.orElse(reportProblem);
}

Definition at line 216 of file StatusCode.h.

216  {
217  if ( isSuccess() ) return *this;
218  return i_invoke( std::forward<F>( f ), std::forward<ARGS>( args )... );
219  }
StatusCode i_invoke(F &&f, ARGS &&... args) const
Helper to invoke a callable and return the resulting StatusCode or this, if the callable returns void...
Definition: StatusCode.h:316
bool isSuccess() const
Definition: StatusCode.h:361

◆ orThrow()

StatusCode StatusCode::orThrow ( std::string  message,
std::string  tag 
) const
inline

Throw a GaudiException in case of failures.

It can be chained with StatusCode::then, behaving as a pass-through for a success StatusCode, while for non-success a GaudiException is thrown, propagating the failure into the exception (using the StatusCode field of the exception).

For example:

void myFunction() {
doSomething()
.andThen( doSomethingElse )
.orThrow( "some error", "myFunction" )
.andThen( moreActions )
.orThrow( "too bad, we were nearly there", "myFunction" );
}

Definition at line 237 of file StatusCode.h.

237  {
238  return orElse( &StatusCode::i_doThrow, this, std::move( message ), std::move( tag ) );
239  }
T move(T... args)
std::string message() const
Description (or name) of StatusCode value.
Definition: StatusCode.h:248
void i_doThrow(std::string message, std::string tag) const
Helper function to avoid circular dependency between GaudiException.h and StatusCode....
Definition: StatusCode.cpp:92
StatusCode orElse(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a failure result.
Definition: StatusCode.h:216

◆ setChecked() [1/2]

const StatusCode& StatusCode::setChecked ( bool  checked = true) const
inline

Check/uncheck StatusCode.

Definition at line 154 of file StatusCode.h.

154  {
155  m_checked = checked;
156  return *this;
157  }
bool checked() const
Has the StatusCode been checked?
Definition: StatusCode.h:242
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305

◆ setChecked() [2/2]

StatusCode& StatusCode::setChecked ( bool  checked = true)
inline

Definition at line 158 of file StatusCode.h.

158  {
159  m_checked = checked;
160  return *this;
161  }
bool checked() const
Has the StatusCode been checked?
Definition: StatusCode.h:242
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const StatusCode lhs,
const StatusCode rhs 
)
friend

Definition at line 259 of file StatusCode.h.

259 { return !( lhs == rhs ); }

◆ operator<

bool operator< ( const StatusCode lhs,
const StatusCode rhs 
)
friend

Comparison (values are grouped by category first)

Definition at line 262 of file StatusCode.h.

262  {
263  lhs.m_checked = true;
264  rhs.m_checked = true;
265  return ( lhs.m_cat < rhs.m_cat || ( lhs.m_cat == rhs.m_cat && lhs.m_code < rhs.m_code ) );
266  }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

◆ operator<<

std::ostream& operator<< ( std::ostream s,
const StatusCode sc 
)
friend

Definition at line 250 of file StatusCode.h.

250  {
251  s << sc.message();
252  return s;
253  }
std::string message() const
Description (or name) of StatusCode value.
Definition: StatusCode.h:248
string s
Definition: gaudirun.py:328

◆ operator==

bool operator== ( const StatusCode lhs,
const StatusCode rhs 
)
friend

Check if StatusCode value and category are the same.

Note
For code values 0(FAILURE) and 1(SUCCESS) the category is ignored
e.g. sc==StatusCode::SUCCESS is equivalent to sc.isSuccess() for all categories

Definition at line 378 of file StatusCode.h.

378  {
379  lhs.m_checked = true;
380  rhs.m_checked = true;
381  return ( lhs.m_code == rhs.m_code ) &&
382  ( lhs.m_code == static_cast<StatusCode::code_t>( StatusCode::ErrorCode::SUCCESS ) ||
383  lhs.m_code == static_cast<StatusCode::code_t>( StatusCode::ErrorCode::FAILURE ) ||
384  ( lhs.m_cat == rhs.m_cat ) );
385 }
code_t m_code
The status code value.
Definition: StatusCode.h:304
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:305
const Category * m_cat
The status code category.
Definition: StatusCode.h:303

Member Data Documentation

◆ FAILURE

constexpr const StatusCode::ErrorCode StatusCode::FAILURE = ErrorCode::FAILURE
static

Definition at line 97 of file StatusCode.h.

◆ m_cat

const Category* StatusCode::m_cat {&default_category()}
private

The status code category.

Definition at line 303 of file StatusCode.h.

◆ m_checked

bool StatusCode::m_checked {false}
mutableprivate

If the StatusCode has been checked.

Definition at line 305 of file StatusCode.h.

◆ m_code

code_t StatusCode::m_code {static_cast<code_t>( ErrorCode::SUCCESS )}
private

The status code value.

Definition at line 304 of file StatusCode.h.

◆ RECOVERABLE

constexpr const StatusCode::ErrorCode StatusCode::RECOVERABLE = ErrorCode::RECOVERABLE
static

Definition at line 98 of file StatusCode.h.

◆ s_checking

bool StatusCode::s_checking
staticprivate

Global flag to control if StatusCode need to be checked.

Definition at line 306 of file StatusCode.h.

◆ SUCCESS

constexpr const StatusCode::ErrorCode StatusCode::SUCCESS = ErrorCode::SUCCESS
static

Definition at line 96 of file StatusCode.h.


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