|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
One named control of a network or operator: empty, a value, or a mapped source. More...
#include <Control.hpp>
Public Member Functions | |
| void | assign (const Control &incoming) |
Takes everything incoming holds, so the next due() is true. | |
| std::optional< double > | at (size_t index) const |
| Value for one element: the network's output there, else the scalar. | |
| Control ()=default | |
| Control (const Control &)=default | |
| Control (Control &&) noexcept=default | |
| template<typename Source> requires std::derived_from<Source, NodeNetwork> | |
| Control (std::shared_ptr< Source > source) | |
| template<typename Source> requires std::derived_from<Source, Node> | |
| Control (std::shared_ptr< Source > source) | |
| template<typename T> requires is_value<T> | |
| Control (T value) noexcept | |
| bool | due () const noexcept |
| True when a consumer should apply this control now. | |
| size_t | element_count () const |
| Node count of the source network, or 0 without one. | |
| template<typename T> requires is_value<T> | |
| void | observe (T actual) noexcept |
| Shows the value the owner really has, unless a source is feeding it. | |
| Control & | operator= (const Control &)=default |
| Control & | operator= (Control &&) noexcept=default |
| template<typename T = double> requires is_value<T> | |
| std::optional< T > | pending () noexcept |
| The value to apply now as type T, or nullopt when nothing is due. | |
| bool | per_element () const noexcept |
| True when a network feeds one value per element. | |
| void | refresh () |
| Reads the node source into value(). | |
| bool | sourced () const noexcept |
| True when a node or a network feeds this control. | |
| ~Control ()=default | |
| Public Member Functions inherited from MayaFlux::ControlValue | |
| void | assign (const ControlValue &incoming) noexcept |
Takes everything incoming holds, so the next due() is true. | |
| ControlValue ()=default | |
| ControlValue (const ControlValue &other) noexcept | |
| ControlValue (ControlValue &&other) noexcept | |
| template<typename T> requires is_value<T> | |
| ControlValue (T value) noexcept | |
| bool | due () const noexcept |
| True when a consumer should apply this value now. | |
| bool | has_value () const noexcept |
| True once a value was given. | |
| template<typename T> requires is_value<T> | |
| void | observe (T actual) noexcept |
| Shows the value the owner really has. | |
| operator double () const noexcept | |
| ControlValue & | operator= (const ControlValue &other) noexcept |
| ControlValue & | operator= (ControlValue &&other) noexcept |
| template<typename T = double> requires is_value<T> | |
| std::optional< T > | pending () noexcept |
| The value to apply now as type T, or nullopt when nothing is due. | |
| void | refresh () noexcept |
| Nothing to read for a plain value. | |
| void | settle () noexcept |
| Marks the current value as applied. | |
| template<typename T> requires is_value<T> | |
| T | value () const noexcept |
| The value as type T, which must be the type it was set with. | |
| double | value () const noexcept |
| The value as a double. | |
| size_t | width () const noexcept |
| Components held: 0 when empty, 1 for a number, flag or enum, 2 to 4 for a vector, 6 for a box. | |
| ~ControlValue ()=default | |
Private Attributes | |
| std::shared_ptr< NodeNetwork > | m_network |
| std::shared_ptr< Node > | m_node |
Additional Inherited Members | |
| Static Public Attributes inherited from MayaFlux::ControlValue | |
| template<typename T> | |
| static constexpr bool | is_box |
| template<typename T> | |
| static constexpr bool | is_value = std::is_arithmetic_v<T> || std::is_enum_v<T> || is_vector<T> || is_box<T> |
| template<typename T> | |
| static constexpr bool | is_vector |
| Protected Member Functions inherited from MayaFlux::ControlValue | |
| bool | changed () const noexcept |
| void | set_blank () noexcept |
| Marks the slot set with one zero lane and leaves it clean. | |
| void | set_scalar (double value) noexcept |
| Static Protected Member Functions inherited from MayaFlux::ControlValue | |
| template<typename T> | |
| static constexpr uint8_t | width_of () noexcept |
| Static Protected Attributes inherited from MayaFlux::ControlValue | |
| static constexpr size_t | k_lanes = 6 |
One named control of a network or operator: empty, a value, or a mapped source.
A Control converts implicitly from a number, a bool, an enum, a glm::vec2, glm::vec3 or glm::vec4, from a box (a struct of exactly a glm::vec3 min and a glm::vec3 max, such as Kinesis::SamplerBounds or Kinesis::AABB3D), from a node (BROADCAST) and from a network (ONE_TO_ONE), so a controls struct reads as designated initializers: net->set({ .decay = 0.6, .amplitude = bell }) or op->set({ .gravity = glm::vec3(0, -9.8, 0) }). An empty Control means "leave this alone". Setting a value replaces any source held before it. The owner reads it back as the type it declared: pending() and value() give a double, and pending<glm::vec3>(), pending<BoundsMode>() and so on give that type. A read of another type than was set finds nothing.
A value may be set from any thread while a block renders. Numbers are atomic, and a vector is written and read under a sequence lock, so it is never seen half written. A value is never lost to a race, only possibly applied twice with the same content. A Control holds one pending value, so a later value replaces one that no block has applied yet. Integers are carried exactly up to 2^53. Attaching, replacing or removing a node or network source belongs outside the block, as with the operator chain. A consumer calls settle() before it reads the value.
Definition at line 34 of file Control.hpp.