#pragma once #include #include #include #include #include namespace aethera::web::detail { enum struct Renderable_Field_Role { prop, state }; template struct Renderable_Field_Role_Attribute; template struct Prop_Field; template struct State_Field; template struct Renderable_Adapter; struct Renderable_Descriptor { public: virtual ~Renderable_Descriptor() = default; [[nodiscard]] virtual std::string_view id() const noexcept = 0; [[nodiscard]] virtual nlohmann::json schema() const = 0; [[nodiscard]] virtual nlohmann::json state() const = 0; [[nodiscard]] virtual nlohmann::json values() const = 0; [[nodiscard]] virtual nlohmann::json write_prop(std::string_view key, const nlohmann::json& value) = 0; }; template struct Renderable_Descriptor_Model final : public Renderable_Descriptor { public: Renderable_Descriptor_Model(std::string id, std::string label, std::string kind, Adapter adapter); [[nodiscard]] std::string_view id() const noexcept override; [[nodiscard]] nlohmann::json schema() const override; [[nodiscard]] nlohmann::json state() const override; [[nodiscard]] nlohmann::json values() const override; [[nodiscard]] nlohmann::json write_prop(std::string_view key, const nlohmann::json& value) override; private: std::string component_id; std::string component_label; std::string component_kind; Adapter adapter; /* 与 Plot 内真实 Renderable 同生共死的无所有权协议视图。 */ }; template [[nodiscard]] std::unique_ptr make_renderable_descriptor( std::string id, std::string label, std::string kind, Adapter adapter); } #include "Renderable_Adapter.ipp"