views:

323

answers:

1

I am using libsigc++ to wire up an application, and is uncertain as to the easier way of going about it.

There is a preexisting object hierarchy that manages the data layer, and the top level object exposes all functions. All good so far.

To this I am adding a GUI object hierarchy, and in the application object I am hooking them together with signal connections. To make a connection, I need pointers to both sender and receiver.

Now, do I hook in a child widget, far down in the tree, directly, thus requiring pointers to be passed up and down the tree?

Or, do I go through the painstaking processes of hooking in signals and slots at every step in the chain?

On the one hand, passing pointers break the separation that the sig-slot model buys you. On the other hand, creating connections at every step does not seem to rhyme with the supposed "event telepathy" that the sig-slots are supposed to provide.

Which one would someone experienced with this model consider the default approach?

+1  A: 

Personally, I don't see any problem by 'skipping' layers with the signal/slots mechanism. I prefer to see it this way: a component is sending signals into the wild, and whoever is interested in those signals may listen to them.

A couple of tips: avoid to send signals that are too generic, and don't rely on the order of execution of the slots (if many slots are called for a given signal).

Martin Cote