Files
Aethera/mcp/core/runtime/Gallery_Runtime.hpp
T

74 lines
2.3 KiB
C++

#pragma once
#include <Frame_Policy/Frame_Policy.hpp>
#include <nlohmann/json_fwd.hpp>
#include <render_2D/scene/Render_Scene_2D.hpp>
#include <render_3D/scene/Render_Scene_3D.hpp>
#include <atomic>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <variant>
#include <vector>
namespace aethera::web {
enum struct Gallery_Pixel_Layout : std::uint8_t { bgra8, rgba8 };
struct Gallery_Pixel_Frame {
std::shared_ptr<const std::vector<std::byte>> pixels{};
Gallery_Pixel_Layout layout{Gallery_Pixel_Layout::rgba8};
std::chrono::microseconds presentation_time{};
std::uint64_t sequence{};
std::uint64_t correlation_id{};
std::uint64_t rendered_sequence{};
std::uint64_t rendered_correlation_id{};
std::uint32_t width{};
std::uint32_t height{};
};
struct Gallery_Frame {
std::shared_ptr<const Gallery_Pixel_Frame> pixels{};
};
enum struct Gallery_Frame_Publication : std::uint8_t {
ignored,
completed,
asynchronous
};
using Gallery_Frame_Publisher = std::function<Gallery_Frame_Publication(
std::string_view, std::shared_ptr<const Gallery_Frame>)>;
struct Gallery_Component {
virtual ~Gallery_Component() = default;
[[nodiscard]] virtual nlohmann::json schema() const = 0;
[[nodiscard]] virtual nlohmann::json write_prop(
std::string_view component, std::string_view key,
const nlohmann::json& value) = 0;
[[nodiscard]] virtual nlohmann::json component_state(
std::string_view component) const = 0;
[[nodiscard]] virtual nlohmann::json capture_components(
const std::vector<std::string>& components) const = 0;
[[nodiscard]] virtual nlohmann::json data_generator_schema() const = 0;
[[nodiscard]] virtual nlohmann::json generate_data(
const nlohmann::json& input) = 0;
virtual void update(const Frame_Request& request) = 0;
};
using Gallery_Scene = std::variant<
std::unique_ptr<render_2d::Render_Scene_2D>,
std::unique_ptr<render_3d::Render_Scene_3D>>;
using Gallery_Build = std::pair<
std::unique_ptr<Gallery_Component>, Gallery_Scene>;
/* One authoritative Scene and its current policy. */
using Gallery_Runtime = std::pair<
Gallery_Scene, std::atomic<std::shared_ptr<Frame_Policy>>>;
}