MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
SchedulerQuery.cpp
Go to the documentation of this file.
1#include "Inspector.hpp"
2
5
7
9
11
13 const Vruta::TaskEntry& entry,
14 Surface& surface,
15 LayoutCursor& cursor,
16 float x_min, float x_max, float row_h)
17{
18 auto routine = entry.routine;
19 const std::string name = entry.name;
20
21 std::vector<ValueSpec> values {
22 ValueSpec {
23 .label = "name",
24 .reader = [name] { return name.empty() ? "(unnamed)" : name; },
25 },
26 ValueSpec {
27 .label = "token",
28 .reader = [routine] {
29 return std::string(Reflect::enum_to_string(routine->get_processing_token()));
30 },
31 },
32 ValueSpec {
33 .label = "active",
34 .reader = [routine] { return routine->is_active() ? "true" : "false"; },
35 },
36 ValueSpec {
37 .label = "delay",
38 .reader = [routine] {
39 return std::string(Reflect::enum_to_string(routine->get_delay_context()));
40 },
41 },
42 };
43
44 const auto dims = row_pixel_dims(surface.window(), x_min, x_max, row_h);
45 auto hbuf = make_row_buffer(surface.window(), Reflect::short_dynamic_type_name(*entry.routine), dims);
46 std::vector<RowBuffer> rbufs;
47 rbufs.reserve(values.size());
48 for (const auto& spec : values)
49 rbufs.push_back(make_row_buffer(surface.window(), spec.label, dims));
50
51 auto group = make_value_group(values, std::move(hbuf), rbufs,
52 surface, cursor, x_min, x_max, row_h, false);
53
54 InspectResult result;
55 result.group = std::move(group);
56 return result;
57}
58
60 Surface& surface,
61 LayoutCursor& cursor,
62 float x_min, float x_max, float row_h)
63{
65 return *s_scheduler_result;
66 }
67
68 const std::vector<ValueSpec> root_values {
69 ValueSpec {
70 .label = "tasks",
71 .reader = [&m_sched = m_sched] {
72 return std::to_string(m_sched.get_all_tasks().size());
73 },
74 },
75 };
76
77 const auto dims = row_pixel_dims(surface.window(), x_min, x_max, row_h);
78 auto hbuf = make_row_buffer(surface.window(), "TaskScheduler", dims);
79 std::vector<RowBuffer> rbufs;
80 rbufs.reserve(root_values.size());
81 for (const auto& spec : root_values)
82 rbufs.push_back(make_row_buffer(surface.window(), spec.label, dims));
83 auto root_group = make_value_group(root_values, std::move(hbuf), rbufs,
84 surface, cursor, x_min, x_max, row_h, true);
85
86 InspectResult& result = s_scheduler_result.emplace();
87 result.group = std::move(root_group);
88
89 const auto tasks = m_sched.get_all_tasks();
90 for (const auto& entry : tasks) {
91 if (!entry.routine)
92 continue;
93
94 auto task_result = inspect_task(
95 entry, surface, cursor,
96 x_min, x_max, row_h);
97
98 result.group.header.attach(surface.layer(), task_result.group.header.header_id);
99 result.children.push_back(std::move(task_result));
100 }
101
102 return result;
103}
104
107 Surface& surface,
108 LayoutCursor& cursor,
109 float x_min, float x_max, float row_h)
110{
111 const std::string header_label = "TaskScheduler ["
112 + std::string(Reflect::enum_to_string(token)) + "]";
113
114 const auto dims = row_pixel_dims(surface.window(), x_min, x_max, row_h);
115 auto hbuf = make_row_buffer(surface.window(), header_label, dims);
116 auto root_group = make_value_group({}, std::move(hbuf), {},
117 surface, cursor, x_min, x_max, row_h, true);
118
119 InspectResult result;
120 result.group = std::move(root_group);
121
122 const auto all = m_sched.get_all_tasks();
123 for (const auto& entry : all) {
124 if (!entry.routine)
125 continue;
126 if (entry.routine->get_processing_token() != token)
127 continue;
128
129 auto task_result = inspect_task(
130 entry, surface, cursor,
131 x_min, x_max, row_h);
132
133 result.group.header.attach(surface.layer(), task_result.group.header.header_id);
134 result.children.push_back(std::move(task_result));
135 }
136
137 return result;
138}
139
140} // namespace MayaFlux::Portal::Forma
InspectResult tasks(Vruta::ProcessingToken token, Surface &surface, LayoutCursor &cursor, float x_min=-0.95F, float x_max=0.95F, float row_h=0.05F)
Inspect tasks for a specific processing token.
RowBuffer make_row_buffer(const std::shared_ptr< Core::Window > &window, std::string_view text, glm::uvec2 pixel_dims) const
Definition Inspector.cpp:13
InspectResult inspect_task(const Vruta::TaskEntry &entry, Surface &surface, LayoutCursor &cursor, float x_min, float x_max, float row_h)
static std::optional< InspectResult > s_scheduler_result
InspectResult & scheduler(Surface &surface, LayoutCursor &cursor, float x_min=-0.95F, float x_max=0.95F, float row_h=0.05F)
Inspect the full TaskScheduler state.
Vruta::TaskScheduler & m_sched
Reactive Y-position accumulator for vertical primitive stacking.
const std::shared_ptr< Core::Window > & window() const noexcept
Access the rendering target window.
Definition Surface.hpp:126
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:107
Named owner of a (Window, Layer, Context) triple - the Forma canvas.
Definition Surface.hpp:58
const std::vector< TaskEntry > & get_all_tasks()
Get all tasks for inspection/debugging.
ValueGroup make_value_group(std::span< const ValueSpec > values, RowBuffer header_buf, std::span< const RowBuffer > row_bufs, Surface &surface, LayoutCursor &cursor, float x_min, float x_max, float row_h, bool initially_open)
Construct a collapsible header followed by N value rows under it.
glm::uvec2 row_pixel_dims(const std::shared_ptr< Core::Window > &window, float x_min, float x_max, float row_h)
Convert an NDC row rect into integer pixel dimensions.
constexpr std::string_view enum_to_string(EnumType value) noexcept
Universal enum to string converter using magic_enum (original case)
std::string short_dynamic_type_name(const T &obj) noexcept
Returns the unqualified dynamic type name of obj.
Definition TypeInfo.hpp:95
MAYAFLUX_API void attach(Layer &layer, uint32_t body_id) const
Relate a body element to this collapsible and sync its visibility to the current open state.
std::vector< InspectResult > children
Result of an introspect call.
A single value to display in a ValueGroup body row.
std::shared_ptr< Routine > routine
Definition Scheduler.hpp:9