MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nodes::Network::RelationNetwork Class Reference

Host for a dynamically growable set of slots and the operators that act on them. More...

#include <RelationNetwork.hpp>

+ Inheritance diagram for MayaFlux::Nodes::Network::RelationNetwork:
+ Collaboration diagram for MayaFlux::Nodes::Network::RelationNetwork:

Public Member Functions

template<std::derived_from< RelationOperator > Op, typename... Args>
requires std::constructible_from<Op, Args...>
std::shared_ptr< Op > add (Args &&... args)
 Construct an operator in place and append it to the chain.
 
uint32_t add_slot (RelationSlot slot={})
 Add a slot to the network.
 
std::vector< uint32_t > add_slots (std::initializer_list< RelationSlot > slots)
 Add several slots at once.
 
std::optional< std::reference_wrapper< RelationSlot > > find_slot (std::string_view name)
 Find a slot by name.
 
std::optional< std::reference_wrapper< const RelationSlot > > find_slot (std::string_view name) const
 
std::optional< uint32_t > find_slot_index (std::string_view name) const
 Find the index of a slot by name.
 
std::optional< std::vector< double > > get_audio_buffer () const override
 Block of the first published output, or nullopt when none is published.
 
std::unordered_map< std::string, std::string > get_metadata () const override
 Get network metadata for debugging/visualization.
 
std::optional< std::span< const double > > get_node_audio_buffer (size_t index) const override
 Block of one slot from the last process_batch()
 
size_t get_node_count () const override
 Get the number of nodes in the network.
 
std::optional< double > get_node_output (size_t index) const override
 Level of one slot after the last processed block.
 
std::optional< std::span< const double > > get_output_block (size_t index) const
 Block of one published output from the last process_batch()
 
size_t get_output_count () const
 Total published outputs across all publishing operators, in chain order.
 
RelationSlot & get_slot (uint32_t index)
 
const RelationSlot & get_slot (uint32_t index) const
 
void process_batch (unsigned int num_samples) override
 Process the network for the given number of samples.
 
 RelationNetwork ()
 
size_t slot_count () const noexcept
 
const std::vector< RelationSlot > & slots () const noexcept
 
std::vector< RelationSlot > & slots () noexcept
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
void add_channel_usage (uint32_t channel_id)
 Register network usage on a specific channel.
 
void clear_timestep ()
 Return to the frame period.
 
uint32_t get_block_size () const
 
uint32_t get_channel_mask () const
 Get channel mask (bitfield of registered channels)
 
uint32_t get_frame_rate () const
 
virtual NetworkOperator * get_operator ()
 
virtual const NetworkOperator * get_operator () const
 
std::shared_ptr< OperatorChain > get_operator_chain () const
 Access the secondary operator chain.
 
OutputMode get_output_mode () const
 Get the current output routing mode.
 
double get_output_scale () const
 Get the current output scale factor.
 
std::vector< uint32_t > get_registered_channels () const
 Get all channels this network is registered on.
 
RoutingState & get_routing_state ()
 Retrieves the current routing state of the network (non-const)
 
const RoutingState & get_routing_state () const
 Retrieves the current routing state of the network.
 
uint32_t get_sample_rate () const
 
float get_timestep () const
 Seconds one visual frame advances this network.
 
Topology get_topology () const
 Get the current topology.
 
virtual bool has_operator () const
 
virtual void initialize ()
 Called once before first process_batch()
 
bool is_enabled () const
 Check if network is enabled.
 
bool is_processed_this_cycle () const
 Check if network has been processed this cycle (lock-free)
 
bool is_processing () const
 Check if network is currently processing (lock-free)
 
bool is_registered_on_channel (uint32_t channel_id) const
 Check if network is registered on a channel.
 
virtual void map_parameter (const std::string &param_name, const std::shared_ptr< Node > &source, MappingMode mode=MappingMode::BROADCAST)
 Map external node output to network parameter.
 
virtual void map_parameter (const std::string &param_name, const std::shared_ptr< NodeNetwork > &source_network)
 Map external node network to network parameters (ONE_TO_ONE)
 
void mark_processed (bool processed)
 Mark network as processed this cycle (lock-free)
 
void mark_processing (bool processing)
 Mark network as processing or not (lock-free)
 
bool needs_channel_routing () const
 Checks if the network is currently in a routing transition phase.
 
void remove_channel_usage (uint32_t channel_id)
 Unregister network from a specific channel.
 
void request_reset_from_channel (uint32_t channel_id)
 Request a reset from a specific channel.
 
virtual void reset ()
 Reset network to initial state.
 
void set_block_size (uint32_t block_size)
 
void set_channel_mask (uint32_t mask)
 Set channel mask directly.
 
void set_enabled (bool enabled)
 Enable/disable the network.
 
void set_frame_rate (uint32_t frame_rate)
 Frame rate the owning manager runs visual processing at.
 
void set_output_mode (OutputMode mode)
 Set the network's output routing mode.
 
void set_output_scale (double scale)
 Set the scalar multiplier applied to the network's output buffer after processing.
 
void set_sample_rate (uint32_t sample_rate)
 
void set_timestep (float dt)
 Advance this network by a fixed number of seconds per frame instead of the frame period.
 
virtual void set_topology (Topology topology)
 Set the network's topology.
 
virtual void unmap_parameter (const std::string &param_name)
 Remove parameter mapping.
 
virtual ~NodeNetwork ()=default
 

Private Attributes

std::vector< std::shared_ptr< RelationOperator > > m_publishers
 
std::vector< RelationSlot > m_slots
 

Additional Inherited Members

- Protected Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
void apply_output_scale ()
 Apply m_output_scale to m_last_audio_buffer.
 
void ensure_initialized ()
 Ensure initialize() is called exactly once.
 
- Static Protected Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
static std::unordered_map< size_t, std::vector< size_t > > build_chain_neighbors (size_t count)
 Build neighbor map for CHAIN topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_grid_2d_neighbors (size_t width, size_t height)
 Build neighbor map for GRID_2D topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_grid_3d_neighbors (size_t width, size_t height, size_t depth)
 Build neighbor map for GRID_3D topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_ring_neighbors (size_t count)
 Build neighbor map for RING topology.
 
- Protected Attributes inherited from MayaFlux::Nodes::Network::NodeNetwork
std::atomic_flag m_audio_buffer_lock = ATOMIC_FLAG_INIT
 Spinlock guarding m_last_audio_buffer.
 
uint32_t m_block_size { 512 }
 
std::atomic< uint32_t > m_channel_mask { 0 }
 Bitfield of channels this network is registered on.
 
bool m_enabled = true
 
uint32_t m_frame_rate { 60 }
 
bool m_initialized = false
 
std::vector< double > m_last_audio_buffer
 
std::shared_ptr< OperatorChain > m_operator_chain
 
OutputMode m_output_mode = OutputMode::NONE
 
double m_output_scale { 1.0 }
 Post-processing scalar applied to m_last_audio_buffer each batch.
 
std::vector< ParameterMapping > m_parameter_mappings
 
std::atomic< uint32_t > m_pending_reset_mask { 0 }
 
std::atomic< bool > m_processed_this_cycle { false }
 
std::atomic< bool > m_processing_state { false }
 Per-channel processing state (lock-free atomic flags)
 
uint32_t m_sample_rate { 48000 }
 
std::optional< float > m_timestep
 
Topology m_topology = Topology::INDEPENDENT
 

Detailed Description

Host for a dynamically growable set of slots and the operators that act on them.

The network owns the slots; everything computational lives in operators: advancing slot signals (AdvanceOperator), deriving one slot from others (DeriveOperator), turning slots into published outputs (CombineOperator), and any other slot logic (StepOperator and operators built on the same base). Construction adds no operators and no slots; a network with no publishing operator outputs nothing.

Add slots with add_slot(), operators with add<Op>(...) in this order: control operators first, then AdvanceOperator, then DeriveOperator, then CombineOperator.

Warning
A RelationSlot's address is not stable: add_slot() may reallocate the whole slot vector. Read a slot fresh through get_slot(index) or get_node_output(index) rather than holding a pointer to it.

add_slot() reserves each new slot's block storage, so a slot added while the network is already running does not allocate on its first block. process_batch() re-supplies every operator the current slot storage, applies mapped parameters, and runs the chain in order. Output 0 of the first publishing operator becomes the network's audio buffer.

Structural edits (add_slot(), slot sources, callbacks, adding operators) must happen outside process_batch(). Parameter mapping uses Source and map() on RelationOperator (see RelationOperators.hpp).

Definition at line 39 of file RelationNetwork.hpp.


The documentation for this class was generated from the following files: