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

◆ clone()

std::shared_ptr< Polynomial > MayaFlux::Nodes::Generator::Polynomial::clone ( ) const

An independent node with the same behaviour and fresh history.

Same mode, buffer size, function, scale and coefficient array as the array stands now, so a state-bearing kernel's clone continues from the current state. History, saved state and hooks are not copied. The input node, if any, is shared. Closure state captured by a function is shared too; the coefficient array is the state that is not.

Attach one clone per channel instead of one node to several.

Definition at line 183 of file Polynomial.cpp.

184{
185 std::shared_ptr<Polynomial> copy;
186
187 if (m_coef_bound) {
188 copy = std::make_shared<Polynomial>(m_coef_function, m_mode, m_buffer_size, m_coefficients);
189 } else if (m_mode == PolynomialMode::DIRECT) {
191 ? std::make_shared<Polynomial>(m_coefficients)
192 : std::make_shared<Polynomial>(m_direct_function);
193 } else {
194 copy = std::make_shared<Polynomial>(m_buffer_function, m_mode, m_buffer_size);
195 }
196
197 copy->m_coefficients = m_coefficients;
198 copy->m_scale_factor = m_scale_factor;
199 copy->m_input_node = m_input_node;
200 return copy;
201}
CoefBufferFunction m_coef_function
The function behind m_buffer_function while a CoefBufferFunction is bound.
PolynomialMode m_mode
Current processing mode.
double m_scale_factor
Scaling factor for output.
Polynomial(const std::vector< double > &coefficients)
Constructs a Polynomial generator in direct mode with coefficient-based definition.
Definition Polynomial.cpp:5
size_t m_buffer_size
Maximum size of the buffers.
BufferFunction m_buffer_function
Function for recursive/feedforward mode.
bool m_coef_direct
True while DIRECT output is evaluated from m_coefficients.
std::shared_ptr< Node > m_input_node
Input node for processing.
bool m_coef_bound
True once a CoefBufferFunction has been bound.
DirectFunction m_direct_function
Function for direct mode.
std::vector< double > m_coefficients
Polynomial coefficients (if using coefficient-based definition)
@ DIRECT
Evaluates f(x) where x is the current phase/input.
CopiedText copy(std::string_view text, const LayoutResult &layout, size_t a, size_t b)
Copy a byte range: the text it spans, and the quads that render it.

References MayaFlux::Nodes::Generator::DIRECT, m_buffer_function, m_buffer_size, m_coef_bound, m_coef_direct, m_coef_function, m_coefficients, m_direct_function, m_input_node, m_mode, and m_scale_factor.