MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / ResourceId

Class ResourceId

src/task/include/resource_id.hpp:77–162  ·  view source on GitHub ↗

* @brief 资源 ID * * [63:56] - 资源类型 (8 bits) * [55:0] - 资源数据 (56 bits) */

Source from the content-addressed store, hash-verified

75 * [55:0] - 资源数据 (56 bits)
76 */
77class ResourceId {
78 public:
79 /**
80 * @brief 获取资源类型
81 * @return ResourceType 资源类型
82 */
83 [[nodiscard]] constexpr auto GetType() const -> ResourceType {
84 return static_cast<ResourceType>((value_ >> kTypeShift) & 0xFF);
85 }
86
87 /**
88 * @brief 获取资源数据
89 * @return uint64_t 资源数据
90 */
91 [[nodiscard]] constexpr auto GetData() const -> uint64_t {
92 return value_ & kDataMask;
93 }
94
95 /**
96 * @brief 获取类型名称(用于调试)
97 * @return const char* 资源类型名称
98 */
99 [[nodiscard]] constexpr auto GetTypeName() const -> const char* {
100 return GetResourceTypeName(GetType());
101 }
102
103 /**
104 * @brief 检查是否为有效资源
105 * @return bool 有效返回 true,无效返回 false
106 */
107 constexpr explicit operator bool() const {
108 return GetType() != ResourceType::kNone;
109 }
110
111 /**
112 * @brief 隐式转换到 uint64_t(用于存储和比较)
113 * @return uint64_t 内部存储值
114 */
115 constexpr operator uint64_t() const { return value_; }
116
117 /**
118 * @brief 相等比较操作符
119 * @param other 另一个资源 ID
120 * @return bool 相等返回 true
121 */
122 constexpr auto operator==(const ResourceId& other) const -> bool {
123 return value_ == other.value_;
124 }
125
126 /**
127 * @brief 不等比较操作符
128 * @param other 另一个资源 ID
129 * @return bool 不相等返回 true
130 */
131 constexpr auto operator!=(const ResourceId& other) const -> bool {
132 return value_ != other.value_;
133 }
134

Callers 2

WaitMethod · 0.85
ExitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected