fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
This commit is contained in:
40
docs/api/core/refcounted/AddRef.md
Normal file
40
docs/api/core/refcounted/AddRef.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# RefCounted::AddRef
|
||||
|
||||
```cpp
|
||||
void AddRef();
|
||||
```
|
||||
|
||||
增加引用计数。
|
||||
|
||||
**描述**
|
||||
|
||||
原子地增加引用计数。在复制 `RefCounted` 指针或传递引用时调用此方法。
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/RefCounted.h>
|
||||
|
||||
class MyObject : public RefCounted {
|
||||
public:
|
||||
void DoSomething() { /* ... */ }
|
||||
};
|
||||
|
||||
// 创建对象(构造时 refCount = 1)
|
||||
MyObject* obj = new MyObject();
|
||||
|
||||
// 手动增加引用
|
||||
obj->AddRef(); // refCount = 2
|
||||
obj->AddRef(); // refCount = 3
|
||||
|
||||
// 需要释放额外的引用
|
||||
obj->Release(); // refCount = 2
|
||||
obj->Release(); // refCount = 1
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RefCounted 总览](refcounted.md) - 返回类总览
|
||||
- [Release](Release.md) - 减少引用计数
|
||||
43
docs/api/core/refcounted/GetRefCount.md
Normal file
43
docs/api/core/refcounted/GetRefCount.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# RefCounted::GetRefCount
|
||||
|
||||
```cpp
|
||||
uint32_t GetRefCount() const;
|
||||
```
|
||||
|
||||
获取当前引用计数。
|
||||
|
||||
**描述**
|
||||
|
||||
返回当前的引用计数值。由于使用 `std::atomic` 实现,因此是线程安全的。
|
||||
|
||||
**返回:** `uint32_t` - 当前引用计数
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/RefCounted.h>
|
||||
|
||||
class MyObject : public RefCounted {
|
||||
public:
|
||||
void Debug() {
|
||||
printf("RefCount: %u\n", GetRefCount());
|
||||
}
|
||||
};
|
||||
|
||||
MyObject* obj = new MyObject();
|
||||
printf("After create: %u\n", obj->GetRefCount()); // 1
|
||||
|
||||
obj->AddRef();
|
||||
printf("After AddRef: %u\n", obj->GetRefCount()); // 2
|
||||
|
||||
obj->Release();
|
||||
printf("After Release: %u\n", obj->GetRefCount()); // 1
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RefCounted 总览](refcounted.md) - 返回类总览
|
||||
- [AddRef](AddRef.md) - 增加引用计数
|
||||
- [Release](Release.md) - 减少引用计数
|
||||
39
docs/api/core/refcounted/Release.md
Normal file
39
docs/api/core/refcounted/Release.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# RefCounted::Release
|
||||
|
||||
```cpp
|
||||
void Release();
|
||||
```
|
||||
|
||||
减少引用计数。
|
||||
|
||||
**描述**
|
||||
|
||||
原子地减少引用计数。当引用计数归零时,对象会自动 `delete this`。这是实现自动内存管理的关键方法。
|
||||
|
||||
**复杂度:** O(1)(归零时为 O(n),n 为对象大小)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/RefCounted.h>
|
||||
|
||||
class MyObject : public RefCounted {
|
||||
public:
|
||||
void DoSomething() { /* ... */ }
|
||||
};
|
||||
|
||||
// 创建对象(构造时 refCount = 1)
|
||||
MyObject* obj = new MyObject();
|
||||
|
||||
// 手动增加引用
|
||||
obj->AddRef(); // refCount = 2
|
||||
|
||||
// 释放引用
|
||||
obj->Release(); // refCount = 1
|
||||
obj->Release(); // refCount = 0, 对象被自动 delete
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RefCounted 总览](refcounted.md) - 返回类总览
|
||||
- [AddRef](AddRef.md) - 增加引用计数
|
||||
44
docs/api/core/refcounted/refcounted.md
Normal file
44
docs/api/core/refcounted/refcounted.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# RefCounted
|
||||
|
||||
**命名空间**: `XCEngine::Core`
|
||||
|
||||
**类型**: `class`
|
||||
|
||||
**描述**: 引用计数基类,提供线程安全的引用计数生命周期管理。
|
||||
|
||||
## 概述
|
||||
|
||||
`RefCounted` 是一个简单的引用计数基类。当引用计数归零时,对象会自动删除。它提供了 `AddRef` 和 `Release` 方法,线程安全地管理引用计数。
|
||||
|
||||
## 公共方法
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `RefCounted()` | 构造函数,初始引用计数为 1 |
|
||||
| `virtual ~RefCounted()` | 虚析构函数 |
|
||||
| [`AddRef`](AddRef.md) | 增加引用计数 |
|
||||
| [`Release`](Release.md) | 减少引用计数(归零时自动 delete this) |
|
||||
| [`GetRefCount`](GetRefCount.md) | 获取当前引用计数 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
class MyObject : public RefCounted {
|
||||
public:
|
||||
MyObject() { /* ... */ }
|
||||
~MyObject() { /* ... */ }
|
||||
|
||||
void DoSomething() { /* ... */ }
|
||||
};
|
||||
|
||||
// 使用
|
||||
MyObject* obj = new MyObject(); // refCount = 1
|
||||
obj->AddRef(); // refCount = 2
|
||||
obj->Release(); // refCount = 1
|
||||
obj->Release(); // refCount = 0, 自动 delete
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Core 模块总览](../core.md) - 返回模块总览
|
||||
- [SmartPtr](../smartptr/smartptr.md) - 智能指针
|
||||
Reference in New Issue
Block a user