The Gaudi Framework  v33r1 (b1225454)
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 67 of file StatusCode.h.

Member Enumeration Documentation

◆ ErrorCode

Enumerator
FAILURE 
SUCCESS 
RECOVERABLE 

Definition at line 69 of file StatusCode.h.

69 : code_t { FAILURE = 0, SUCCESS = 1, RECOVERABLE = 2 };
constexpr static const auto RECOVERABLE
Definition: StatusCode.h:102
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
constexpr static const auto FAILURE
Definition: StatusCode.h:101
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:67

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

109  {
110  *this = StatusCode( static_cast<StatusCode::code_t>( sc ), is_StatusCode_enum<T>::instance );
111  m_checked = checked;
112  }
bool checked() const
Has the StatusCode been checked?
Definition: StatusCode.h:246
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
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 115 of file StatusCode.h.

117  : m_cat( &cat ), m_code( code ), m_checked( checked ) {}
bool checked() const
Has the StatusCode been checked?
Definition: StatusCode.h:246
code_t m_code
The status code value.
Definition: StatusCode.h:308
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
const Category * m_cat
The status code category.
Definition: StatusCode.h:307

◆ StatusCode() [4/6]

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

Constructor from code_t and category (explicit conversion only)

Definition at line 120 of file StatusCode.h.

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

◆ StatusCode() [5/6]

StatusCode::StatusCode ( const StatusCode rhs)
inlinenoexcept

Copy constructor.

Definition at line 123 of file StatusCode.h.

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

◆ StatusCode() [6/6]

StatusCode::StatusCode ( StatusCode &&  rhs)
inlinenoexcept

Move constructor.

Definition at line 128 of file StatusCode.h.

128  : m_cat( rhs.m_cat ), m_code( rhs.m_code ), m_checked( rhs.m_checked ) {
129  rhs.m_checked = true;
130  }
code_t m_code
The status code value.
Definition: StatusCode.h:308
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
const Category * m_cat
The status code category.
Definition: StatusCode.h:307

◆ ~StatusCode()

StatusCode::~StatusCode ( )
inline

Destructor.

Definition at line 133 of file StatusCode.h.

133  {
134  if ( UNLIKELY( s_checking ) ) check();
135  }
#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:310

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

198  {
199  if ( isFailure() ) return *this;
200  return i_invoke( std::forward<F>( f ), std::forward<ARGS>( args )... );
201  }
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:320
bool isFailure() const
Definition: StatusCode.h:145

◆ 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:309
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 246 of file StatusCode.h.

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

◆ 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:310

◆ default_category()

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

Default Gaudi StatusCode category.

Definition at line 361 of file StatusCode.h.

◆ default_value()

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

Project onto the default StatusCode values.

Definition at line 375 of file StatusCode.h.

375  {
376  bool save_checked = m_checked; // Preserve checked status
378  m_checked = save_checked;
379  return r;
380 }
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
bool isSuccess() const
Definition: StatusCode.h:365
bool isRecoverable() const
Definition: StatusCode.h:370

◆ 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:310

◆ 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:310

◆ getCategory()

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

Retrieve category (does not "check" the StatusCode)

Definition at line 249 of file StatusCode.h.

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

◆ getCode()

code_t StatusCode::getCode ( ) const
inline

Retrieve value ("checks" the StatusCode)

Definition at line 152 of file StatusCode.h.

152  {
153  m_checked = true;
154  return m_code;
155  }
code_t m_code
The status code value.
Definition: StatusCode.h:308
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309

◆ 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:252

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

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

◆ ignore() [1/2]

const StatusCode& StatusCode::ignore ( ) const
inline

Ignore/check StatusCode.

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:158

◆ ignore() [2/2]

StatusCode& StatusCode::ignore ( )
inline

Definition at line 172 of file StatusCode.h.

172  {
173  setChecked( true );
174  return *this;
175  }
const StatusCode & setChecked(bool checked=true) const
Check/uncheck StatusCode.
Definition: StatusCode.h:158

◆ isFailure()

bool StatusCode::isFailure ( ) const
inline

Definition at line 145 of file StatusCode.h.

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

◆ isRecoverable()

bool StatusCode::isRecoverable ( ) const
inline

Definition at line 370 of file StatusCode.h.

370  {
371  m_checked = true;
372  return m_cat->isRecoverable( m_code );
373 }
code_t m_code
The status code value.
Definition: StatusCode.h:308
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
virtual bool isRecoverable(code_t code) const
Is code considered recoverable ?
Definition: StatusCode.h:93
const Category * m_cat
The status code category.
Definition: StatusCode.h:307

◆ isSuccess()

bool StatusCode::isSuccess ( ) const
inline

Definition at line 365 of file StatusCode.h.

365  {
366  m_checked = true;
367  return ( m_code == static_cast<code_t>( ErrorCode::SUCCESS ) || m_cat->isSuccess( m_code ) );
368 }
code_t m_code
The status code value.
Definition: StatusCode.h:308
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
virtual bool isSuccess(code_t code) const
Is code considered success ?
Definition: StatusCode.h:90
const Category * m_cat
The status code category.
Definition: StatusCode.h:307

◆ message()

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

Description (or name) of StatusCode value.

Definition at line 252 of file StatusCode.h.

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

◆ operator bool()

StatusCode::operator bool ( ) const
inlineexplicit

Shorthand for isSuccess()

Definition at line 149 of file StatusCode.h.

149 { return isSuccess(); }
bool isSuccess() const
Definition: StatusCode.h:365

◆ operator&=()

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

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

Definition at line 391 of file StatusCode.h.

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

◆ operator=()

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

Definition at line 137 of file StatusCode.h.

137  {
138  m_cat = rhs.m_cat;
139  m_code = rhs.m_code;
140  m_checked = std::exchange( rhs.m_checked, true );
141  return *this;
142  }
code_t m_code
The status code value.
Definition: StatusCode.h:308
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
const Category * m_cat
The status code category.
Definition: StatusCode.h:307

◆ operator|=()

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

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

Definition at line 402 of file StatusCode.h.

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

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

220  {
221  if ( isSuccess() ) return *this;
222  return i_invoke( std::forward<F>( f ), std::forward<ARGS>( args )... );
223  }
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:320
bool isSuccess() const
Definition: StatusCode.h:365

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

241  {
242  return orElse( &StatusCode::i_doThrow, this, std::move( message ), std::move( tag ) );
243  }
T move(T... args)
std::string message() const
Description (or name) of StatusCode value.
Definition: StatusCode.h:252
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:220

◆ setChecked() [1/2]

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

Check/uncheck StatusCode.

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:246
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309

◆ setChecked() [2/2]

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

Definition at line 162 of file StatusCode.h.

162  {
163  m_checked = checked;
164  return *this;
165  }
bool checked() const
Has the StatusCode been checked?
Definition: StatusCode.h:246
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309

Friends And Related Function Documentation

◆ operator!=

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

Definition at line 263 of file StatusCode.h.

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

◆ operator<

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

Comparison (values are grouped by category first)

Definition at line 266 of file StatusCode.h.

266  {
267  lhs.m_checked = true;
268  rhs.m_checked = true;
269  return ( lhs.m_cat < rhs.m_cat || ( lhs.m_cat == rhs.m_cat && lhs.m_code < rhs.m_code ) );
270  }
code_t m_code
The status code value.
Definition: StatusCode.h:308
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
const Category * m_cat
The status code category.
Definition: StatusCode.h:307

◆ operator<<

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

Definition at line 254 of file StatusCode.h.

254  {
255  s << sc.message();
256  return s;
257  }
std::string message() const
Description (or name) of StatusCode value.
Definition: StatusCode.h:252
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 382 of file StatusCode.h.

382  {
383  lhs.m_checked = true;
384  rhs.m_checked = true;
385  return ( lhs.m_code == rhs.m_code ) &&
386  ( lhs.m_code == static_cast<StatusCode::code_t>( StatusCode::ErrorCode::SUCCESS ) ||
387  lhs.m_code == static_cast<StatusCode::code_t>( StatusCode::ErrorCode::FAILURE ) ||
388  ( lhs.m_cat == rhs.m_cat ) );
389 }
code_t m_code
The status code value.
Definition: StatusCode.h:308
bool m_checked
If the StatusCode has been checked.
Definition: StatusCode.h:309
const Category * m_cat
The status code category.
Definition: StatusCode.h:307

Member Data Documentation

◆ FAILURE

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

Definition at line 101 of file StatusCode.h.

◆ m_cat

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

The status code category.

Definition at line 307 of file StatusCode.h.

◆ m_checked

bool StatusCode::m_checked {false}
mutableprivate

If the StatusCode has been checked.

Definition at line 309 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 308 of file StatusCode.h.

◆ RECOVERABLE

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

Definition at line 102 of file StatusCode.h.

◆ s_checking

bool StatusCode::s_checking
staticprivate

Global flag to control if StatusCode need to be checked.

Definition at line 310 of file StatusCode.h.

◆ SUCCESS

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

Definition at line 100 of file StatusCode.h.


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