|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Moves a single active slot along the rows of a weight table. More...
#include <WalkOperator.hpp>
Inheritance diagram for MayaFlux::Nodes::Network::WalkOperator:
Collaboration diagram for MayaFlux::Nodes::Network::WalkOperator:Public Types | |
| using | Pick = std::function< size_t(std::span< const double > row)> |
| Chooses a successor from a row of weights. | |
Public Member Functions | |
| size_t | advance () |
| Step once. | |
| size_t | current () const noexcept |
| Kinesis::Stochastic::Stochastic & | generator () noexcept |
| The generator behind the default weighted draw. | |
| std::string_view | get_type_name () const override |
| Type name for introspection. | |
| void | jump (size_t index) |
| Make a slot the active one. | |
| void | process (float frames) override |
| Self-contained step. | |
| std::optional< double > | query_state (std::string_view query) const override |
| Query walk state. | |
| void | set_every_n_blocks (uint32_t every_n_blocks) noexcept |
| Change or disable the self-contained step rate. | |
| void | set_parameter (std::string_view param, double value) override |
| Set operator parameter. | |
| const std::shared_ptr< Kinesis::Stochastic::Weights > & | table () const noexcept |
| WalkOperator (std::shared_ptr< Kinesis::Stochastic::Weights > table, Pick pick={}, uint32_t every_n_blocks=0, size_t starting_index=0) | |
Public Member Functions inherited from MayaFlux::Nodes::Network::RelationOperator | |
| void | begin_block () |
| Apply mapped parameters at the start of a block. | |
| virtual std::span< const double > | get_output_block (size_t) const |
| virtual size_t | get_output_count () const |
| void | map (std::string parameter, Source source) |
| Drive an operator parameter from a source. | |
| virtual bool | publishes_output () const |
| void | set_slots (std::vector< RelationSlot > &slots) noexcept |
| Supply the current slot storage. | |
| void | unmap (std::string_view parameter) |
| Remove the mapping of a parameter. | |
Public Member Functions inherited from MayaFlux::Nodes::Network::NetworkOperator | |
| virtual void | apply_one_to_one (std::string_view param, const std::shared_ptr< NodeNetwork > &source) |
| Apply ONE_TO_ONE parameter mapping (per-point control) | |
| virtual bool | demands_full_vertex_restore () const |
| Whether a downstream compute pass writes the network's vertex buffer in place each cycle, so the geometry producer must keep restoring the CPU-authoritative vertex data every frame. | |
| virtual | ~NetworkOperator ()=default |
Private Member Functions | |
| void | ensure_established () |
| Activate slot m_current and deactivate every other slot that currently exists. | |
Private Attributes | |
| uint32_t | m_blocks_until { 0 } |
| std::atomic< size_t > | m_current { 0 } |
| bool | m_established { false } |
| std::atomic< uint32_t > | m_every_n_blocks { 0 } |
| Kinesis::Stochastic::Stochastic | m_generator { Kinesis::Stochastic::Algorithm::UNIFORM } |
| Pick | m_pick |
| std::shared_ptr< Kinesis::Stochastic::Weights > | m_table |
Additional Inherited Members | |
Protected Member Functions inherited from MayaFlux::Nodes::Network::RelationOperator | |
| std::span< RelationSlot > | slots () const noexcept |
Moves a single active slot along the rows of a weight table.
Exactly one slot is meant to be active at a time. advance() reads the row of the current slot, picks a successor, deactivates the current slot, and activates the successor, so the slots' leave and enter callbacks fire in that order. jump() moves directly. Nothing else changes the state.
WalkOperator can be stepped two ways, and both may be used on the same instance:
The table is a shared pointer so other operators and writers can read or edit the same weights, and any cell may be rewritten while the walk runs. The draw itself uses an owned Kinesis::Stochastic::Stochastic generator (UNIFORM by default).
The first call to process(), advance(), or jump() establishes the single- active-slot state: it activates starting_index (0 unless the constructor was given a different one) and deactivates every other slot that exists at that moment, before doing anything else. A slot added by add_slot() afterward starts at RelationSlot's own default (active) like any other new slot; WalkOperator does not retroactively enforce its invariant on it. jump() it explicitly to bring it into the walk.
Parameters:
The table must be square with a dimension equal to the slot count of the network. advance() and jump() mutate the walk and must not be called concurrently from more than one thread. Reads are atomic.
Definition at line 51 of file WalkOperator.hpp.