载入中...
搜索中...
未找到
EditorCommandService.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
10
11#include <functional>
12#include <string>
13#include <vector>
14
15namespace eve::editor {
16
17class EditorSession;
18
22 const HostProfile* profile = nullptr;
24 uint64_t targetRevision = 0;
25 CommandSource source = CommandSource::Api;
26};
27
38
39using EditorCommandHandler = std::function<Result<EditorValue>(const CommandContext&, const EditorValue&)>;
40using EditorCommandPlanner = std::function<Result<CommandPlan>(const CommandRequest&)>;
42 std::function<Result<TransactionReceipt>(const CommandRequest&, const CommandPlan&)>;
43
52public:
61 bool replace = false);
71 EditorCommandPlanExecutor executor, bool replace = false);
73 bool unregisterCommand(const CommandId& id, const std::string& ownerModule = {});
75 size_t unregisterOwner(const std::string& ownerModule);
77 void clear();
78
80 const CommandDescriptor* find(const CommandId& id) const;
82 [[nodiscard]] bool supportsPlanning(const CommandId& id) const;
84 std::vector<CommandDescriptor> commands(const HostProfile& profile) const;
86 uint64_t revision() const { return revision_; }
87
95 Result<EditorValue> execute(const CommandId& id, const CommandContext& context,
96 const EditorValue& payload) const;
98 Result<CommandPlan> plan(const CommandRequest& request, const HostProfile& profile) const;
100 Result<TransactionReceipt> executePlan(const CommandRequest& request, const CommandPlan& plan,
101 const HostProfile& profile) const;
102
103private:
104 struct Registration {
107 EditorCommandPlanner planner;
108 EditorCommandPlanExecutor planExecutor;
109 uint64_t generation = 0;
110 };
111
112 static Result<EditorValue> error(EditorStatus status, const char* rule, std::string message);
113 [[nodiscard]] Result<void> checkExecutionPolicy(const CommandDescriptor& descriptor, const CommandId& id,
114 CommandSource source, const EditorValue& payload,
115 const HostProfile& profile) const;
116 std::vector<Registration> commands_;
117 uint64_t revision_ = 0;
118 uint64_t nextRegistrationGeneration_ = 1;
119 mutable uint64_t planSequence_ = 0;
120};
121
122} // namespace eve::editor
Value::Object payload
std::string descriptor
#define EVENGINE_API_ORCHESTRATION
Definition Export.h:111
std::string message
const GltfImportRequest & request
wgpu::PopErrorScopeStatus status
HSQOBJECT handler
std::string error
Definition Package.cpp:60
std::uint32_t generation
const UnitySourceAsset & source
std::vector< VegetationPresetCommand > commands
const VegetationPresetContext & context
Move-only operation result carrying either a value or Status.
Definition Result.h:155
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
Id128 public API.
Definition Identity.h:112
Deterministic owning value tree shared by authoring hosts.
Registry and execution gate for UI-, script- and automation-neutral commands.
uint64_t revision() const
Monotonic registry generation changed by registration mutations.
Hosts interchangeable editor tools and routes their lifecycle/input.
Upper capability boundary for one editor host.
CommandSource
Source that initiated an authoring command.
std::function< Result< TransactionReceipt >(const CommandRequest &, const CommandPlan &)> EditorCommandPlanExecutor
std::function< Result< EditorValue >(const CommandContext &, const EditorValue &)> EditorCommandHandler
HostFeature
Coarse host features used to discover and gate editor extensions.
std::function< Result< CommandPlan >(const CommandRequest &)> EditorCommandPlanner
CommandPlan public API.
CommandRequest public API.
Immutable execution context captured for a synchronous command.
Presentation and execution metadata for a registered command.