2026-03-18 17:49:22 +08:00
|
|
|
# Core 模块概览
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::Core`
|
|
|
|
|
|
|
|
|
|
**类型**: `module`
|
|
|
|
|
|
2026-03-20 02:35:07 +08:00
|
|
|
**头文件**: `XCEngine/Core/Core.h`
|
|
|
|
|
|
2026-03-18 17:49:22 +08:00
|
|
|
**描述**: XCEngine 的核心基础模块,提供类型别名、智能指针、事件系统等基础功能。
|
|
|
|
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
Core 模块包含了引擎所需的基础类型和工具,是其他所有模块的依赖基础。
|
|
|
|
|
|
|
|
|
|
## 模块内容
|
|
|
|
|
|
|
|
|
|
### 类型
|
|
|
|
|
|
|
|
|
|
| 组件 | 文件 | 描述 |
|
|
|
|
|
|------|------|------|
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
| [Types](types/types.md) | `Types.h` | 类型别名定义 |
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
|
|
|
### 智能指针
|
|
|
|
|
|
|
|
|
|
| 组件 | 文件 | 描述 |
|
|
|
|
|
|------|------|------|
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
| [SmartPtr](smartptr/smartptr.md) | `SmartPtr.h` | 智能指针别名和工厂函数 |
|
|
|
|
|
| [RefCounted](refcounted/refcounted.md) | `RefCounted.h` | 引用计数基类 |
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
|
|
|
### 事件系统
|
|
|
|
|
|
|
|
|
|
| 组件 | 文件 | 描述 |
|
|
|
|
|
|------|------|------|
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
| [Event](event/event.md) | `Event.h` | 事件系统模板 |
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
|
|
|
### 文件操作
|
|
|
|
|
|
|
|
|
|
| 组件 | 文件 | 描述 |
|
|
|
|
|
|------|------|------|
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
| [FileWriter](filewriter/filewriter.md) | `FileWriter.h` | 文件写入工具 |
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
|
|
|
## 类型别名
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
using int8 = int8_t;
|
|
|
|
|
using int16 = int16_t;
|
|
|
|
|
using int32 = int32_t;
|
|
|
|
|
using int64 = int64_t;
|
|
|
|
|
using uint8 = uint8_t;
|
|
|
|
|
using uint16 = uint16_t;
|
|
|
|
|
using uint32 = uint32_t;
|
|
|
|
|
using uint64 = uint64_t;
|
|
|
|
|
using byte = uint8_t;
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 智能指针别名
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
template<typename T>
|
|
|
|
|
using Ref = std::shared_ptr<T>;
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
using UniqueRef = std::unique_ptr<T>;
|
|
|
|
|
|
|
|
|
|
template<typename T, typename... Args>
|
|
|
|
|
Ref<T> MakeRef(Args&&... args);
|
|
|
|
|
|
|
|
|
|
template<typename T, typename... Args>
|
|
|
|
|
UniqueRef<T> MakeUnique(Args&&... args);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
#include <XCEngine/Core/Core.h>
|
2026-03-26 01:58:45 +08:00
|
|
|
#include <XCEngine/Core/Containers/String.h>
|
2026-03-19 01:04:30 +08:00
|
|
|
|
|
|
|
|
using namespace XCEngine::Core;
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
|
|
|
// 使用类型别名
|
2026-03-19 01:04:30 +08:00
|
|
|
uint32 value = 100;
|
|
|
|
|
byte data[4];
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
|
|
|
// 使用智能指针
|
|
|
|
|
auto ref = MakeRef<MyClass>();
|
|
|
|
|
auto unique = MakeUnique<MyClass>();
|
|
|
|
|
|
|
|
|
|
// 使用事件系统
|
|
|
|
|
Event<int, float> myEvent;
|
|
|
|
|
myEvent.Subscribe([](int a, float b) {
|
|
|
|
|
printf("Event: %d, %f\n", a, b);
|
|
|
|
|
});
|
|
|
|
|
myEvent.Invoke(42, 3.14f);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
- [Containers 模块](../containers/containers.md) - 容器类型
|
|
|
|
|
- [Memory 模块](../memory/memory.md) - 内存管理
|