27template <
typename ContextT = NodeContext>
72 const std::type_info*
key { &
typeid(void) };
107 : m_list(std::exchange(other.m_list,
nullptr))
108 , m_entries(std::exchange(other.m_entries,
nullptr))
113 [[nodiscard]]
const HookEntry*
begin()
const {
return m_entries ? m_entries->data() :
nullptr; }
114 [[nodiscard]]
const HookEntry*
end()
const {
return m_entries ? m_entries->data() + m_entries->size() :
nullptr; }
115 [[nodiscard]]
size_t size()
const {
return m_entries ? m_entries->size() : 0; }
116 [[nodiscard]]
bool empty()
const {
return size() == 0; }
128 const std::vector<HookEntry>* m_entries {
nullptr };
140 HookId add(
NodeHook hook,
const std::type_info& key, uint8_t tag = 0, std::array<double, 2> params = {});
143 HookId add_unique(
NodeHook hook,
const std::type_info& key, uint8_t tag = 0, std::array<double, 2> params = {});
146 HookId add_conditional(NodeHook hook, NodeCondition condition,
const std::type_info& key, uint8_t tag = 0);
149 HookId add_conditional_unique(NodeHook hook, NodeCondition condition,
const std::type_info& key, uint8_t tag = 0);
152 bool remove(HookId
id);
155 bool remove_by_key(
const std::type_info& key);
158 bool remove_first_by_key(
const std::type_info& key);
161 bool remove_by_condition_key(
const std::type_info& key);
164 bool remove_by_tag(uint8_t tag);
168 [[nodiscard]]
bool empty()
const;
169 [[nodiscard]]
size_t size()
const;
172 [[nodiscard]] Snapshot snapshot()
const;
175 void fire(NodeContext& ctx)
const;
180 bool mutate(
const std::function<
bool(std::vector<HookEntry>&)>& edit);
181 HookId next_id()
const;
182 void retire(
const std::vector<HookEntry>* old);
186 std::atomic<const std::vector<HookEntry>*> m_head {
nullptr };
187 std::atomic<Retired*> m_retired {
nullptr };
188 mutable std::atomic<uint32_t> m_readers { 0 };
196template <
typename ContextT>
201 hook(
static_cast<ContextT&
>(ctx));
308MAYAFLUX_API std::vector<uint32_t>
get_active_channels(
const std::shared_ptr<Nodes::Node>& node, uint32_t fallback_channel = 0);
316MAYAFLUX_API std::vector<uint32_t>
get_active_channels(uint32_t channel_mask, uint32_t fallback_channel = 0);
Snapshot & operator=(Snapshot &&)=delete
const HookEntry * end() const
Snapshot(Snapshot &&other) noexcept
Snapshot(const HookList *list, const std::vector< HookEntry > *entries)
Snapshot(const Snapshot &)=delete
const HookEntry * begin() const
Snapshot & operator=(const Snapshot &)=delete
The entries of a list at one instant, kept alive while this object exists.
HookList & operator=(HookList &&)=delete
HookList(const HookList &)=delete
HookList & operator=(const HookList &)=delete
HookList(HookList &&)=delete
Stores, fires and clears the hooks of one node channel.
Base context class for node callbacks.
Base interface for all computational processing nodes.
TypedHook<> NodeHook
Alias for TypedHook<NodeContext>.
NodeState
Represents the processing state of a node in the audio graph.
void try_reset_processed_state(std::shared_ptr< Node > node)
Attempts to reset the processed state of a node.
void atomic_set_flag_weak(std::atomic< NodeState > &flag, NodeState &expected, const NodeState &desired)
Atomically sets a node state flag with weak memory ordering.
void atomic_inc_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically increments the modulator count by a specified amount.
uint64_t HookId
Identifies one registration inside a HookList.
void atomic_dec_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically decrements the modulator count by a specified amount.
void update_routing_state(RoutingState &state)
Updates the routing state for a node based on its current channel usage.
void atomic_set_strong(std::atomic< NodeState > &flag, NodeState &expected, const NodeState &desired)
Atomically sets a node state flag with strong memory ordering.
std::function< void(ContextT &)> TypedHook
Callback function type for node processing events, parameterised on context type.
void atomic_remove_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically removes a flag from a node state.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
void atomic_set_flag_strong(std::atomic< NodeState > &flag, const NodeState &desired)
Atomically sets a node state flag to a specific value.
std::vector< uint32_t > get_active_channels(const std::shared_ptr< Nodes::Node > &node, uint32_t fallback_channel)
Extracts active channel list from a node's channel mask.
NodeHook adapt_hook(const TypedHook< ContextT > &hook)
Wraps a context-typed hook into a NodeHook.
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.
Contains the node-based computational processing system components.
std::array< double, 2 > params
const std::type_info * key
std::optional< NodeCondition > condition
One registration held by a HookList.