From 45f891fe0368efead661240fef872d006db34d05 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Fri, 2 Jan 2015 23:35:24 +0100 Subject: Allowing to pass arbitrary data to an event handler (not only Managed objects) --- src/core/managed/Manager.hpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/core/managed/Manager.hpp') diff --git a/src/core/managed/Manager.hpp b/src/core/managed/Manager.hpp index 0e9d519..3bcf3e8 100644 --- a/src/core/managed/Manager.hpp +++ b/src/core/managed/Manager.hpp @@ -325,11 +325,12 @@ public: * from the the reference object to the owner is added. The argument may be * nullptr in which case no reference is added. The owner is passed to the * event handler as second parameter. + * @param data is some user defined data. * @return a numeric event id, which is unique for the given reference * object. The event id must be used when unregistering event handlers. */ EventId registerEvent(Managed *ref, EventType type, EventHandler handler, - Managed *owner); + Managed *owner, void *data); /** * Unregisters the event with the given event id from the given reference @@ -343,13 +344,31 @@ public: */ bool unregisterEvent(Managed *ref, EventId id); + /** + * Searches for the event with the given signature and removes it. + * + * @param ref is the reference object for which the event should be + * registered. + * @param type is the event type that should be registered. + * @param handler is the callback function. + * @param owner is a managed object that owns the event handler. A reference + * from the the reference object to the owner is added. The argument may be + * nullptr in which case no reference is added. The owner is passed to the + * event handler as second parameter. + * @param data is some user defined data. + * @return true if the operation was successful, false if either the + * reference object or and event with the given signature do not exist. + */ + bool unregisterEvent(Managed *ref, EventType type, EventHandler handler, + Managed *owner, void *data); + /** * Triggers the event of the given type for the reference object. * * @param ref is the object for which the given event should be triggered. * @param data is the event data that should be passed to the handlers. */ - bool triggerEvent(Managed *ref, Event &data); + bool triggerEvent(Managed *ref, Event &ev); }; } -- cgit v1.2.3