core: data_item(_t) -> DataItem, memory_item(_t) -> MemoryItem
[lumina.git] / core / src / filter.c
blob0b65de3ec014a9ea5bda829c5ad0a1765136c6ab
1 #include "filter.h"
3 #include <assert.h> /* assert */
5 /* Since the behavior for every 'simply filtered' item is the same, use a macro */
6 #define CASE_FILTER_ACTION(condition,function) \
7 case condition: \
8 if(f->function) { \
9 f->function(filter, mode, item, next, nextData); \
10 } else { \
11 next(nextData, mode, item); \
12 } \
13 break;
15 void SimpleFilter_action(void *filter, FilterMode mode, DataItem *item, FilterAction_next next, void *nextData) {
16 assert(filter && next);
17 SimpleFilter *f = (SimpleFilter*)filter;
19 switch(mode) {
20 CASE_FILTER_ACTION(FILTER_WRITE, onWrite)
21 CASE_FILTER_ACTION(FILTER_WRITE_COMPLETE, onWriteComplete)
22 CASE_FILTER_ACTION(FILTER_READ, onRead)
23 CASE_FILTER_ACTION(FILTER_READ_COMPLETE, onReadComplete)
24 default:
25 /* By default just pass it on no matter what it is*/
26 next(nextData, mode, item);
27 break;