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

◆ notify_tick()

void MayaFlux::Nodes::Generator::Logic::notify_tick ( double  value)
overrideprotectedvirtual

Notifies all registered callbacks about a new sample.

Parameters
valueThe newly generated sample

This method is called internally whenever a new sample is generated, creating the appropriate context and invoking all registered callbacks that should receive notification about this sample.

Reimplemented from MayaFlux::Nodes::Generator::Generator.

Definition at line 708 of file Logic.cpp.

709{
711 bool state_changed = (value != m_last_output);
712
713 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
714 auto& ctx = static_cast<LogicContext&>(get_last_context());
715
716 m_callbacks.fire(ctx);
718
719 for (const auto& entry : m_all_callbacks.snapshot()) {
720 bool should_call = false;
721
722 switch (static_cast<LogicEventType>(entry.tag)) {
725 break;
726
728 should_call = static_cast<bool>(value);
729 break;
730
732 should_call = !value;
733 break;
734
736 should_call = state_changed;
737 break;
738
740 should_call = state_changed && static_cast<bool>(value);
741 break;
742
744 should_call = state_changed && !value;
745 break;
746 }
747
748 if (should_call) {
749 entry.hook(ctx);
750 }
751 }
752}
glm::vec3 value
void update_context(double value) override
Updates the context with the latest sample value.
Definition Logic.cpp:677
NodeContext & get_last_context() override
Retrieves the last created context object.
Definition Logic.cpp:754
HookList m_all_callbacks
Event-specific callbacks, tagged with their LogicEventType.
Definition Logic.hpp:762
void fire(NodeContext &ctx) const
Calls every entry whose condition, if any, holds.
Definition NodeUtils.cpp:68
HookList m_conditional_callbacks
Hooks fired on a tick only while their condition holds.
Definition Node.hpp:485
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:441
HookList m_callbacks
Hooks fired on every tick.
Definition Node.hpp:478
LogicEventType
Events that can trigger callbacks.
Definition Logic.hpp:50

References MayaFlux::Nodes::Generator::CHANGE, MayaFlux::Nodes::Generator::CONDITIONAL, MayaFlux::Nodes::Generator::FALSE, MayaFlux::Nodes::HookList::fire(), get_last_context(), m_all_callbacks, MayaFlux::Nodes::Node::m_callbacks, MayaFlux::Nodes::Node::m_conditional_callbacks, MayaFlux::Nodes::Node::m_last_output, MayaFlux::Nodes::HookList::snapshot(), MayaFlux::Nodes::Generator::TICK, MayaFlux::Nodes::Generator::TRUE, update_context(), value, MayaFlux::Nodes::Generator::WHILE_FALSE, and MayaFlux::Nodes::Generator::WHILE_TRUE.

Referenced by process_multi_input(), and process_sample().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: