Files
Renderive/web_server/app/Gallery_Protocol.h
T
2026-08-14 19:03:39 +08:00

40 lines
1.7 KiB
C++

#pragma once
#include "common/Gallery_Types.h"
#include <optional>
#include <string>
#include <string_view>
#include <variant>
namespace renderive::web {
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 std::optional<Gallery_Open_Request> open_request(std::string_view message);
[[nodiscard]] static std::optional<Gallery_Action_Request> action_request(std::string_view message);
[[nodiscard]] static std::optional<Gallery_Control_Patch_Request> 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