载入中...
搜索中...
未找到
SceneComponentPayload.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
6
7#include <functional>
8#include <map>
9#include <string>
10#include <vector>
11
12namespace eve::scene_editing {
13
16
19 TargetId target;
20 ObjectId object;
21 StableId component;
22 std::string type;
23 std::uint64_t generation = 0;
25
27 auto operator<=>(const SceneComponentPayloadRef&) const = default;
28};
29
38public:
40 ~ISceneComponentPayloadProvider() override = default;
41
43 virtual const std::string& componentType() const = 0;
45 virtual std::vector<SceneComponentPayloadRef> components(const TargetId& scene,
46 const ObjectId& object) const = 0;
49 const SelectionSnapshot& selection) const = 0;
51 virtual std::vector<EditorDiagnostic> validateComponent(const SceneComponentPayloadRef& component) const = 0;
52};
53
61public:
62 using Validator = std::function<std::vector<EditorDiagnostic>()>;
63
65 explicit SceneComponentPropertyBindings(std::string componentType);
67 const std::string& componentType() const override { return componentType_; }
68
71 SelectionItem moduleSelection,
73 IDomainOperationTarget* operations,
74 Validator validator = {});
76 SceneComponentChange unbind(const TargetId& scene, const StableId& component);
77
79 std::vector<SceneComponentPayloadRef> components(const TargetId& scene,
80 const ObjectId& object) const override;
82 Result<IDomainOperationTarget*> payloadOperationTarget(
83 const SelectionSnapshot& selection) const override;
85 std::vector<EditorDiagnostic> validateComponent(
86 const SceneComponentPayloadRef& component) const override;
88 eve::Result<eve::Revision> currentRevision(const SelectionSnapshot& selection) const override;
90 PropertySchema schema(const SelectionSnapshot& selection) const override;
92 PropertyReadResult read(const SelectionSnapshot& selection, const PropertyPath& path) const override;
94 Result<DomainOperation> makeSet(const SelectionSnapshot& selection,
95 const PropertyPath& path, const EditorValue& value,
96 PropertySetMode mode) const override;
98 Result<DomainOperation> makeReset(const SelectionSnapshot& selection,
99 const PropertyPath& path) const override;
100
101private:
102 struct Binding {
103 SceneComponentPayloadRef component;
104 SelectionItem moduleSelection;
105 IPropertyProvider* properties = nullptr;
106 IDomainOperationTarget* operations = nullptr;
107 Validator validator;
108 };
109
111 Result<std::pair<const Binding*, SelectionSnapshot>> translate(
112 const SelectionSnapshot& selection) const;
114 const Binding* find(const TargetId& scene, const StableId& component) const;
115
116 std::string componentType_;
117 std::vector<Binding> bindings_;
118};
119
122public:
124 virtual ~ISceneComponentPayloadTarget() = default;
126 static CapabilityId editorCapabilityId() {
128 return CapabilityId("eve.editor.target.scene-component-payloads");
129 }
132 const TargetId& scene, const ObjectId& object) const = 0;
139 const SceneComponentPayloadRef& component) const = 0;
140};
141
144public:
146 Result<void> registerProvider(ISceneComponentPayloadProvider* provider);
148 SceneComponentChange unregisterProvider(ISceneComponentPayloadProvider* provider);
149
152 const TargetId& scene, const ObjectId& object) const override;
154 Result<IPropertyProvider*> propertyProvider(const SelectionSnapshot& selection) const override;
156 Result<IDomainOperationTarget*> operationTarget(const SelectionSnapshot& selection) const override;
159 const SceneComponentPayloadRef& component) const override;
160
161private:
162 Result<ISceneComponentPayloadProvider*> resolve(const SelectionSnapshot& selection) const;
163 std::map<std::string, ISceneComponentPayloadProvider*> providers_;
164};
165
168 std::string channel, const std::vector<SceneComponentPayloadRef>& components, std::uint64_t sequence = 0);
169
170} // namespace eve::scene_editing
double value
#define EVENGINE_API_BACKENDS
Definition Export.h:108
std::map< std::string, PropertyRule > properties
std::unique_ptr< gpgpu::Sequence > sequence
Definition OnnxGpgpu.cpp:43
std::string path
Definition PlayHost.cpp:110
std::weak_ptr< PrimitiveScene > scene
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Editable-target capability that applies owning domain operations.
UI-independent property access for an immutable selection snapshot.
Module-owned adapter for one scene component payload type.
virtual std::vector< EditorDiagnostic > validateComponent(const SceneComponentPayloadRef &component) const =0
Validate the current payload and return inspector diagnostics.
virtual const std::string & componentType() const =0
Stable component type handled by this provider.
virtual Result< IDomainOperationTarget * > payloadOperationTarget(const SelectionSnapshot &selection) const =0
Resolve the authoritative mutation target for one component selection.
~ISceneComponentPayloadProvider() override=default
Releases ISceneComponentPayloadProvider resources.
virtual std::vector< SceneComponentPayloadRef > components(const TargetId &scene, const ObjectId &object) const =0
Enumerate immutable component references attached to one object.
Scene capability that discovers and routes module-owned component payload editors.
virtual Result< IDomainOperationTarget * > operationTarget(const SelectionSnapshot &selection) const =0
Resolve the operation target that must receive the provider's planned operations.
virtual Result< std::vector< SceneComponentPayloadRef > > componentPayloads(const TargetId &scene, const ObjectId &object) const =0
Enumerate all registered component payloads on one scene object.
static CapabilityId editorCapabilityId()
Stable capability id for editable scene component payloads.
virtual Result< std::vector< EditorDiagnostic > > validatePayload(const SceneComponentPayloadRef &component) const =0
Validate a stable component reference using its owning module.
virtual ~ISceneComponentPayloadTarget()=default
Releases ISceneComponentPayloadTarget resources.
virtual Result< IPropertyProvider * > propertyProvider(const SelectionSnapshot &selection) const =0
Resolve the property provider for a homogeneous component selection.
Non-owning registry and scene-facing router for component payload providers.
Reuses existing property/operation targets as scene component payloads.
const std::string & componentType() const override
Component type.
std::function< std::vector< EditorDiagnostic >()> Validator
Result< SelectionSnapshot > makeSceneComponentSelection(std::string channel, const std::vector< SceneComponentPayloadRef > &components, std::uint64_t sequence)
Build a property selection for one or more homogeneous component references.
SceneComponentChange
Whether a registry or binding removal changed authoritative state.
detail::StrongUint64< detail::RevisionTag > Revision
Monotonic content/state revision used for optimistic-concurrency checks.
Definition Revision.h:13
SelectionItem public API.
SelectionSnapshot public API.
Stable, pointer-free reference to one editable component instance.
auto operator<=>(const SceneComponentPayloadRef &) const =default
Operator <=>.