mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
Add has_hook functions taking function pointer or callback data in EventHandler
This commit is contained in:
parent
1583196022
commit
b71ee446e3
@ -182,6 +182,46 @@ has_hook(const string &event_name) const {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if there is the hook added on the indicated event name and
|
||||
* function pointer, false otherwise.
|
||||
*/
|
||||
bool EventHandler::
|
||||
has_hook(const string &event_name, EventFunction *function) const {
|
||||
assert(!event_name.empty());
|
||||
Hooks::const_iterator hi;
|
||||
hi = _hooks.find(event_name);
|
||||
if (hi != _hooks.end()) {
|
||||
const Functions& functions = (*hi).second;
|
||||
if (functions.find(function) != functions.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if there is the hook added on the indicated event name,
|
||||
* function pointer and callback data, false otherwise.
|
||||
*/
|
||||
bool EventHandler::
|
||||
has_hook(const string &event_name, EventCallbackFunction *function, void *data) const {
|
||||
assert(!event_name.empty());
|
||||
CallbackHooks::const_iterator chi;
|
||||
chi = _cbhooks.find(event_name);
|
||||
if (chi != _cbhooks.end()) {
|
||||
const CallbackFunctions& cbfunctions = (*chi).second;
|
||||
if (cbfunctions.find(CallbackFunction(function, data)) != cbfunctions.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the indicated function from the named event hook. Returns true if
|
||||
* the hook was removed, false if it wasn't there in the first place.
|
||||
|
@ -55,6 +55,9 @@ public:
|
||||
bool add_hook(const string &event_name, EventCallbackFunction *function,
|
||||
void *data);
|
||||
bool has_hook(const string &event_name) const;
|
||||
bool has_hook(const string &event_name, EventFunction *function) const;
|
||||
bool has_hook(const string &event_name, EventCallbackFunction *function,
|
||||
void *data) const;
|
||||
bool remove_hook(const string &event_name, EventFunction *function);
|
||||
bool remove_hook(const string &event_name, EventCallbackFunction *function,
|
||||
void *data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user