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

◆ declare()

template<typename C>
C & MayaFlux::Nodes::Network::RewriteOperator::declare ( )
inline

Declare the struct of controls the grammar's rules read, and return it.

Template Parameters
CA described struct whose members are all Control.

Call once, before the first rewrite() and before any thread sets or reads the controls. A rule reads them through Environment::controls<C>().

struct Bloom { Control rate; Control angle; };
rewrite->declare<Bloom>();
rewrite->replace('F', [](const Symbol& s, Environment env, const EmitSymbol& emit) {
emit({ 'F', s.parameters[0] * env.controls<Bloom>().rate.value() });
});
rewrite->set<Bloom>({ .rate = 0.3, .angle = lfo });
#define MF_DESCRIBE(...)
Requests a generated member description for a struct at namespace scope.
Definition Describe.hpp:14
One named control of a network or operator: empty, a value, or a mapped source.
Definition Control.hpp:34
std::function< bool(Symbol)> EmitSymbol
Append a symbol; false on a bound violation.
RewriteResult rewrite(uint64_t steps=1, std::span< const double > inputs={})
Rewrite the draft word on the producer lane, without submitting it.

Definition at line 184 of file RewriteOperator.hpp.

185 {
186 m_hold = [this] {
187 return std::shared_ptr<const void>(std::make_shared<const C>(snapshot_controls<C>()));
188 };
189 m_read = [this](std::string_view name) {
191 };
193 return declare_controls<C>();
194 }
static std::optional< double > read_named(const C &controls, std::string_view name)
C & declare_controls()
Create the operator's controls struct and keep it alive.
C snapshot_controls() const
A copy of the declared struct, for an operator whose controls type is not fixed.
std::function< std::shared_ptr< const void >()> m_hold
static const void * controls_tag() noexcept
A tag that is the same for every use of one type C in a module, and differs between types.
std::function< std::optional< double >(std::string_view)> m_read

References controls_tag(), MayaFlux::Nodes::Network::NetworkOperator::declare_controls(), m_held_tag, m_hold, m_read, MayaFlux::ControlValueStore< Control >::read_named(), and MayaFlux::Nodes::Network::NetworkOperator::snapshot_controls().

Here is the call graph for this function: