|
Boost : |
Subject: Re: [boost] Interest in non-intrusive signal/slot lib?
From: Edward Diener (eldiener_at_[hidden])
Date: 2015-05-16 17:35:20
On 5/16/2015 3:04 PM, Emil Dotchevski wrote:
> On Sat, May 16, 2015 at 11:50 AM, Edward Diener <eldiener_at_[hidden]>
> wrote:
>
>> I assume that the purpose of having the signal type be a pointer to a
>>>> function taking some data and returning an incomplete type instead of
>>>> returning void is to make each signal type unique. But is this really
>>>> necessary ?
>>>>
>>>
>>> It is necessary so that if you have:
>>>
>>> typedef struct button_down_(*button_down)(int x, int y);
>>>
>>> you can tell it apart from
>>>
>>> typedef struct button_up_(*button_up)(int x, int y);
>>>
>>>
>> I understand that the types are different but when would you ever use that
>> knowledge in code ?
>
>
> It seems you're asking why are different signals necessary, e.g. why would
> I need to discriminate between a "button down" and a "button up" event --
> which is puzzling. Anyway, the answer is that you need different signals so
> that you can tell connect<> which signal you're connecting (and emit<>
> which signal you're emitting) from the specified emitter object:
>
> void handle_button_down( int x, int y );
> void handle_button_up( int x, int y );
>
> auto c1=connect<button_down>(e,&handle_button_down);
> auto c2=connect<button_up>(e,&handle_button_up);
typedef void (*button_down)(int x, int y);
typedef void (*button_up)(int x, int y);
void handle_button_down( int x, int y );
void handle_button_up( int x, int y );
auto c1=connect<button_down>(e,&handle_button_down);
auto c2=connect<button_up>(e,&handle_button_up);
Is there some reason why the above would not work ? The fact that
button_down and button_up are the same types above but different types
the way synapse is currently designed seems irrelevant. I am enquiring
whether there is an internal reason for that.
>
>
>> The signal handler knows nothing about the type of the signal except that
>> it's signature matches the parameters of the signal.
>
>
> The signal handling code knows nothing about signals at all.
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk