rpcsx/orbis-kernel/include/orbis/error/SysResult.hpp
DH 0c16e294d4 merge rpcsx-gpu and rpcsx-os
initial watchdog implementation
implement gpu -> os events
implement main gfx queue
2024-10-12 05:24:58 +03:00

32 lines
732 B
C++

#pragma once
#include <compare>
namespace orbis {
enum class ErrorCode : int;
class SysResult {
int mValue = 0;
public:
SysResult() = default;
SysResult(ErrorCode ec) : mValue(-static_cast<int>(ec)) {}
[[nodiscard]] static SysResult notAnError(ErrorCode ec) {
SysResult result;
result.mValue = static_cast<int>(ec);
return result;
}
[[nodiscard]] int value() const { return mValue < 0 ? -mValue : mValue; }
[[nodiscard]] bool isError() const { return mValue < 0; }
[[nodiscard]] auto operator<=>(ErrorCode ec) const {
return static_cast<ErrorCode>(value()) <=> ec;
}
[[nodiscard]] auto operator<=>(SysResult other) const {
return value() <=> other.value();
}
};
} // namespace orbis