|
Boost Users : |
From: Douglas Gregor (dgregor_at_[hidden])
Date: 2005-02-07 00:16:36
On Feb 6, 2005, at 10:13 AM, Tony Juricic wrote:
> Shame be where it belongs, after rading documentation, implementation,
> examples and test code, I am unable to write what should be simple
> signals code:
>
> ---------------------------------------------
> *.h
>
> typedef boost::function<void (void)> Callback;
You should replace the Callback typedef with:
typedef boost::signal<void(void)>::slot_type Callback;
That'll make all of the object tracking stuff work properly.
> boost::signal<void (void)> mySignal;
>
> void Signal::Connect(Callback f)
> {
> // iterate over signal slots, if slot equals input f do nothing
> // otherwise connect f
> }
This operation is not possible with Signals: you can't get at the
individual slots once they're connected. Essentially, Signals was
designed with the idea that comparing function objects for equality
when connecting/disconnecting is a bad idea, because it breaks down
when the function objects you build are non-trivial (because it becomes
hard to duplicate the function object when calling disconnect()).
Doug
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net