Boost logo

Boost :

Subject: Re: [boost] Interest in non-intrusive signal/slot lib?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2015-05-16 15:04:35

On Sat, May 16, 2015 at 11:50 AM, Edward Diener <eldiener_at_[hidden]>

> 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);

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

Emil Dotchevski
Reverge Studios, Inc.

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