载入中...
搜索中...
未找到
StepKindRegistry.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
7#include "common/Result.h"
8#include "common/Value.h"
10
11#include <functional>
12#include <map>
13#include <string>
14#include <string_view>
15#include <vector>
16
17namespace eve::dnut {
18
20enum class StepShape : std::uint8_t {
22 Instant,
31 Await,
32};
33
35enum class StepFieldType : std::uint8_t { String, Number, Integer, Boolean, Any };
36
38struct StepField {
39 std::string name;
41 bool required = false;
42};
43
46 std::string type;
47 std::string displayName;
48 std::string category;
50 std::vector<StepField> fields;
59 std::function<eve::Result<void>(const SequenceNode& node)> validate;
60};
61
63enum class StepStatus : std::uint8_t { Completed, Blocked, Failed };
64
71
80 std::string assetId;
81 std::string nodeId;
82 const eve::Value* bindings = nullptr;
83 const eve::Value* locals = nullptr;
92 void* host = nullptr;
93};
94
96using StepHandler = std::function<StepOutcome(const SequenceNode&, const StepContext&)>;
97
109public:
117 [[nodiscard]] eve::Result<void> registerStep(StepKindDescriptor descriptor);
118
125 [[nodiscard]] eve::Result<void> registerHandler(std::string_view type, StepHandler handler);
126
128 void unregisterStep(std::string_view type);
129
131 [[nodiscard]] bool contains(std::string_view type) const;
132
139 [[nodiscard]] const StepKindDescriptor* descriptor(std::string_view type) const;
140
142 [[nodiscard]] std::vector<StepKindDescriptor> descriptors() const;
143
145 [[nodiscard]] bool hasHandler(std::string_view type) const;
146
157 [[nodiscard]] eve::Result<void> validate(const SequenceNode& node) const;
158
169 [[nodiscard]] StepOutcome dispatch(const SequenceNode& node, const StepContext& context) const;
170
171private:
172 std::map<std::string, StepKindDescriptor, std::less<>> descriptors_;
173 std::map<std::string, StepHandler, std::less<>> handlers_;
174};
175
177[[nodiscard]] const char* stepShapeName(StepShape shape) noexcept;
178
179} // namespace eve::dnut
std::string descriptor
#define EVENGINE_API_PLATFORM
Definition Export.h:107
ShaderImageInput shape
HSQOBJECT handler
Move-only, checked operation results for the common layer.
const RoadNode * node
Domain-neutral compiled sequence graph for `.dnut` sources.
Owning, renderer-independent dynamic values.
const VegetationPresetContext & context
Move-only operation result carrying either a value or Status.
Definition Result.h:155
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
Canonical step vocabulary owner and runtime handler router.
StepFieldType
Accepted value kind of one declared payload field.
std::function< StepOutcome(const SequenceNode &, const StepContext &)> StepHandler
Consumer-owned handler for one registered step type.
StepShape
Declares whether a step completes inside its call or suspends the runtime.
@ Await
The step may suspend the runtime.
@ Instant
The step completes synchronously; Completed continues at next.
StepStatus
Terminal state of one dispatched step.
const char * stepShapeName(StepShape shape) noexcept
Return the stable lowercase spelling of a step shape.
@ String
Quoted string with escapes already resolved.
@ Number
Unsigned numeric literal; sign handling belongs to the parser.
One immutable step of a compiled sequence.
Borrowed execution context handed to one step handler.
const eve::Value * bindings
void * host
Opaque consumer context installed by the runtime owner.
const eve::Value * locals
One declared payload field of a step type.
Owning authoring/runtime contract for one step type.
std::vector< StepField > fields
std::function< eve::Result< void >(const SequenceNode &node)> validate
Optional domain invariant applied after the field schema passes.
Structured outcome of one dispatched step.