Re: Subscriber callback interface design
From: David Rubin (fullname_at_warpmail.net)
Date: 05/16/04
- Next message: John Harrison: "Re: Memory leak"
- Previous message: Greg Comeau: "Re: linker errors when I use template friends?"
- In reply to: Denis Remezov: "Re: Subscriber callback interface design"
- Next in thread: Edward Diener: "Re: Subscriber callback interface design"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 16 May 2004 16:35:34 GMT
Denis Remezov wrote:
[snip]
> In this case, to avoid overdesigning, I would probably keep the original
> EventHandlerInterface and change RegisterEvent/UnregisterEvent to accept
> just a pointer to the interface without the event type (all HandleEvent__s()
> will be called).
> Compared to your more general solution, this design is quite simpler:
> - an implementation of EventHandlerInterface does not need to do
> dispatching (a big relief);
This is a very important point. In general, clients should be able to
register handlers on a per-event basis. This goes a long way towards
insulating clients from changes to the Event interface.
> - EventHandlerInterface doesn't care about EventTypeEnum;
And It shouldn't be as event handlers are only called for the types they
are registered for (and parameterized by event-specific data types if
necessary).
> - event data types do not need to have a single base class (no, they may
> happen to have nothing in common);
> - registration is much easier;
> - there is less coding.
One thing you might want to consider is allowing clients to register
event handler functors rather than event handler objects. This allows
you to 1) use free functions as an event handler while at the same time
2) use a (pointer-to) member function, but avoid multiple inheritance
(of MyBase + EventHandlerInterface) in your class hierarchy.
/david
-- "As a scientist, Throckmorton knew that if he were ever to break wind in the echo chamber, he would never hear the end of it."
- Next message: John Harrison: "Re: Memory leak"
- Previous message: Greg Comeau: "Re: linker errors when I use template friends?"
- In reply to: Denis Remezov: "Re: Subscriber callback interface design"
- Next in thread: Edward Diener: "Re: Subscriber callback interface design"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|