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

◆ safe_add_conditional_callback()

bool MayaFlux::Nodes::safe_add_conditional_callback ( std::vector< std::pair< NodeHook, NodeCondition > > &  callbacks,
const NodeHook callback,
const NodeCondition condition 
)

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

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

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

Definition at line 42 of file NodeUtils.cpp.

43{
44 if (!callback_pair_exists(callbacks, callback, condition)) {
45 callbacks.emplace_back(callback, condition);
46 return true;
47 }
48 return false;
49}
bool callback_pair_exists(const std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeHook &callback, const NodeCondition &condition)
Checks if a specific callback and condition pair already exists.
Definition NodeUtils.cpp:25

References callback_pair_exists().

Referenced by MayaFlux::Nodes::Node::on_tick_if().

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