I’m just trying to figure out what makes the Signal/Slot (Pattern?). Wikipedia tells me not so much and calls it an implementation of the ObserverPattern* while I would think it has much more resemblance to the DataBusPattern**.
Can someone explain in an abstract way what Signal/Slot is? Do the participants in Signal/Slot need to know each other (as in ObserverPattern) or not (as in DataBusPattern) and what are the key differences?
I tried to figure it out reading the QT docs, but there is to much C++ magic.
*) http://c2.com/cgi/wiki?ObserverPattern
**) http://c2.com/cgi/wiki?DataBusPattern
1
The connection information between a signal and a slot is completely held between the connected sender and receiver objects. See here for more information. A connect
operation is always given between two concrete instances, and the programmer must know about both of them. One is doing the publishing, one is doing the subscribing. You can connect many signals to one slot, and many slots to one signal, but each connection is made individually.
In a data bus pattern, you don’t make individual connections. You just broadcast your events onto the bus, and every receiver on the bus receives every single event. They can choose not to do anything with certain events, but they can’t choose not to receive them at all.
2