/[zanavi_public1]/navit/navit/callback.h
ZANavi

Contents of /navit/navit/callback.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations) (download)
Wed Aug 22 17:01:27 2012 UTC (7 years, 11 months ago) by zoff99
File MIME type: text/plain
File size: 6210 byte(s)
ZANavi 2.0, lots of changes, everything in its own thread, more performance
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
4 *
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.
8 *
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.
13 *
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.
18 */
19
20 #ifndef NAVIT_CALLBACK_H
21 #define NAVIT_CALLBACK_H
22
23 #include "item.h"
24 #include "attr.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 /* prototypes */
30 enum attr_type;
31
32 struct callback
33 {
34 void (*func)();
35 char func_name[400]; // function name as string (function that will be called)
36 char setup_func_name[400]; // function name as string (function that create the callback)
37 int pcount;
38 enum attr_type type;
39 void *p[0];
40 };
41
42 struct callback_list
43 {
44 GList *list;
45 };
46
47 struct callback_list *callback_list_new(void);
48 struct callback *callback_new_attr(void (*func)(void), enum attr_type type, int pcount, void **p);
49 struct callback *callback_new_attr_args(const char *module, const int mlen,const char *function, void (*func)(void), enum attr_type type, int count, ...);
50 struct callback *callback_new(void (*func)(void), int pcount, void **p);
51 struct callback *callback_new_args(const char *module, const int mlen,const char *function, void (*func)(void), int count, ...);
52 void callback_destroy_real(const char *module, const int mlen,const char *function, struct callback *cb);
53 void callback_set_arg(struct callback *cb, int arg, void *p);
54 void callback_list_add(struct callback_list *l, struct callback *cb);
55 struct callback *callback_list_add_new(struct callback_list *l, void (*func)(void), int pcount, void **p);
56 void callback_add_names(struct callback *cb, const char *parent_name, const char *func_name);
57 void callback_list_remove(struct callback_list *l, struct callback *cb);
58 void callback_list_remove_destroy(struct callback_list *l, struct callback *cb);
59 void callback_call(struct callback *cb, int pcount, void **p);
60 void callback_call_args_real(const char *module, const int mlen,const char *function, struct callback *cb, int count, ...);
61 void callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount, void **p);
62 void callback_list_call_attr_args(const char *module, const int mlen,const char *function, struct callback_list *cbl, enum attr_type type, int count, ...);
63 void callback_list_call(struct callback_list *l, int pcount, void **p);
64 void callback_list_call_args(const char *module, const int mlen,const char *function, struct callback_list *cbl, int count, ...);
65 void callback_list_destroy(struct callback_list *l);
66 /* end of prototypes */
67
68 #define callback_destroy(cb) callback_destroy_real(__FILE__,__LINE__,__PRETTY_FUNCTION__,cb)
69
70 #define callback_call_args(cb, count, ...) callback_call_args_real(__FILE__,__LINE__,__PRETTY_FUNCTION__,cb, count, __VA_ARGS__)
71
72 #define callback_new_0(func) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 0)
73 #define callback_new_1(func,p1) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 1, p1)
74 #define callback_new_2(func,p1,p2) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 2, p1, p2)
75 #define callback_new_3(func,p1,p2,p3) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 3, p1, p2, p3)
76 #define callback_new_4(func,p1,p2,p3,p4) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 4, p1, p2, p3, p4)
77
78 #define callback_new_attr_0(func,type) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 0)
79 #define callback_new_attr_1(func,type,p1) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 1, p1)
80 #define callback_new_attr_2(func,type,p1,p2) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 2, p1, p2)
81 #define callback_new_attr_3(func,type,p1,p2,p3) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 3, p1, p2, p3)
82 #define callback_new_attr_4(func,type,p1,p2,p3,p4) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 4, p1, p2, p3, p4)
83
84 #define callback_call_0(cb) callback_call_args_real(__FILE__,__LINE__,__PRETTY_FUNCTION__,cb, 0)
85 #define callback_call_1(cb,p1) callback_call_args(cb, 1, p1)
86 #define callback_call_2(cb,p1,p2) callback_call_args(cb, 2, p1, p2)
87 #define callback_call_3(cb,p1,p2,p3) callback_call_args(cb, 3, p1, p2, p3)
88 #define callback_call_4(cb,p1,p2,p3,p4) callback_call_args(cb, 4, p1, p2, p3, p4)
89
90 #define callback_list_call_0(cbl) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 0)
91 #define callback_list_call_1(cbl,p1) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 1, p1)
92 #define callback_list_call_2(cbl,p1,p2) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 2, p1, p2)
93 #define callback_list_call_3(cbl,p1,p2,p3) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 3, p1, p2, p3)
94 #define callback_list_call_4(cbl,p1,p2,p3,p4) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 4, p1, p2, p3, p4)
95
96 #define callback_list_call_attr_0(cbl,type) callback_list_call_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl,type, 0)
97 #define callback_list_call_attr_1(cbl,type,p1) callback_list_call_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, type, 1, p1)
98 #define callback_list_call_attr_2(cbl,type,p1,p2) callback_list_call_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, type, 2, p1, p2)
99 #define callback_list_call_attr_3(cbl,type,p1,p2,p3) callback_list_call_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, type, 3, p1, p2, p3)
100 #define callback_list_call_attr_4(cbl,type,p1,p2,p3,p4) callback_list_call_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, type, 4, p1, p2, p3, p4)
101
102 #define callback_cast(x) (void (*)(void))(x)
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif
108

   
Visit the ZANavi Wiki