Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2004-08-22 18:20:21

Mathew Robertson wrote:
>>> It might be easier to group events by type, use signals to dispatch
>>> them and an event handler like I suggested to deal with them, e.g.
>>> MouseEvent( unsigned int event, const MouseEvent & info );
>>> KeyEvent( unsigned int event, const KeyEvent & info );
>> Why do you have to create event handlers for people to use. Just
>> create boost::signal<> which encapsulates the parameters you want to
>> pass when the event occurs. Give it a name which relates to the
>> event that is happening, and let anyone simply add their slot to the
>> signal. When your code determines that the event has occurred, just
>> trigger the signal and allow anyone, including your own internal
>> code if necessary, to handle the event. Why do I like this ? Because
>> systems that determine that one must be this-or-that to handle an
>> event are always unnecessarily limiting in one way or another.
> The problem with the "registering your self in a slot" approach, is
> that most events generate actions -> ie they application flow is
> bi-directional. The signal/slot approach (usually) suffers from not
> being able to send a response back to the event sender.

The boost::signal<> is fully capable of returning a response. Take a look at
it. Furthermore even if it weren't, it is child's play to pass a reference
or pointer to something in which a response is put. Finally any handler of a
boost::signal<> can generate their own event in response themselves.

Boost list run by bdawes at, gregod at, cpdaniel at, john at