2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef NAVIT_CALLBACK_H
21 #define NAVIT_CALLBACK_H
33 struct callback_list *callback_list_new(void);
34 struct callback *callback_new_attr(void (*func)(void), enum attr_type type, int pcount, void **p);
35 struct callback *callback_new(void (*func)(void), int pcount, void **p);
36 void callback_destroy(struct callback *cb);
37 void callback_set_arg(struct callback *cb, int arg, void *p);
38 void callback_list_add(struct callback_list *l, struct callback *cb);
39 struct callback *callback_list_add_new(struct callback_list *l, void (*func)(void), int pcount, void **p);
40 void callback_list_remove(struct callback_list *l, struct callback *cb);
41 void callback_list_remove_destroy(struct callback_list *l, struct callback *cb);
42 void callback_call(struct callback *cb, int pcount, void **p);
43 void callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount, void **p);
44 void callback_list_call(struct callback_list *l, int pcount, void **p);
45 void callback_list_destroy(struct callback_list *l);
46 /* end of prototypes */
48 static inline struct callback *callback_new_attr_0(void (*func)(void), enum attr_type type)
50 return callback_new_attr(func, type, 0, NULL);
53 static inline struct callback *callback_new_0(void (*func)(void))
55 return callback_new(func, 0, NULL);
58 static inline struct callback *callback_new_attr_1(void (*func)(void), enum attr_type type, void *p1)
62 return callback_new_attr(func, type, 1, p);
65 static inline struct callback *callback_new_1(void (*func)(void), void *p1)
69 return callback_new(func, 1, p);
72 static inline struct callback *callback_new_attr_2(void (*func)(void), enum attr_type type, void *p1, void *p2)
77 return callback_new_attr(func, type, 2, p);
80 static inline struct callback *callback_new_2(void (*func)(void), void *p1, void *p2)
85 return callback_new(func, 2, p);
88 static inline struct callback *callback_new_3(void (*func)(void), void *p1, void *p2, void *p3)
94 return callback_new(func, 3, p);
97 static inline void callback_call_0(struct callback *cb)
99 callback_call(cb, 0, NULL);
102 static inline void callback_call_1(struct callback *cb, void *p1)
106 callback_call(cb, 1, p);
109 static inline void callback_list_call_0(struct callback_list *l)
111 callback_list_call(l, 0, NULL);
114 static inline void callback_list_call_attr_0(struct callback_list *l, enum attr_type type)
116 callback_list_call_attr(l, type, 0, NULL);
119 static inline void callback_list_call_attr_1(struct callback_list *l, enum attr_type type, void *p1)
123 callback_list_call_attr(l, type, 1, p);
126 static inline void callback_list_call_1(struct callback_list *l, void *p1)
130 callback_list_call(l, 1, p);
133 static inline void callback_list_call_attr_2(struct callback_list *l, enum attr_type type, void *p1, void *p2)
138 callback_list_call_attr(l, type, 2, p);
141 static inline void callback_list_call_2(struct callback_list *l, void *p1, void *p2)
146 callback_list_call(l, 2, p);
149 static inline void callback_list_call_attr_3(struct callback_list *l, enum attr_type type, void *p1, void *p2, void *p3)
155 callback_list_call_attr(l, type, 3, p);
158 static inline void callback_list_call_attr_4(struct callback_list *l, enum attr_type type, void *p1, void *p2, void *p3, void *p4)
165 callback_list_call_attr(l, type, 4, p);
169 #define callback_cast(x) (void (*)(void))(x)