Navit SVN

/work/compile/navit/src/navit/callback.h

00001 
00020 #ifndef NAVIT_CALLBACK_H
00021 #define NAVIT_CALLBACK_H
00022 
00023 #include "item.h"
00024 #include "attr.h"
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 /* prototypes */
00030 enum attr_type;
00031 struct callback;
00032 struct callback_list;
00033 struct callback_list *callback_list_new(void);
00034 struct callback *callback_new_attr(void (*func)(void), enum attr_type type, int pcount, void **p);
00035 struct callback *callback_new_attr_args(void (*func)(void), enum attr_type type, int count, ...);
00036 struct callback *callback_new(void (*func)(void), int pcount, void **p);
00037 struct callback *callback_new_args(void (*func)(void), int count, ...);
00038 void callback_destroy(struct callback *cb);
00039 void callback_set_arg(struct callback *cb, int arg, void *p);
00040 void callback_list_add(struct callback_list *l, struct callback *cb);
00041 struct callback *callback_list_add_new(struct callback_list *l, void (*func)(void), int pcount, void **p);
00042 void callback_list_remove(struct callback_list *l, struct callback *cb);
00043 void callback_list_remove_destroy(struct callback_list *l, struct callback *cb);
00044 void callback_call(struct callback *cb, int pcount, void **p);
00045 void callback_call_args(struct callback *cb, int count, ...);
00046 void callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount, void **p);
00047 void callback_list_call_attr_args(struct callback_list *cbl, enum attr_type type, int count, ...);
00048 void callback_list_call(struct callback_list *l, int pcount, void **p);
00049 void callback_list_call_args(struct callback_list *cbl, int count, ...);
00050 void callback_list_destroy(struct callback_list *l);
00051 /* end of prototypes */
00052 
00053 #define callback_new_0(func) callback_new_args(func, 0)
00054 #define callback_new_1(func,p1) callback_new_args(func, 1, p1)
00055 #define callback_new_2(func,p1,p2) callback_new_args(func, 2, p1, p2)
00056 #define callback_new_3(func,p1,p2,p3) callback_new_args(func, 3, p1, p2, p3)
00057 #define callback_new_4(func,p1,p2,p3,p4) callback_new_args(func, 4, p1, p2, p3, p4)
00058 
00059 #define callback_new_attr_0(func,type) callback_new_attr_args(func, type, 0)
00060 #define callback_new_attr_1(func,type,p1) callback_new_attr_args(func, type, 1, p1)
00061 #define callback_new_attr_2(func,type,p1,p2) callback_new_attr_args(func, type, 2, p1, p2)
00062 #define callback_new_attr_3(func,type,p1,p2,p3) callback_new_attr_args(func, type, 3, p1, p2, p3)
00063 #define callback_new_attr_4(func,type,p1,p2,p3,p4) callback_new_attr_args(func, type, 4, p1, p2, p3, p4)
00064 
00065 #define callback_call_0(cb) callback_call_args(cb, 0)
00066 #define callback_call_1(cb,p1) callback_call_args(cb, 1, p1)
00067 #define callback_call_2(cb,p1,p2) callback_call_args(cb, 2, p1, p2)
00068 #define callback_call_3(cb,p1,p2,p3) callback_call_args(cb, 3, p1, p2, p3)
00069 #define callback_call_4(cb,p1,p2,p3,p4) callback_call_args(cb, 4, p1, p2, p3, p4)
00070 
00071 #define callback_list_call_0(cbl) callback_list_call_args(cbl, 0)
00072 #define callback_list_call_1(cbl,p1) callback_list_call_args(cbl, 1, p1)
00073 #define callback_list_call_2(cbl,p1,p2) callback_list_call_args(cbl, 2, p1, p2)
00074 #define callback_list_call_3(cbl,p1,p2,p3) callback_list_call_args(cbl, 3, p1, p2, p3)
00075 #define callback_list_call_4(cbl,p1,p2,p3,p4) callback_list_call_args(cbl, 4, p1, p2, p3, p4)
00076 
00077 #define callback_list_call_attr_0(cbl,type) callback_list_call_attr_args(cbl,type, 0)
00078 #define callback_list_call_attr_1(cbl,type,p1) callback_list_call_attr_args(cbl, type, 1, p1)
00079 #define callback_list_call_attr_2(cbl,type,p1,p2) callback_list_call_attr_args(cbl, type, 2, p1, p2)
00080 #define callback_list_call_attr_3(cbl,type,p1,p2,p3) callback_list_call_attr_args(cbl, type, 3, p1, p2, p3)
00081 #define callback_list_call_attr_4(cbl,type,p1,p2,p3,p4) callback_list_call_attr_args(cbl, type, 4, p1, p2, p3, p4)
00082 
00083 #define callback_cast(x) (void (*)(void))(x)
00084 #ifdef __cplusplus
00085 }
00086 #endif
00087 
00088 #endif
00089