At line 22 added 1 line. |
+ The callbacks are stored as one list per node. |
Lines 24-26 were replaced by line 25 |
- In our example we have a module ''nodehandling''. |
- |
- Extract from nodehandling.h: |
+ Extract from (sics)hipadaba.h: |
Line 34 was replaced by line 33 |
- SetCallbackMsg *SetClassCast(void *msg); |
+ SetCallbackMsg *SetCallbackCast(void *msg); |
Lines 37-39 were replaced by lines 36-38 |
- 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. SetCallbackCast reveals if an anonymous message is a SetCallbackMsg. It returns |
+ NULL otherwise. |
Line 41 was replaced by line 40 |
- Extract from nodehandling.c: |
+ Extract from (sics)hipadaba.c: |
Line 45 was replaced by line 44 |
- SetCallbackMsg *SetClassCast(void *msg) { |
+ SetCallbackMsg *SetCallbackCast(void *msg) { |
Removed line 59 |
- setMsg.node = node; |
Line 65 was replaced by line 63 |
- for logging purposes. Checking of a particular class should be done by comparing |
+ for logging purposes. The check for a particular class is done by comparing |
Lines 71-72 were replaced by lines 69-71 |
- SetCallbackMsg *setMsg = SetClassCast(msg); |
- |
+ SetCallbackMsg *setMsg = SetCallbackCast(msg); |
+ MyData *mydata; |
+ |
Line 74 was replaced by lines 73-74 |
- |
+ |
+ mydata = data; |
Line 90 was replaced by line 90 |
- cb = MakeCallback(MySetCallback, data, (KillFunc)KillMyData); |
+ cb = MakeCallback(MySetCallback, data, (KillFunc *)KillMyData); |
At line 93 added 33 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 */ |
+ } |
+ }}} |
+ |
+ For the implementation of Hipadaba at least the following callbacks have |
+ to be implemented: |
+ |
+ * SetCallback |
+ * ReadCallback |
+ * UpdateCallback |
+ * KillForIDCallback |
+ * KillForInternalIDCallback |
+ |