MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Inspector.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "InspectResult.hpp"
5
6namespace MayaFlux::Core {
7class Window;
8}
9
10namespace MayaFlux::Nodes {
11struct ModulatorTree;
12class NodeGraphManager;
13}
14
15namespace MayaFlux::Buffers {
16class BufferManager;
17}
18
19namespace MayaFlux::Vruta {
20class TaskScheduler;
21struct TaskEntry;
22class Event;
23class EventManager;
24}
25
27
28class Surface;
29
30/**
31 * @brief Forma subsystem for live introspection.
32 *
33 * Initialized by Portal::Forma::initialize alongside Bridge.
34 * Provides a fluent entry point into Inspect:: query functions
35 * using stored BufferManager and NodeGraphManager defaults.
36 *
37 * Access via Portal::Forma::get_inspector().
38 */
39class MAYAFLUX_API Inspector {
40public:
43 : m_ngm(ngm)
44 , m_bm(bm)
45 , m_sched(sched)
46 , m_event_mgr(event_mgr)
47 {
48 }
49
50 /**
51 * @brief Inspect a single Node and its full modulator tree.
52 *
53 * Builds a ValueGroup whose header is the node's short type name and
54 * whose body rows expose the node's runtime values (output, role for
55 * modulators, etc.). Modulator children are recursively expanded as
56 * nested InspectResults related to this node's header.
57 */
58 [[nodiscard]] InspectResult node(
59 const std::shared_ptr<Nodes::Node>& n,
60 Surface& surface,
61 LayoutCursor& cursor,
62 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F, int depth = 0);
63
64 /**
65 * @brief Inspect a single RootNode for a specific token and channel.
66 *
67 * Header is "root [ch N]" for AUDIO_RATE or "root" for all other tokens.
68 * Body row exposes live node count from RootNode::get_node_size(). Each
69 * registered node is expanded via node() as a child. Networks for the
70 * token/channel are appended after the node children.
71 */
72 [[nodiscard]] InspectResult root_node(
73 Nodes::ProcessingToken token, uint32_t channel,
74 Surface& surface,
75 LayoutCursor& cursor,
76 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F, int depth = 0);
77
78 /**
79 * @brief Inspect all RootNodes for a token.
80 *
81 * For AUDIO_RATE: header shows token and channel count, each channel
82 * expanded as a nested root_node(token, channel) result.
83 * For all other tokens: delegates directly to root_node(token, 0).
84 */
85 [[nodiscard]] InspectResult root_node(
87 Surface& surface,
88 LayoutCursor& cursor,
89 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F, int depth = 0);
90
91 /**
92 * @brief Inspect a NodeNetwork and its per-network metadata.
93 *
94 * Builds a collapsible ValueGroup whose header is the network's topology
95 * and output mode, with body rows for node count and enabled state.
96 * Intended to be nested inside node_graph_manager() but callable
97 * independently when the caller already holds a network reference.
98 */
99 [[nodiscard]] InspectResult node_network(
100 const std::shared_ptr<Nodes::Network::NodeNetwork>& net,
101 Surface& surface,
102 LayoutCursor& cursor,
103 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F, int depth = 0);
104
105 /**
106 * @brief Inspect the full NodeGraphManager state across all active tokens.
107 *
108 * Emits one collapsible per active Nodes::ProcessingToken. Each token
109 * expands per-channel children, each of which recursively calls node()
110 * for every node registered to that channel. Networks for the token are
111 * appended after the channel children, showing topology, output mode,
112 * node count, enabled state, and registered channels.
113 *
114 * Persistent: the first call builds the result against @p surface and
115 * @p cursor and stores it statically. Subsequent calls return the same
116 * result regardless of the supplied surface and cursor; the original
117 * window remains the render target. To display on a different surface,
118 * the process must be restarted.
119 */
120 [[nodiscard]] InspectResult& node_graph_manager(
121 Surface& surface,
122 LayoutCursor& cursor,
123 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F);
124
125 /**
126 * @brief Inspect a single Buffer: default processor and full processing chain.
127 *
128 * Header is the buffer's dynamic type name. Body rows expose the default
129 * processor type, then preprocessor, each indexed chain processor,
130 * postprocessor, and final processor. Absent slots show "-".
131 */
132 [[nodiscard]] InspectResult buffer(
133 const std::shared_ptr<Buffers::Buffer>& buf,
134 Surface& surface,
135 LayoutCursor& cursor,
136 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F, int depth = 0);
137
138 /**
139 * @brief Inspect the root audio buffer for a specific token and channel.
140 *
141 * Header shows channel index and token. Rows show sample count and child
142 * count. The root buffer itself is expanded via buffer(), then each child
143 * buffer is expanded via buffer() in order.
144 */
145 [[nodiscard]] InspectResult root_audio_buffer(
146 Buffers::ProcessingToken token, uint32_t channel,
147 Surface& surface,
148 LayoutCursor& cursor,
149 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F, int depth = 0);
150
151 /**
152 * @brief Inspect all root audio buffers for a token across every channel.
153 *
154 * Header shows token and total channel count. Each channel is expanded
155 * as a nested root_audio_buffer() result, related for visibility cascade.
156 */
157 [[nodiscard]] InspectResult root_audio_buffer(
159 Surface& surface,
160 LayoutCursor& cursor,
161 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F, int depth = 0);
162
163 /**
164 * @brief Inspect the root graphics buffer for a token.
165 *
166 * Header shows token. Row shows VKBuffer child count. The root buffer
167 * itself is expanded via buffer(), then each VKBuffer child via buffer().
168 */
169 [[nodiscard]] InspectResult root_graphics_buffer(
171 Surface& surface,
172 LayoutCursor& cursor,
173 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F, int depth = 0);
174
175 /**
176 * @brief Inspect the full BufferManager state across all active tokens.
177 *
178 * Emits one top-level collapsible per active Buffers::ProcessingToken. Audio
179 * tokens (AUDIO_BACKEND, AUDIO_PARALLEL) expand per-channel rows showing
180 * sample count, child buffer count, and processing chain state. Graphics
181 * tokens (GRAPHICS_BACKEND) expand a single root entry showing VKBuffer
182 * child count. All children are related via layer.relate() for cascade.
183 *
184 * Persistent: the first call builds the result against @p surface and
185 * @p cursor and stores it statically. Subsequent calls return the same
186 * result regardless of the supplied surface and cursor; the original
187 * window remains the render target. To display on a different surface,
188 * the process must be restarted.
189 */
190 [[nodiscard]] InspectResult& buffer_manager(
191 Surface& surface,
192 LayoutCursor& cursor,
193 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F);
194
195 /**
196 * @brief Inspect the full TaskScheduler state.
197 *
198 * Header shows total task count. Each task is a collapsible whose header
199 * is the routine's dynamic type name, with name, token, active, and delay
200 * context as sub-fields.
201 *
202 * Persistent: the first call builds the result against @p surface and
203 * @p cursor and stores it statically. Subsequent calls return the same
204 * result regardless of the supplied surface and cursor; the original
205 * window remains the render target. To display on a different surface,
206 * the process must be restarted.
207 */
208 [[nodiscard]] InspectResult& scheduler(
209 Surface& surface,
210 LayoutCursor& cursor,
211 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F);
212
213 /**
214 * @brief Inspect tasks for a specific processing token.
215 *
216 * Same per-task layout as scheduler() but filtered to one token.
217 */
218 [[nodiscard]] InspectResult tasks(
220 Surface& surface,
221 LayoutCursor& cursor,
222 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F);
223 /**
224 * @brief Inspect the full EventManager state.
225 *
226 * Header shows total event count. Each event is a collapsible whose
227 * header is the event's registered name, or "(unnamed)" for events
228 * added without a name. Body rows expose active state.
229 *
230 * Persistent: the first call builds the result against @p surface and
231 * @p cursor and stores it statically. Subsequent calls return the same
232 * result regardless of the supplied surface and cursor; the original
233 * window remains the render target. To display on a different surface,
234 * the process must be restarted.
235 */
236 [[nodiscard]] InspectResult& event_manager(
237 Surface& surface,
238 LayoutCursor& cursor,
239 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F);
240
241 /**
242 * @brief Inspect a single Event by name and pointer.
243 *
244 * Header is the event's registered name, or "(unnamed)" if empty.
245 * Body rows expose token and active state.
246 */
247 [[nodiscard]] InspectResult event(
248 const std::shared_ptr<Vruta::Event>& ev,
249 std::string_view name,
250 Surface& surface,
251 LayoutCursor& cursor,
252 float x_min = -0.95F, float x_max = 0.95F, float row_h = 0.05F);
253
254 /**
255 * @brief Destroy an InspectResult and release its resources.
256 *
257 * If @p result is one of the four persistent manager results, the
258 * corresponding static optional is nulled; the next manager call will
259 * rebuild from scratch. If @p result is a per-element result owned by
260 * the caller, it is reset to a default-constructed state.
261 */
262 void destroy(InspectResult& result);
263
264private:
269
270 [[nodiscard]] RowBuffer make_row_buffer(
271 const std::shared_ptr<Core::Window>& window,
272 std::string_view text,
273 glm::uvec2 pixel_dims) const;
274
275 InspectResult inspect_modulator_tree(
276 const Nodes::ModulatorTree& tree,
277 Surface& surface,
278 LayoutCursor& cursor,
279 float x_min, float x_max, float row_h, int depth);
280
281 [[nodiscard]] InspectResult inspect_task(
282 const Vruta::TaskEntry& entry,
283 Surface& surface,
284 LayoutCursor& cursor,
285 float x_min, float x_max, float row_h);
286
287 static std::optional<InspectResult> s_node_graph_result;
288 static std::optional<InspectResult> s_buffer_result;
289 static std::optional<InspectResult> s_scheduler_result;
290 static std::optional<InspectResult> s_event_result;
291};
292
293} // namespace MayaFlux::Portal::Forma
Token-based multimodal buffer management system for unified data stream processing.
Central manager for the computational processing node graph.
static std::optional< InspectResult > s_buffer_result
Nodes::NodeGraphManager & m_ngm
Vruta::EventManager & m_event_mgr
static std::optional< InspectResult > s_node_graph_result
static std::optional< InspectResult > s_event_result
static std::optional< InspectResult > s_scheduler_result
Vruta::TaskScheduler & m_sched
Inspector(Nodes::NodeGraphManager &ngm, Buffers::BufferManager &bm, Vruta::TaskScheduler &sched, Vruta::EventManager &event_mgr)
Definition Inspector.hpp:41
Buffers::BufferManager & m_bm
Forma subsystem for live introspection.
Definition Inspector.hpp:39
Reactive Y-position accumulator for vertical primitive stacking.
Named owner of a (Window, Layer, Context) triple - the Forma canvas.
Definition Surface.hpp:58
Token-based multimodal task scheduling system for unified coroutine processing.
Definition Scheduler.hpp:51
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
ProcessingToken
Enumerates the different processing domains for nodes.
Contains the node-based computational processing system components.
Definition Chronie.hpp:14
Recursive tree node describing a modulator and all of its own modulators.
Definition Node.hpp:34
Result of an introspect call.
A pre-created buffer and its bound text image, passed to make_value_row.