载入中...
搜索中...
未找到
EditorCommandService.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
10#include "editor/EditorValue.h"
11
12#include <functional>
13#include <string>
14#include <vector>
15
16namespace eve::editor {
17
18class EditorSession;
19
23 const HostProfile* profile = nullptr;
25 uint64_t targetRevision = 0;
26 CommandSource source = CommandSource::Api;
27};
28
47
48using EditorCommandHandler = std::function<Result<EditorValue>(const CommandContext&, const EditorValue&)>;
49using EditorCommandPlanner = std::function<Result<CommandPlan>(const CommandRequest&)>;
51 std::function<Result<TransactionReceipt>(const CommandRequest&, const CommandPlan&)>;
52
61public:
70 bool replace = false);
80 EditorCommandPlanExecutor executor, bool replace = false);
82 bool unregisterCommand(const CommandId& id, const std::string& ownerModule = {});
84 size_t unregisterOwner(const std::string& ownerModule);
86 void clear();
87
89 const CommandDescriptor* find(const CommandId& id) const;
91 [[nodiscard]] bool supportsPlanning(const CommandId& id) const;
93 std::vector<CommandDescriptor> commands(const HostProfile& profile) const;
95 uint64_t revision() const { return revision_; }
96
104 Result<EditorValue> execute(const CommandId& id, const CommandContext& context,
105 const EditorValue& payload) const;
107 Result<CommandPlan> plan(const CommandRequest& request, const HostProfile& profile) const;
109 Result<TransactionReceipt> executePlan(const CommandRequest& request, const CommandPlan& plan,
110 const HostProfile& profile) const;
111
112private:
113 struct Registration {
116 EditorCommandPlanner planner;
117 EditorCommandPlanExecutor planExecutor;
118 uint64_t generation = 0;
119 };
120
121 static Result<EditorValue> error(EditorStatus status, const char* rule, std::string message);
122 [[nodiscard]] Result<void> checkExecutionPolicy(const CommandDescriptor& descriptor, const CommandId& id,
123 CommandSource source, const EditorValue& payload,
124 const HostProfile& profile) const;
125 std::vector<Registration> commands_;
126 uint64_t revision_ = 0;
127 uint64_t nextRegistrationGeneration_ = 1;
128 mutable uint64_t planSequence_ = 0;
129};
130
131} // namespace eve::editor
Value::Object payload
std::string descriptor
Generation generation
Definition ECS.cpp:40
#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:174
std::string_view source
std::vector< VegetationPresetCommand > commands
const VegetationPresetContext & context
Move-only operation result carrying either a value or Status.
Definition Result.h:176
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
Id128 public API.
Definition Identity.h:111
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.
EVENGINE_API_PLATFORM public API.
Immutable execution context captured for a synchronous command.
Presentation and execution metadata for a registered command.
std::string panelContext
Bound workspace panel context.
std::string panelCapability
Bound workspace panel capability (panel-before-automation).
PropertySchema payloadSchema
Payload schema projected to MCP inputSchema / Inspector.
std::vector< std::string > targetKinds
Target type names this command may bind.