更完
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "Gallery_Protocol.h"
|
||||
#include "Gallery_Renderables_Adminive.h"
|
||||
#include "Gallery_Renderables.h"
|
||||
#include "Gallery_Session_Control_Adminive.h"
|
||||
|
||||
#include "adminive/adminive.hpp"
|
||||
@@ -489,17 +489,19 @@ std::string Gallery_Protocol::catalog_json() {
|
||||
Json entry = adminive::to_frontend_json<Json>(item);
|
||||
entry["control_count_by_mode"] = Json::object();
|
||||
entry["action_count_by_mode"] = Json::object();
|
||||
const std::size_t controls = gallery_control_count<Gallery_Session_Control>() +
|
||||
gallery_renderable_control_count(item.id);
|
||||
for (const auto mode : frame_modes) {
|
||||
const std::string key(frame_mode_id(mode));
|
||||
const std::size_t mode_controls = control_count(item.id, mode);
|
||||
const std::size_t mode_actions = action_count(item.id, mode);
|
||||
entry["control_count_by_mode"][key] = mode_controls;
|
||||
entry["action_count_by_mode"][key] = mode_actions;
|
||||
controls_total += mode_controls;
|
||||
actions_total += mode_actions;
|
||||
const std::size_t actions = gallery_detail::actions(item.id, mode).size();
|
||||
entry["control_count_by_mode"][key] = controls;
|
||||
entry["action_count_by_mode"][key] = actions;
|
||||
controls_total += controls;
|
||||
actions_total += actions;
|
||||
}
|
||||
entry["control_count"] = control_count(item.id, Gallery_Frame_Mode::Low_Latency);
|
||||
entry["action_count"] = action_count(item.id, Gallery_Frame_Mode::Low_Latency);
|
||||
entry["control_count"] = controls;
|
||||
entry["action_count"] =
|
||||
gallery_detail::actions(item.id, Gallery_Frame_Mode::Low_Latency).size();
|
||||
result["cases"].push_back(std::move(entry));
|
||||
}
|
||||
result["coverage"] = {{"case_count", gallery_detail::cases().size()},
|
||||
@@ -642,67 +644,6 @@ std::optional<Gallery_Control_Patch_Request> Gallery_Protocol::control_patch_req
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t Gallery_Protocol::control_count(std::string_view case_id,
|
||||
Gallery_Frame_Mode frame_mode) {
|
||||
const auto count = [](const auto& self, const Json& fields) -> std::size_t {
|
||||
std::size_t result{};
|
||||
for (const auto& field : fields) {
|
||||
if (field.value("editable", false) && !field.contains("children"))
|
||||
++result;
|
||||
if (field.contains("children"))
|
||||
result += self(self, field.at("children"));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
const auto type_count = [&count]<class T>() {
|
||||
return count(count, adminive::to_descriptor_json<Json, T>().at("fields"));
|
||||
};
|
||||
std::size_t result = type_count.template operator()<Gallery_Session_Control>();
|
||||
if (case_id == "axis_lab")
|
||||
return result + type_count.template operator()<Gallery_Frequency_Axis>() +
|
||||
type_count.template operator()<Gallery_Time_Axis>();
|
||||
if (case_id == "spectrum" || case_id == "selection_overlay") {
|
||||
result += type_count.template operator()<Gallery_Frequency_Axis>() +
|
||||
type_count.template operator()<Gallery_Axis>() +
|
||||
type_count.template operator()<Gallery_Spectrum>();
|
||||
if (case_id == "selection_overlay")
|
||||
result += type_count.template operator()<Gallery_Selection_Rectangle_Overlay>();
|
||||
return result;
|
||||
}
|
||||
if (case_id == "waterfall")
|
||||
return result + type_count.template operator()<Gallery_Frequency_Axis>() +
|
||||
type_count.template operator()<Gallery_Time_Axis>() +
|
||||
type_count.template operator()<Gallery_Waterfall>();
|
||||
if (case_id == "afterglow")
|
||||
return result + type_count.template operator()<Gallery_Frequency_Axis>() +
|
||||
type_count.template operator()<Gallery_Axis>() +
|
||||
type_count.template operator()<Gallery_Afterglow>();
|
||||
if (case_id == "sweep_spectrum")
|
||||
return result + 2 * type_count.template operator()<Gallery_Axis>() +
|
||||
type_count.template operator()<Gallery_Sweep_Spectrum>();
|
||||
if (case_id == "frequency_trace")
|
||||
return result + type_count.template operator()<Gallery_Time_Axis>() +
|
||||
type_count.template operator()<Gallery_Axis>() +
|
||||
type_count.template operator()<Gallery_Frequency_Trace>();
|
||||
if (case_id == "constellation")
|
||||
return result + 2 * type_count.template operator()<Gallery_Axis>() +
|
||||
type_count.template operator()<Gallery_Constellation_Diagram>();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::size_t Gallery_Protocol::control_count(std::string_view case_id) {
|
||||
return control_count(case_id, Gallery_Frame_Mode::Low_Latency);
|
||||
}
|
||||
|
||||
std::size_t Gallery_Protocol::action_count(std::string_view case_id,
|
||||
Gallery_Frame_Mode frame_mode) {
|
||||
return gallery_detail::actions(case_id, frame_mode).size();
|
||||
}
|
||||
|
||||
std::size_t Gallery_Protocol::action_count(std::string_view case_id) {
|
||||
return action_count(case_id, Gallery_Frame_Mode::Low_Latency);
|
||||
}
|
||||
|
||||
bool Gallery_Protocol::action_available(std::string_view case_id,
|
||||
Gallery_Frame_Mode frame_mode,
|
||||
std::string_view action_id) {
|
||||
|
||||
Reference in New Issue
Block a user