|
Boost : |
From: Edward Diener (eddielee_at_[hidden])
Date: 2004-09-23 22:36:34
Reece Dunn wrote:
> There has been discussions in earlier threads (Java style GUI in C++)
> about using boost::signal as an event handler. I have two questions
> regarding this:
> (1) if I have n message types, do I need n boost::signal objects?
Define message types ? Boost signal works off of signals defining a
particular member signature for a slot to handle the signal.
> If
> so,
> this would increase the size of each component.
You can have base class components handle certain signals and derived class
components only handle signals which base class components do not handle.
This is no different than any other OOP framework with virtual functions.
> Also, what if you
> want a "handle all events" handler.
What's you parameters for handling any event. Unless they are void *, or
better yet boost::any or boost::variant, with extra info to define the
particular event, you will be hard put to handle all events with a single
handler. Somehow the handler must know what event it is handling when it
does so.
> (2) if generic events are defined in an 'event' object, and a handler
> function has the form:
>
> event_handled_type eventfn( const event & e );
>
> what if you want to support:
>
> event_handled_type pressed( const mouse_event & me );
> event_handled_type key_down( const key_event & ke );
What are you trying to do here ? I would assume that mouse_event and
key_event are derived from event.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk