MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MeshOperator.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "NetworkOperator.hpp"
5
7
8/**
9 * @class MeshOperator
10 * @brief Abstract base for operators that process MeshNetwork slots.
11 *
12 * Sits between NetworkOperator and the concrete mesh operators.
13 * Concrete subclasses implement process_slot() for per-slot logic;
14 * the base process() iterates m_slots in the caller-supplied topological
15 * order and delegates to process_slot() for each entry.
16 *
17 * Slots are supplied once per cycle by MeshNetwork::process_batch()
18 * via set_slots(). The operator does not own the slot storage.
19 *
20 * Topological order (parents before children) is enforced by MeshNetwork
21 * before it calls process(); operators receive slots in that order and
22 * must not re-order them.
23 */
24class MAYAFLUX_API MeshOperator : public NetworkOperator {
25public:
26 ~MeshOperator() override = default;
27
28 /**
29 * @brief Supply the slot list and processing order for the coming cycle.
30 * @param slots Reference to the MeshNetwork's slot storage.
31 * @param order Indices into slots in topological order (parents first).
32 *
33 * Called by MeshNetwork::process_batch() before process(dt).
34 * The reference must remain valid for the duration of the cycle.
35 */
36 void set_slots(std::vector<MeshSlot>& slots,
37 const std::vector<uint32_t>& order)
38 {
39 m_slots = &slots;
40 m_order = &order;
41 }
42
43 /**
44 * @brief Iterate slots in topological order and call process_slot() on each.
45 * @param dt Time delta in seconds.
46 */
47 void process(float dt) override
48 {
49 if (!m_slots || !m_order)
50 return;
51 for (uint32_t idx : *m_order)
52 process_slot((*m_slots)[idx], dt);
53 }
54
55 /**
56 * @brief Process a single slot.
57 * @param slot Slot to process (mutable).
58 * @param dt Time delta in seconds.
59 */
60 virtual void process_slot(MeshSlot& slot, float dt) = 0;
61
62 // -------------------------------------------------------------------------
63 // NetworkOperator stubs -- concrete operators may override as needed
64 // -------------------------------------------------------------------------
65
66 void set_parameter(std::string_view, double) override { }
67 [[nodiscard]] std::optional<double> query_state(std::string_view) const override
68 {
69 return std::nullopt;
70 }
71
72protected:
73 std::vector<MeshSlot>* m_slots { nullptr };
74 const std::vector<uint32_t>* m_order { nullptr };
75};
76
77} // namespace MayaFlux::Nodes::Network
void process(float dt) override
Iterate slots in topological order and call process_slot() on each.
virtual void process_slot(MeshSlot &slot, float dt)=0
Process a single slot.
std::optional< double > query_state(std::string_view) const override
Query operator internal state.
void set_parameter(std::string_view, double) override
Set operator parameter.
void set_slots(std::vector< MeshSlot > &slots, const std::vector< uint32_t > &order)
Supply the slot list and processing order for the coming cycle.
Abstract base for operators that process MeshNetwork slots.
Domain-agnostic interpretive lens for network processing.
Named, independently transformable mesh unit within a MeshNetwork.
Definition MeshSlot.hpp:31