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

◆ safe_add_callback()

bool MayaFlux::Nodes::safe_add_callback ( std::vector< NodeHook > &  callbacks,
const NodeHook callback 
)

Safely adds a callback to a collection if it doesn't already exist.

Parameters
callbacksThe collection of callbacks to add to
callbackThe callback function to add
Returns
True if the callback was added, false if it already existed

This function first checks if the callback already exists in the collection, and only adds it if it's not already present. This prevents duplicate registrations of the same callback function.

Definition at line 33 of file NodeUtils.cpp.

34{
35 if (!callback_exists(callbacks, callback)) {
36 callbacks.push_back(callback);
37 return true;
38 }
39 return false;
40}
bool callback_exists(const std::vector< NodeHook > &callbacks, const NodeHook &callback)
Checks if a callback function already exists in a collection.
Definition NodeUtils.cpp:9

References callback_exists().

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

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