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

◆ add_unique()

HookId MayaFlux::Nodes::HookList::add_unique ( NodeHook  hook,
const std::type_info &  key,
uint8_t  tag = 0,
std::array< double, 2 >  params = {} 
)

Appends unless an entry with the same key and params exists, in which case that entry's id is returned.

Definition at line 159 of file NodeUtils.cpp.

160{
161 const HookId fresh = next_id();
162 HookId result = fresh;
163 mutate([&](std::vector<HookEntry>& entries) {
164 const auto it = std::ranges::find_if(entries, [&](const HookEntry& entry) {
165 return *entry.key == key && entry.params == params;
166 });
167 if (it != entries.end()) {
168 result = it->id;
169 return false;
170 }
171 result = fresh;
172 entries.push_back(HookEntry { fresh, &key, tag, params, hook, std::nullopt });
173 return true;
174 });
175 return result;
176}
bool mutate(const std::function< bool(std::vector< HookEntry > &)> &edit)
uint64_t HookId
Identifies one registration inside a HookList.
Definition NodeUtils.hpp:60

References MayaFlux::Nodes::HookEntry::key, mutate(), next_id(), and MayaFlux::Nodes::HookEntry::params.

Referenced by MayaFlux::Nodes::GpuSync::GpuComputeNode::on_complete(), MayaFlux::Nodes::Generator::Impulse::on_impulse(), MayaFlux::Nodes::Generator::Phasor::on_phase_wrap(), MayaFlux::Nodes::Generator::Phasor::on_threshold(), and MayaFlux::Nodes::Node::on_tick().

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