GFSavePipelineContext¶
API Reference / Save / 类索引
- 路径:
addons/gf/extensions/save/pipeline/gf_save_pipeline_context.gd - 模块:
Save - 继承:
RefCounted - API:
public - 类别:值对象 (
value_object) - 首次版本:
3.17.0
存档图流程上下文。 在一次 gather/apply 操作中收集通用事件、警告、错误与共享数据。 上下文通过调用者传入的 context 字典传播,不要求存档载荷写死任何字段。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 属性 | operation |
var operation: StringName = &"" |
| 属性 | root_scope_key |
var root_scope_key: StringName = &"" |
| 属性 | shared |
var shared: Dictionary = {} |
| 属性 | events |
var events: Array[GFSavePipelineEvent] = [] |
| 属性 | warnings |
var warnings: PackedStringArray = PackedStringArray() |
| 属性 | errors |
var errors: PackedStringArray = PackedStringArray() |
| 属性 | started_at_msec |
var started_at_msec: int = 0 |
| 属性 | finished_at_msec |
var finished_at_msec: int = 0 |
| 方法 | begin_operation |
func begin_operation( p_operation: StringName, p_root_scope_key: StringName = &"", p_shared: Dictionary = {} ) -> GFSavePipelineContext: |
| 方法 | record_event |
func record_event( stage: StringName, scope: Object = null, source: Object = null, message: String = "", payload: Dictionary = {}, severity: StringName = &"info" ) -> GFSavePipelineEvent: |
| 方法 | add_warning |
func add_warning(message: String, payload: Dictionary = {}) -> void: |
| 方法 | add_error |
func add_error(message: String, payload: Dictionary = {}) -> void: |
| 方法 | finish |
func finish() -> void: |
| 方法 | is_finished |
func is_finished() -> bool: |
| 方法 | get_elapsed_msec |
func get_elapsed_msec() -> int: |
| 方法 | to_dict |
func to_dict(include_events: bool = true) -> Dictionary: |
属性¶
operation¶
- API:
public
当前操作类型,如 gather 或 apply。
root_scope_key¶
- API:
public
根作用域键。
shared¶
- API:
public
流程共享数据。项目层可写入自己的临时状态。
结构:
shared: Dictionary,一次流程中的临时共享字段,不会自动写入存档载荷。
events¶
- API:
public
流程事件列表。
warnings¶
- API:
public
通用警告信息。
errors¶
- API:
public
通用错误信息。
started_at_msec¶
- API:
public
开始时间。
finished_at_msec¶
- API:
public
结束时间。
方法¶
begin_operation¶
- API:
public
func begin_operation( p_operation: StringName, p_root_scope_key: StringName = &"", p_shared: Dictionary = {} ) -> GFSavePipelineContext:
开始一次流程操作。
参数:
| 名称 | 说明 |
|---|---|
p_operation |
操作类型。 |
p_root_scope_key |
根作用域键。 |
p_shared |
初始共享数据。 |
返回:当前上下文。
结构:
p_shared: Dictionary,一次流程中的临时共享字段,不会自动写入存档载荷。
record_event¶
- API:
public
func record_event( stage: StringName, scope: Object = null, source: Object = null, message: String = "", payload: Dictionary = {}, severity: StringName = &"info" ) -> GFSavePipelineEvent:
记录流程事件。
参数:
| 名称 | 说明 |
|---|---|
stage |
阶段标识。 |
scope |
可选 Scope。 |
source |
可选 Source。 |
message |
调试消息。 |
payload |
附加载荷。 |
severity |
严重级别。 |
返回:新事件。
结构:
payload: Dictionary,项目或流程步骤附加的诊断字段。
add_warning¶
- API:
public
记录警告并同步生成 warning 事件。
参数:
| 名称 | 说明 |
|---|---|
message |
警告内容。 |
payload |
附加载荷。 |
结构:
payload: Dictionary,项目或流程步骤附加的诊断字段。
add_error¶
- API:
public
记录错误并同步生成 error 事件。
参数:
| 名称 | 说明 |
|---|---|
message |
错误内容。 |
payload |
附加载荷。 |
结构:
payload: Dictionary,项目或流程步骤附加的诊断字段。
finish¶
- API:
public
标记流程结束。
is_finished¶
- API:
public
当前流程是否已结束。
返回:已结束返回 true。
get_elapsed_msec¶
- API:
public
获取耗时毫秒。
返回:耗时。
to_dict¶
- API:
public
转换为 Dictionary。
参数:
| 名称 | 说明 |
|---|---|
include_events |
是否包含事件列表。 |
返回:上下文字典。
结构:
return: Dictionary,包含 operation、root_scope_key、shared、warnings、errors、started_at_msec、finished_at_msec、elapsed_msec、event_count;include_events 为 true 时包含 events: Array[Dictionary]。