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

◆ remove_hook()

bool MayaFlux::Nodes::Generator::Counter::remove_hook ( const NodeHook callback)
overridevirtual

Removes a previously registered callback.

Parameters
callbackThe callback to remove
Returns
True if the callback was found and removed, false otherwise

Unregisters a callback that was previously registered with on_tick(). After removal, the callback will no longer be triggered when the node produces new output values.

This method is useful for cleaning up callbacks when they are no longer needed, preventing memory leaks and unnecessary processing.

Reimplemented from MayaFlux::Nodes::Node.

Definition at line 32 of file Counter.cpp.

33{
34 bool r = safe_remove_callback(m_callbacks, callback);
35 auto erase_typed = [&](auto& vec) {
36 auto before = vec.size();
37 std::erase_if(vec, [&](const auto& cb) {
38 return cb.target_type() == callback.target_type();
39 });
40 return vec.size() < before;
41 };
42 r |= erase_typed(m_increment_callbacks);
43 r |= erase_typed(m_wrap_callbacks);
44 std::erase_if(m_count_callbacks, [&](const auto& p) {
45 return p.second.target_type() == callback.target_type();
46 });
47 return r;
48}
std::vector< TypedHook< GeneratorContext > > m_increment_callbacks
Definition Counter.hpp:136
std::vector< TypedHook< GeneratorContext > > m_wrap_callbacks
Definition Counter.hpp:137
std::vector< std::pair< uint32_t, TypedHook< GeneratorContext > > > m_count_callbacks
Definition Counter.hpp:138
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
Definition Node.hpp:426
bool safe_remove_callback(std::vector< TypedHook< ContextT > > &callbacks, const TypedHook< ContextT > &callback)
Removes all callbacks whose target_type() matches that of the supplied callback.
Definition NodeUtils.hpp:92

References MayaFlux::Nodes::Node::m_callbacks, m_count_callbacks, m_increment_callbacks, m_wrap_callbacks, and MayaFlux::Nodes::safe_remove_callback().

+ Here is the call graph for this function: