MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ add_slot()

uint32_t MayaFlux::Nodes::Network::MeshNetwork::add_slot ( std::string  name,
std::shared_ptr< GpuSync::MeshWriterNode node,
std::optional< uint32_t >  parent = std::nullopt 
)

Add a slot to the network.

Parameters
nameLogical name for lookup and logging.
nodeMeshWriterNode carrying the slot's geometry.
parentIndex of the parent slot, or nullopt for a root slot.
Returns
Stable index of the new slot. Never changes after insertion.

Definition at line 23 of file MeshNetwork.cpp.

27{
28 if (!node) {
29 error<std::invalid_argument>(
31 std::source_location::current(),
32 "MeshNetwork::add_slot: null MeshWriterNode for slot '{}'", name);
33 }
34
35 if (parent.has_value() && parent.value() >= m_slots.size()) {
36 error<std::out_of_range>(
38 std::source_location::current(),
39 "MeshNetwork::add_slot: parent index {} out of range (slot count: {})",
40 parent.value(), m_slots.size());
41 }
42
43 const auto idx = static_cast<uint32_t>(m_slots.size());
44
45 MeshSlot slot;
46 slot.index = idx;
47 slot.name = std::move(name);
48 slot.node = std::move(node);
49 slot.parent_index = parent;
50 slot.dirty = true;
51
52 if (parent.has_value()) {
53 m_slots[parent.value()].child_indices.push_back(idx);
54 }
55
56 m_slots.push_back(std::move(slot));
57 m_sort_dirty = true;
58
60 "MeshNetwork: added slot '{}' at index {} (parent: {})",
61 m_slots[idx].name, idx,
62 parent.has_value() ? std::to_string(parent.value()) : "none");
63
64 return idx;
65}
#define MF_DEBUG(comp, ctx,...)
bool m_sort_dirty
Set when add_slot() changes the DAG and a re-sort is needed.
@ Init
Engine/subsystem initialization.
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.

References MayaFlux::Nodes::Network::MeshSlot::dirty, MayaFlux::Nodes::Network::MeshSlot::index, MayaFlux::Journal::Init, m_slots, m_sort_dirty, MF_DEBUG, MayaFlux::Nodes::Network::MeshSlot::name, MayaFlux::Nodes::Network::MeshSlot::node, MayaFlux::Journal::Nodes, and MayaFlux::Nodes::Network::MeshSlot::parent_index.