| Line 12 was replaced by lines 12-23 |
| - In our example we have a module ''nodehandling''. |
| + Given the following functions dealing with callbacks: |
| + {{{ |
| + typedef void KillFunc(void *); |
| + typedef int CallbackFunction(Hdb *node, void *msg, void *data); |
| + typedef struct Callback Callback; |
| + |
| + InvokeCallback(Hdb *node, void *msg); |
| + Callback *MakeCallback(CallbackFunction *cbFunc, void *data, KillFunc *killFunc); |
| + AppendCallback(Hdb *node, Callback *cb); |
| + PrependCallback(Hdb *node, Callback *cb); |
| + }}} |
| + The callbacks are stored as one list per node. |
| Line 14 was replaced by line 25 |
| - Extract from nodehandling.h: |
| + Extract from (sics)hipadaba.h: |
| Removed line 19 |
| - Hdb *node; |
| Line 23 was replaced by line 33 |
| - SetCallbackMsg *SetClassCast(void *msg); |
| + SetCallbackMsg *SetCallbackCast(void *msg); |
| Lines 26-30 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 32 was replaced by line 40 |
| - Extract from nodehandling.c: |
| + Extract from (sics)hipadaba.c: |
| Line 36 was replaced by line 44 |
| - SetCallbackMsg *SetClassCast(void *msg) { |
| + SetCallbackMsg *SetCallbackCast(void *msg) { |
| Removed line 50 |
| - setMsg.node = node; |
| Line 52 was replaced by line 59 |
| - CallCallback(callbacklist, &setMsg); |
| + InvokeCallback(node, &setMsg); |
| Line 56 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 62-63 were replaced by lines 69-71 |
| - SetCallbackMsg *setMsg = SetClassCast(msg); |
| - |
| + SetCallbackMsg *setMsg = SetCallbackCast(msg); |
| + MyData *mydata; |
| + |
| Line 65 was replaced by lines 73-74 |
| - |
| + |
| + mydata = data; |
| Line 81 was replaced by line 90 |
| - cb = MakeCallback(MySetCallback, data, (KillFunc)KillMyData); |
| + cb = MakeCallback(MySetCallback, data, (KillFunc *)KillMyData); |
| At line 84 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 |
| + |