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/Managed.hpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/core/managed/Managed.hpp') diff --git a/src/core/managed/Managed.hpp b/src/core/managed/Managed.hpp index 4a38dbd..cdf81aa 100644 --- a/src/core/managed/Managed.hpp +++ b/src/core/managed/Managed.hpp @@ -146,11 +146,29 @@ 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(EventType type, EventHandler handler, - Handle owner); + Handle owner, + void *data = nullptr); + + /** + * Unregisters the event handler with the given signature. + * + * @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 a numeric event id, which is unique for the given reference + * object. The event id must be used when unregistering event handlers. + */ + bool unregisterEvent(EventType type, EventHandler handler, + Handle owner, void *data = nullptr); /** * Unregisters the event with the given event id. @@ -167,7 +185,7 @@ public: * * @param data is the event data that should be passed to the handlers. */ - bool triggerEvent(Event &data); + bool triggerEvent(Event &ev); /* RTTI methods */ -- cgit v1.2.3