- audio: 更新 audio-system 方法文档 - components: 新增 audio-listener/audio-source 组件方法文档,新增 remove-component 方法 - core: 更新 filewriter, types 文档 - math: 更新 box 方法文档 - memory: 更新 proxy-allocator 文档 - resources: 更新 loader 和 texture 文档 - rhi: 更新 opengl 设备、shader、swap-chain 文档 - threading: 更新 mutex 和 task-system 文档
2.1 KiB
2.1 KiB
Core 模块概览
命名空间: XCEngine::Core
类型: module
头文件: XCEngine/Core/Core.h
描述: XCEngine 的核心基础模块,提供类型别名、智能指针、事件系统等基础功能。
概述
Core 模块包含了引擎所需的基础类型和工具,是其他所有模块的依赖基础。
模块内容
类型
| 组件 | 文件 | 描述 |
|---|---|---|
| Types | Types.h |
类型别名定义 |
智能指针
| 组件 | 文件 | 描述 |
|---|---|---|
| SmartPtr | SmartPtr.h |
智能指针别名和工厂函数 |
| RefCounted | RefCounted.h |
引用计数基类 |
事件系统
| 组件 | 文件 | 描述 |
|---|---|---|
| Event | Event.h |
事件系统模板 |
文件操作
| 组件 | 文件 | 描述 |
|---|---|---|
| FileWriter | FileWriter.h |
文件写入工具 |
类型别名
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;
智能指针别名
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);
使用示例
#include <XCEngine/Core/Core.h>
#include <XCEngine/Core/Containers/String.h>
using namespace XCEngine::Core;
// 使用类型别名
uint32 value = 100;
byte data[4];
// 使用智能指针
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);
相关文档
- Containers 模块 - 容器类型
- Memory 模块 - 内存管理