Big Bucket Software you like to use
Message Passing
October 29th, 2005

I wouldn’t get too used to this flurry of activity; I’m making up for the many months of development that went undocumented 🙂

So message-passing…

Currently, when something interesting happens to an object, it emits a signal. For example, when the lampshade is manipulated it emits the signal, IsManipulated, with the parameter ‘true’. Similarly, when the lampshade is manipulated again, it will emit the signal, IsManipulated with the parameter ‘false’. Something that may recieve/emit signals is a MessageColleague.

Signals are received by the Messenger who forwards them to whoever has registered an interest. Interest is registered like so:

Messenger messenger;

Signal wallswitch_manipulated(
    wallswitch,
    SignalType_IsManipulated,
    true);

Slot lamphsade_enable(
    lampshade,
    SlotType_SetEnabled,
    true);

messenger.link(wallswitch_manipulated, lampshade_enable);

What the above is saying, is that when the wallswitch is manipulated/turned on, the lampshade is enabled. We also want the lampshade to turn off when the wallswitch is turned off, so:

Signal wallswitch_unmanipulated(
    wallswitch,
    SignalType_IsManipulated,
    false);

Slot lampshade_disable(lampshade, SlotType_SetEnabled, false);
Slot lampshade_unmanipulate(
    lampshade,
    SlotType_SetManipulated,
    false);

messenger.link(wallswitch_unmanipulated, lampshade_disable);
messenger.link(
    wallswitch_unmanipulated,
    lampshade_unmanipulate);

A Slot is an encapsulation of:

  • Who is interested
  • How to respond

Currently, the drawback to this technique is that when the wallswitch is turned back on, if the lampshade switch is still on, it should light up. I’m working on the concept of flags which are associated with MessageColleague’s to deal with this… More later.