1 #ifndef GAUDIKERNEL_STATUSCODE_H 2 #define GAUDIKERNEL_STATUSCODE_H 4 #include "boost/preprocessor/facilities/overload.hpp" 64 constexpr
Category() noexcept =
default;
68 virtual const char*
name()
const = 0;
101 bool checked =
false ) noexcept
109 rhs.m_checked =
true;
114 rhs.m_checked =
true;
125 m_checked = std::exchange( rhs.m_checked,
true );
239 #define STATUSCODE_ENUM_DECL( ENUM ) \ 241 struct is_StatusCode_enum<ENUM> : std::true_type { \ 242 static const StatusCode::Category& instance; \ 248 #define STATUSCODE_ENUM_IMPL( ... ) BOOST_PP_OVERLOAD( STATUSCODE_ENUM_IMPL_, __VA_ARGS__ )( __VA_ARGS__ ) 250 #define STATUSCODE_ENUM_IMPL_1( ENUM ) \ 251 const StatusCode::Category& is_StatusCode_enum<ENUM>::instance = StatusCode::default_category(); 253 #define STATUSCODE_ENUM_IMPL_2( ENUM, CATEGORY ) \ 254 const StatusCode::Category& is_StatusCode_enum<ENUM>::instance = CATEGORY{}; 327 #endif // GAUDIKERNEL_STATUSCODE_H code_t getCode() const
Retrieve value ("checks" the StatusCode)
bool checked() const
Has the StatusCode been checked?
StatusCode operator|(StatusCode lhs, const StatusCode &rhs)
Ternary OR operator.
void check()
Do StatusCode check.
code_t m_code
The status code value.
friend bool operator<(const StatusCode &lhs, const StatusCode &rhs)
Comparison (values are grouped by category first)
bool m_checked
If the StatusCode has been checked.
The category assigned to a StatusCode.
constexpr static const auto RECOVERABLE
StatusCode & operator=(const StatusCode &rhs) noexcept
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)
constexpr static const auto SUCCESS
virtual const char * name() const =0
Name of the category.
StatusCode(code_t code, bool checked) noexcept
Constructor from code_t and category (explicit conversion only)
static GAUDI_API void enableChecking()
StatusCode(const StatusCode &rhs) noexcept
Copy constructor.
static GAUDI_API bool checkingEnabled()
StatusCode & setChecked(bool checked=true)
const StatusCode::Category & getCategory() const
Retrieve category (does not "check" the StatusCode)
virtual bool isSuccess(code_t code) const
Is code considered success ?
friend std::ostream & operator<<(std::ostream &s, const StatusCode &sc)
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
virtual std::string message(code_t code) const
Description for code within this category.
This class is used for returning status codes from appropriate routines.
virtual bool isRecoverable(code_t code) const
Is code considered recoverable ?
friend bool operator!=(const StatusCode &lhs, const StatusCode &rhs)
static const Category & default_category() noexcept
Default Gaudi StatusCode category.
Simple RAII class to ignore unchecked StatusCode instances in a scope.
static bool s_checking
Global flag to control if StatusCode need to be checked.
std::string message() const
Description (or name) of StatusCode value.
StatusCode operator &(StatusCode lhs, const StatusCode &rhs)
Ternary AND operator.
bool operator==(const StatusCode &lhs, const StatusCode &rhs)
const StatusCode & ignore() const
Ignore/check StatusCode.
friend bool operator==(const StatusCode &lhs, const StatusCode &rhs)
Check if StatusCode value and category are the same.
constexpr Category() noexcept=default
bool & operator|=(bool &lhs, const StatusCode &sc)
Boolean OR assignment operator.
bool isRecoverable() const
constexpr static const auto FAILURE
static GAUDI_API void disableChecking()
StatusCode()=default
Default constructor.
bool & operator&=(bool &lhs, const StatusCode &sc)
Boolean AND assignment operator.
StatusCode(StatusCode &&rhs) noexcept
Move constructor.
const StatusCode & setChecked(bool checked=true) const
Check/uncheck StatusCode.
ErrorCode default_value() const
Project onto the default StatusCode values.
const Category * m_cat
The status code category.
StatusCode & operator|=(const StatusCode &rhs)
Ternary logic operator with RECOVERABLE being the "third" state.
StatusCode & operator&=(const StatusCode &rhs)
Ternary logic operator with RECOVERABLE being the "third" state.
unsigned long code_t
type of StatusCode value