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 created the callback)
|
37 |
int pcount;
|
38 |
enum attr_type type;
|
39 |
void *p[0];
|
40 |
};
|
41 |
|
42 |
struct callback_list
|
43 |
{
|
44 |
char cb_name[400]; // callbacklist "function:name"
|
45 |
GList *list;
|
46 |
};
|
47 |
|
48 |
void callback_dump_callbacks();
|
49 |
struct callback_list *callback_list_new(char *name);
|
50 |
struct callback *callback_new_attr(void (*func)(void), enum attr_type type, int pcount, void **p);
|
51 |
struct callback *callback_new_attr_args(const char *module, const int mlen,const char *function, void (*func)(void), enum attr_type type, int count, ...);
|
52 |
struct callback *callback_new(void (*func)(void), int pcount, void **p);
|
53 |
struct callback *callback_new_args(const char *module, const int mlen,const char *function, void (*func)(void), int count, ...);
|
54 |
void callback_destroy_real(const char *module, const int mlen,const char *function, struct callback *cb);
|
55 |
void callback_set_arg(struct callback *cb, int arg, void *p);
|
56 |
// void callback_list_add(struct callback_list *l, struct callback *cb);
|
57 |
void callback_list_add_2(const char *module, const int mlen,const char *function, struct callback_list *l, struct callback *cb);
|
58 |
struct callback *callback_list_add_new(struct callback_list *l, void (*func)(void), int pcount, void **p);
|
59 |
void callback_add_names(struct callback *cb, const char *parent_name, const char *func_name);
|
60 |
// void callback_list_remove(struct callback_list *l, struct callback *cb);
|
61 |
void callback_list_remove_2(const char *module, const int mlen,const char *function, struct callback_list *l, struct callback *cb);
|
62 |
void callback_list_remove_destroy(struct callback_list *l, struct callback *cb);
|
63 |
void callback_call(struct callback *cb, int pcount, void **p);
|
64 |
void callback_call_args_real(const char *module, const int mlen,const char *function, struct callback *cb, int count, ...);
|
65 |
void callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount, void **p);
|
66 |
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, ...);
|
67 |
void callback_list_call(struct callback_list *l, int pcount, void **p);
|
68 |
void callback_list_call_args(const char *module, const int mlen,const char *function, struct callback_list *cbl, int count, ...);
|
69 |
void callback_list_destroy(struct callback_list *l);
|
70 |
/* end of prototypes */
|
71 |
|
72 |
#define callback_destroy(cb) callback_destroy_real(__FILE__,__LINE__,__PRETTY_FUNCTION__,cb)
|
73 |
|
74 |
#define callback_call_args(cb, count, ...) callback_call_args_real(__FILE__,__LINE__,__PRETTY_FUNCTION__,cb, count, __VA_ARGS__)
|
75 |
|
76 |
#define callback_list_add(l, cb) callback_list_add_2(__FILE__,__LINE__,__PRETTY_FUNCTION__,l,cb)
|
77 |
#define callback_list_remove(l, cb) callback_list_remove_2(__FILE__,__LINE__,__PRETTY_FUNCTION__,l,cb)
|
78 |
|
79 |
|
80 |
#define callback_new_0(func) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 0)
|
81 |
#define callback_new_1(func,p1) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 1, p1)
|
82 |
#define callback_new_2(func,p1,p2) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 2, p1, p2)
|
83 |
#define callback_new_3(func,p1,p2,p3) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 3, p1, p2, p3)
|
84 |
#define callback_new_4(func,p1,p2,p3,p4) callback_new_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, 4, p1, p2, p3, p4)
|
85 |
|
86 |
#define callback_new_attr_0(func,type) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 0)
|
87 |
#define callback_new_attr_1(func,type,p1) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 1, p1)
|
88 |
#define callback_new_attr_2(func,type,p1,p2) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 2, p1, p2)
|
89 |
#define callback_new_attr_3(func,type,p1,p2,p3) callback_new_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,func, type, 3, p1, p2, p3)
|
90 |
#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)
|
91 |
|
92 |
#define callback_call_0(cb) callback_call_args_real(__FILE__,__LINE__,__PRETTY_FUNCTION__,cb, 0)
|
93 |
#define callback_call_1(cb,p1) callback_call_args(cb, 1, p1)
|
94 |
#define callback_call_2(cb,p1,p2) callback_call_args(cb, 2, p1, p2)
|
95 |
#define callback_call_3(cb,p1,p2,p3) callback_call_args(cb, 3, p1, p2, p3)
|
96 |
#define callback_call_4(cb,p1,p2,p3,p4) callback_call_args(cb, 4, p1, p2, p3, p4)
|
97 |
|
98 |
#define callback_list_call_0(cbl) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 0)
|
99 |
#define callback_list_call_1(cbl,p1) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 1, p1)
|
100 |
#define callback_list_call_2(cbl,p1,p2) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 2, p1, p2)
|
101 |
#define callback_list_call_3(cbl,p1,p2,p3) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 3, p1, p2, p3)
|
102 |
#define callback_list_call_4(cbl,p1,p2,p3,p4) callback_list_call_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, 4, p1, p2, p3, p4)
|
103 |
|
104 |
#define callback_list_call_attr_0(cbl,type) callback_list_call_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl,type, 0)
|
105 |
#define callback_list_call_attr_1(cbl,type,p1) callback_list_call_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, type, 1, p1)
|
106 |
#define callback_list_call_attr_2(cbl,type,p1,p2) callback_list_call_attr_args(__FILE__,__LINE__,__PRETTY_FUNCTION__,cbl, type, 2, p1, p2)
|
107 |
#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)
|
108 |
#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)
|
109 |
|
110 |
#define callback_cast(x) (void (*)(void))(x)
|
111 |
#ifdef __cplusplus
|
112 |
}
|
113 |
#endif
|
114 |
|
115 |
#endif
|
116 |
|