26class MAYAFLUX_API
ChainNode :
public Node,
public std::enable_shared_from_this<ChainNode> {
34 explicit ChainNode(std::vector<std::shared_ptr<Node>> nodes);
43 std::vector<std::shared_ptr<Node>> nodes,
53 const std::shared_ptr<Node>& source,
54 const std::shared_ptr<Node>& target);
64 const std::shared_ptr<Node>& source,
65 const std::shared_ptr<Node>& target,
73 void append(
const std::shared_ptr<Node>& node);
79 void append_chain(
const std::shared_ptr<ChainNode>& other);
84 [[nodiscard]]
size_t size()
const {
return m_nodes.size(); }
89 [[nodiscard]]
const std::vector<std::shared_ptr<Node>>&
nodes()
const {
return m_nodes; }
100 double process_sample(
double input = 0.)
override;
101 std::vector<double> process_batch(
unsigned int num_samples)
override;
105 return m_nodes.empty() ? 0 : m_nodes.back()->on_tick(
callback);
110 return m_nodes.empty() ? 0 : m_nodes.back()->on_tick_if(condition,
callback);
115 return !m_nodes.empty() && m_nodes.back()->unhook(
id);
120 return !m_nodes.empty() && m_nodes.back()->remove_hook(
callback);
125 return !m_nodes.empty() && m_nodes.back()->remove_conditional_hook(
callback);
130 if (!m_nodes.empty())
131 m_nodes.back()->remove_all_hooks();
134 void reset_processed_state()
override;
136 void save_state()
override;
137 void restore_state()
override;
143 [[nodiscard]] std::vector<std::pair<ModulatorRole, std::shared_ptr<Node>>> get_modulators()
const override;
153 bool m_is_initialized {};
154 bool m_state_saved {};
Core::GlobalInputConfig input
std::vector< std::shared_ptr< Node > > m_nodes
HookId on_tick_if(const NodeCondition &condition, const NodeHook &callback) override
Registers a conditional callback.
void update_context(double) override
Updates the context object with the current node state.
bool unhook(HookId id) override
Removes the one registration with this id, whichever hook list holds it.
HookId on_tick(const NodeHook &callback) override
Registers a callback to be called on each tick.
void remove_all_hooks() override
Removes all registered callbacks.
bool remove_hook(const NodeHook &callback) override
Removes a previously registered callback.
bool remove_conditional_hook(const NodeCondition &callback) override
Removes a previously registered conditional callback.
void notify_tick(double) override
Notifies all registered callbacks with the current context.
const std::vector< std::shared_ptr< Node > > & nodes() const
Returns a const reference to the internal node sequence.
size_t size() const
Returns the number of nodes in the chain.
Connects an ordered sequence of nodes in series.
Base context class for node callbacks.
Central manager for the computational processing node graph.
Base interface for all computational processing nodes.
TypedHook<> NodeHook
Alias for TypedHook<NodeContext>.
ProcessingToken
Enumerates the different processing domains for nodes.
uint64_t HookId
Identifies one registration inside a HookList.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
Contains the node-based computational processing system components.
bool is_initialized()
Checks if the default engine has been initialized.