89 lines
2.9 KiB
C++
89 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include <map>
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <variant>
|
|
|
|
namespace renderive::web {
|
|
|
|
enum class Gallery_Frame_Mode : std::uint8_t {
|
|
Manual,
|
|
Low_Latency,
|
|
Playback
|
|
};
|
|
|
|
struct Gallery_Open_Request {
|
|
std::string case_id;
|
|
Gallery_Frame_Mode frame_mode = Gallery_Frame_Mode::Low_Latency;
|
|
};
|
|
|
|
using Gallery_Value = std::variant<bool, double, std::string>;
|
|
|
|
struct Gallery_State {
|
|
std::map<std::string, Gallery_Value, std::less<>> values;
|
|
};
|
|
|
|
struct Gallery_Patch_Result {
|
|
std::optional<Gallery_State> candidate;
|
|
std::string response_json;
|
|
};
|
|
|
|
struct Gallery_Action_Request {
|
|
std::string id;
|
|
std::optional<Gallery_Value> argument;
|
|
};
|
|
|
|
class Gallery_Protocol final {
|
|
public:
|
|
[[nodiscard]] static std::string catalog_json();
|
|
[[nodiscard]] static bool is_case(std::string_view case_id);
|
|
[[nodiscard]] static Gallery_State default_state(std::string_view case_id);
|
|
[[nodiscard]] static Gallery_State default_state(
|
|
std::string_view case_id, Gallery_Frame_Mode frame_mode);
|
|
[[nodiscard]] static std::string case_json(
|
|
std::string_view case_id,
|
|
const Gallery_State& state,
|
|
std::string_view telemetry_json = "{}",
|
|
std::string_view notice = {});
|
|
[[nodiscard]] static std::string case_json(
|
|
std::string_view case_id,
|
|
const Gallery_State& state,
|
|
std::string_view telemetry_json,
|
|
std::string_view notice,
|
|
Gallery_Frame_Mode frame_mode);
|
|
[[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 Gallery_Patch_Result apply_patch(
|
|
std::string_view case_id,
|
|
const Gallery_State& current,
|
|
std::string_view message);
|
|
[[nodiscard]] static Gallery_Patch_Result apply_patch(
|
|
std::string_view case_id,
|
|
const Gallery_State& current,
|
|
std::string_view message,
|
|
Gallery_Frame_Mode frame_mode);
|
|
[[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::size_t control_count(std::string_view case_id);
|
|
[[nodiscard]] static std::size_t control_count(
|
|
std::string_view case_id, Gallery_Frame_Mode frame_mode);
|
|
[[nodiscard]] static std::size_t action_count(std::string_view case_id);
|
|
[[nodiscard]] static std::size_t action_count(
|
|
std::string_view case_id, Gallery_Frame_Mode frame_mode);
|
|
[[nodiscard]] static bool action_available(
|
|
std::string_view case_id, Gallery_Frame_Mode frame_mode,
|
|
std::string_view action_id);
|
|
};
|
|
|
|
} // namespace renderive::web
|