Boost logo

Boost :

From: Mathew Robertson (mathew.robertson_at_[hidden])
Date: 2004-08-22 17:44:52

> > 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.


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