Line 34 was replaced by line 34 |
- SetCallbackMsg *SetClassCast(void *msg); |
+ SetCallbackMsg *SetCallbackCast(void *msg); |
Lines 37-39 were replaced by lines 37-39 |
- The members of callback message are all arguments needed for the handling of |
- the callback. SetClassCast converts an anonymous message to an implementation. It returns |
- the message if it is a SetCallbackMsg or NULL otherwise. |
+ The members of callback message contain the additional arguments needed for the handling of |
+ the callback. SetClassCast reveals if an anonymous message is a SetCallbackMsg. It returns |
+ NULL otherwise. |
Line 45 was replaced by line 45 |
- SetCallbackMsg *SetClassCast(void *msg) { |
+ SetCallbackMsg *SetCallbackCast(void *msg) { |
Lines 71-72 were replaced by lines 71-73 |
- SetCallbackMsg *setMsg = SetClassCast(msg); |
- |
+ SetCallbackMsg *setMsg = SetCallbackCast(msg); |
+ MyData *mydata; |
+ |
Line 74 was replaced by lines 75-76 |
- |
+ |
+ mydata = data; |
At line 93 added 23 lines. |
+ An implementation may use the same callback function for handling different |
+ callback messages, with the same user data: |
+ {{{ |
+ int CombinedCallback(Hdb *node, void * msg, void *data) { |
+ SetCallbackMsg *setMsg; |
+ UpdateCallbackMsg *updateMsg; |
+ MyData *mydata = data; |
+ |
+ setMsg = SetCallbackCast(msg); |
+ if (setMsg) { |
+ /* handle setMsg */ |
+ return 1; |
+ } |
+ |
+ updateMsg= UpdateCallbackCast(msg); |
+ if (updateMsg) { |
+ /* handle updateMsg */ |
+ return 1; |
+ } |
+ |
+ return 0; /* not handled */ |
+ } |
+ }}} |