#pragma once #include "common/Gallery_Types.h" #include #include #include #include namespace renderive::web { enum class Gallery_Request_Error { none, invalid_json, wrong_message_type, missing_field, invalid_field }; template struct Gallery_Request_Result { std::optional value; Gallery_Request_Error error{}; [[nodiscard]] explicit operator bool() const noexcept { return error == Gallery_Request_Error::none && value.has_value(); } [[nodiscard]] const Value* operator->() const noexcept { return &*value; } [[nodiscard]] const Value& operator*() const noexcept { return *value; } }; struct Gallery_Open_Request { std::string case_id; Gallery_Frame_Mode frame_mode = Gallery_Frame_Mode::Low_Latency; }; struct Gallery_Control_Patch_Request { std::string target; std::string patch_json; }; class Gallery_Protocol final { public: [[nodiscard]] static std::string catalog_json(); [[nodiscard]] static bool is_case(std::string_view case_id); [[nodiscard]] static std::string error_json(std::string_view message, std::string_view field = {}); [[nodiscard]] static std::string observer_json(std::string_view case_id, Gallery_Frame_Mode frame_mode, std::string_view telemetry_json); [[nodiscard]] static std::string case_json_from_controls( std::string_view case_id, std::string_view controls_json, std::string_view telemetry_json, std::string_view notice, Gallery_Frame_Mode frame_mode, bool manual_refresh); [[nodiscard]] static Gallery_Request_Result open_request(std::string_view message); [[nodiscard]] static Gallery_Request_Result action_request(std::string_view message); [[nodiscard]] static Gallery_Request_Result control_patch_request( std::string_view message); [[nodiscard]] static bool action_available(std::string_view case_id, Gallery_Frame_Mode frame_mode, std::string_view action_id); }; } // namespace renderive::web