MayaFlux 1.0.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<EntrySpec> entrys {
22 EntrySpec {
23 .label = "name",
24 .reader = [name] { return name.empty() ? "(unnamed)" : name; },
25 },
26 EntrySpec {
27 .label = "token",
28 .reader = [routine] {
29 return std::string(Reflect::enum_to_string(routine->get_processing_token()));
30 },
31 },
32 EntrySpec {
33 .label = "active",
34 .reader = [routine] { return routine->is_active() ? "true" : "false"; },
35 },
36 EntrySpec {
37 .label = "delay",
38 .reader = [routine] {
39 return std::string(Reflect::enum_to_string(routine->get_delay_context()));
40 },
41 },
42 };
43
44 auto hbuf = make_header_buffer(surface.window());
45 auto rbufs = make_row_buffers(surface.window(), entrys.size());
46
47 auto group = make_entry_group(entrys, Reflect::short_dynamic_type_name(*entry.routine), std::move(hbuf), rbufs,
48 surface, cursor, x_min, x_max, row_h, false);
49
50 InspectResult result;
51 result.group = std::move(group);
52 return result;
53}
54
56 Surface& surface,
57 LayoutCursor& cursor,
58 float x_min, float x_max, float row_h)
59{
61 return *m_scheduler_result;
62 }
63
64 const std::vector<EntrySpec> root_entrys {
65 EntrySpec {
66 .label = "tasks",
67 .reader = [&m_sched = m_sched] {
68 return std::to_string(m_sched.get_all_tasks().size());
69 },
70 },
71 };
72
73 auto hbuf = make_header_buffer(surface.window());
74 auto rbufs = make_row_buffers(surface.window(), root_entrys.size());
75 auto root_group = make_entry_group(root_entrys, "TaskScheduler", std::move(hbuf), rbufs,
76 surface, cursor, x_min, x_max, row_h, true);
77
78 InspectResult& result = m_scheduler_result.emplace();
79 result.group = std::move(root_group);
80
81 const auto tasks = m_sched.get_all_tasks();
82 for (const auto& entry : tasks) {
83 if (!entry.routine)
84 continue;
85
86 auto task_result = inspect_task(
87 entry, surface, cursor,
88 x_min, x_max, row_h);
89
90 result.group.header.attach(surface.layer(), task_result.group.header.header_id);
91 result.children.push_back(std::move(task_result));
92 }
93
94 return result;
95}
96
99 Surface& surface,
100 LayoutCursor& cursor,
101 float x_min, float x_max, float row_h)
102{
103 const std::string header_label = "TaskScheduler ["
104 + std::string(Reflect::enum_to_string(token)) + "]";
105
106 auto hbuf = make_header_buffer(surface.window());
107 auto root_group = make_entry_group({}, header_label, std::move(hbuf), {},
108 surface, cursor, x_min, x_max, row_h, true);
109
110 InspectResult result;
111 result.group = std::move(root_group);
112
113 const auto all = m_sched.get_all_tasks();
114 for (const auto& entry : all) {
115 if (!entry.routine)
116 continue;
117 if (entry.routine->get_processing_token() != token)
118 continue;
119
120 auto task_result = inspect_task(
121 entry, surface, cursor,
122 x_min, x_max, row_h);
123
124 result.group.header.attach(surface.layer(), task_result.group.header.header_id);
125 result.children.push_back(std::move(task_result));
126 }
127
128 return result;
129}
130
131} // namespace MayaFlux::Portal::Forma
std::string name
Definition VKDevice.cpp:123
std::shared_ptr< Buffers::FormaBuffer > make_header_buffer(const std::shared_ptr< Core::Window > &window) const
A "text"-slotted buffer, registered with the BufferManager.
Definition Inspector.cpp:11
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.
std::vector< EntryBuffer > make_row_buffers(const std::shared_ptr< Core::Window > &window, size_t count) const
count row targets, slices of one "text"-slotted buffer, for make_entry_group's rows.
Definition Inspector.cpp:24
std::optional< InspectResult > m_scheduler_result
InspectResult inspect_task(const Vruta::TaskEntry &entry, Surface &surface, LayoutCursor &cursor, float x_min, float x_max, float row_h)
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:178
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:159
Named owner of a (Window, Layer, Context) triple: the Forma canvas.
Definition Surface.hpp:121
const std::vector< TaskEntry > & get_all_tasks()
Get all tasks for inspection/debugging.
EntryGroup make_entry_group(std::span< const EntrySpec > entrys, std::string_view header_label, FormaTarget header_buf, std::span< const EntryBuffer > 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 entry rows under it.
Definition Entry.cpp:104
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.
A single entry to display in a EntryGroup body row.
Definition Entry.hpp:29
std::vector< InspectResult > children
Result of an introspect call.
std::shared_ptr< Routine > routine
Definition Scheduler.hpp:9