diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-02 23:35:24 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2015-01-02 23:35:24 +0100 |
commit | 45f891fe0368efead661240fef872d006db34d05 (patch) | |
tree | 4ad3af7a489fc5ea6b29b0baf266a1c58a9fa26b /src/core/managed/Managed.hpp | |
parent | d10aab38d5fca62c4da2d98f7c7c6877906ebe58 (diff) |
Allowing to pass arbitrary data to an event handler (not only Managed objects)
Diffstat (limited to 'src/core/managed/Managed.hpp')
-rw-r--r-- | src/core/managed/Managed.hpp | 22 |
1 files changed, 20 insertions, 2 deletions
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<Managed> owner); + Handle<Managed> 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<Managed> 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 */ |