docs: update resources API docs
This commit is contained in:
33
docs/api/resources/iresource/isvalid.md
Normal file
33
docs/api/resources/iresource/isvalid.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# IResource::IsValid
|
||||
|
||||
```cpp
|
||||
virtual bool IsValid() const = 0
|
||||
```
|
||||
|
||||
检查资源是否有效。纯虚方法,由具体资源类实现,返回资源当前的有效状态。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** `bool` - 资源有效返回 `true`,无效返回 `false`
|
||||
|
||||
**异常:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ResourceHandle<Texture> tex = ResourceManager::Get().Load<Texture>("textures/player.png");
|
||||
if (tex->IsValid()) {
|
||||
// 资源加载成功,可以使用
|
||||
} else {
|
||||
// 资源加载失败或已被释放
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [IResource 总览](iresource.md) - 返回类总览
|
||||
- [SetInvalid](setinvalid.md) - 将资源标记为无效
|
||||
Reference in New Issue
Block a user