diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-05 00:15:24 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-05 00:15:24 +0100 |
commit | 9b1db73f776309668b1f5fa20dece1849c8d035b (patch) | |
tree | 81f411906de269f22fa38a144eb65bcc8143df7c /src/core/managed/Events.hpp | |
parent | 0abccb029e55326f9de99563e38ed4c9a87eb4d1 (diff) |
Using weak references for storing the owner in events.
Diffstat (limited to 'src/core/managed/Events.hpp')
-rw-r--r-- | src/core/managed/Events.hpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/managed/Events.hpp b/src/core/managed/Events.hpp index 768f0aa..a69c363 100644 --- a/src/core/managed/Events.hpp +++ b/src/core/managed/Events.hpp @@ -28,6 +28,8 @@ #ifndef _OUSIA_EVENTS_HPP_ #define _OUSIA_EVENTS_HPP_ +#include <cstdint> + #include <string> namespace ousia { @@ -147,9 +149,9 @@ struct EventHandlerDescriptor { EventHandler handler; /** - * Owner object. + * Weak reference to the owner object. */ - Managed *owner; + uint64_t ownerUid; /** * User defined data. @@ -162,15 +164,15 @@ struct EventHandlerDescriptor { * @param type is the event type for which the handler is registered. * @param handler is the function pointer which is going to be called once * the associated event handler has fired. - * @param owner is a user-specified object which owns the method that is + * @param ownerUid is a user-specified object which owns the method that is * going to be called. This can be used to make sure that the method which * handles the events has access to its owned object as long as the event * handler lives. * @param data is some arbitrary user defined data. */ - EventHandlerDescriptor(EventType type, EventHandler handler, Managed *owner, - void *data) - : type(type), handler(handler), owner(owner), data(data) + EventHandlerDescriptor(EventType type, EventHandler handler, + uint64_t ownerUid, void *data) + : type(type), handler(handler), ownerUid(ownerUid), data(data) { } @@ -182,7 +184,8 @@ struct EventHandlerDescriptor { /** * Returns the name of the current event type. */ - const char *getEventTypeName() const { + const char *getEventTypeName() const + { return getEventTypeName(this->type); } }; |