载入中...
搜索中...
未找到
SceneComponentPayload.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
4
5
7
8#include <functional>
9#include <map>
10#include <string>
11#include <vector>
12
13namespace eve::scene_editing {
14
17
30
39public:
41 ~ISceneComponentPayloadProvider() override = default;
42
44 virtual const std::string& componentType() const = 0;
46 virtual std::vector<SceneComponentPayloadRef> components(const TargetId& scene,
47 const ObjectId& object) const = 0;
50 const SelectionSnapshot& selection) const = 0;
52 virtual std::vector<EditorDiagnostic> validateComponent(const SceneComponentPayloadRef& component) const = 0;
53};
54
62public:
63 using Validator = std::function<std::vector<EditorDiagnostic>()>;
64
66 explicit SceneComponentPropertyBindings(std::string componentType);
68 const std::string& componentType() const override { return componentType_; }
69
72 SelectionItem moduleSelection,
74 IDomainOperationTarget* operations,
75 Validator validator = {});
77 SceneComponentChange unbind(const TargetId& scene, const StableId& component);
78
80 std::vector<SceneComponentPayloadRef> components(const TargetId& scene,
81 const ObjectId& object) const override;
83 Result<IDomainOperationTarget*> payloadOperationTarget(
84 const SelectionSnapshot& selection) const override;
86 std::vector<EditorDiagnostic> validateComponent(
87 const SceneComponentPayloadRef& component) const override;
89 eve::Result<eve::Revision> currentRevision(const SelectionSnapshot& selection) const override;
91 PropertySchema schema(const SelectionSnapshot& selection) const override;
93 PropertyReadResult read(const SelectionSnapshot& selection, const PropertyPath& path) const override;
95 Result<DomainOperation> makeSet(const SelectionSnapshot& selection,
96 const PropertyPath& path, const EditorValue& value,
97 PropertySetMode mode) const override;
99 Result<DomainOperation> makeReset(const SelectionSnapshot& selection,
100 const PropertyPath& path) const override;
101
102private:
103 struct Binding {
104 SceneComponentPayloadRef component;
105 SelectionItem moduleSelection;
106 IPropertyProvider* properties = nullptr;
107 IDomainOperationTarget* operations = nullptr;
108 Validator validator;
109 };
110
112 Result<std::pair<const Binding*, SelectionSnapshot>> translate(
113 const SelectionSnapshot& selection) const;
115 const Binding* find(const TargetId& scene, const StableId& component) const;
116
117 std::string componentType_;
118 std::vector<Binding> bindings_;
119};
120
123public:
125 virtual ~ISceneComponentPayloadTarget() = default;
129 return CapabilityId("eve.editor.target.scene-component-payloads");
130 }
133 const TargetId& scene, const ObjectId& object) const = 0;
140 const SceneComponentPayloadRef& component) const = 0;
141};
142
145public:
155 [[nodiscard]] Result<void> registerProvider(std::shared_ptr<ISceneComponentPayloadProvider> provider);
158
161 const TargetId& scene, const ObjectId& object) const override;
163 Result<IPropertyProvider*> propertyProvider(const SelectionSnapshot& selection) const override;
165 Result<IDomainOperationTarget*> operationTarget(const SelectionSnapshot& selection) const override;
168 const SceneComponentPayloadRef& component) const override;
169
170private:
173};
174
177 std::string channel, const std::vector<SceneComponentPayloadRef>& components, std::uint64_t sequence = 0);
178
179} // namespace eve::scene_editing
#define EVENGINE_API_BACKENDS
Definition Export.h:108
std::function< Numbers(b3JointId)> read
std::map< std::string, PropertyRule > properties
std::unique_ptr< gpgpu::Sequence > sequence
Definition OnnxGpgpu.cpp:43
std::string path
Definition PlayHost.cpp:111
std::weak_ptr< PrimitiveScene > scene
Object::Ptr value
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
Instance-owned publication mechanism shared by capability and domain registries. @ownership The regis...
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.
Owning registry and scene-facing router for component payload providers.
SceneComponentPayloadRegistry()=default
Construct a registry owning its provider publications.
SceneComponentPayloadRegistry & operator=(const SceneComponentPayloadRegistry &)=delete
SceneComponentPayloadRegistry(const SceneComponentPayloadRegistry &)=delete
Reuses existing property/operation targets as scene component payloads.
const std::string & componentType() const override
Component type.
std::function< std::vector< EditorDiagnostic >()> Validator
std::uint64_t Revision
StrongId< CapabilityIdTag > CapabilityId
Definition EditingIds.h:61
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.
SelectionItem public API.
SelectionSnapshot public API.
Stable, pointer-free reference to one editable component instance.
auto operator<=>(const SceneComponentPayloadRef &) const =default
Operator <=>.