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.
48 #define PLUGIN_PROTO(name,...) void name(__VA_ARGS__)
51 #define PLUGIN_REGISTER(name,...) \
53 plugin_register_##name(PLUGIN_PROTO((*func),__VA_ARGS__)) \
55 plugin_##name##_func=func; \
58 #define PLUGIN_CALL(name,...) \
60 if (plugin_##name##_func) \
61 (*plugin_##name##_func)(__VA_ARGS__); \
64 #define PLUGIN_FUNC1(name,t1,p1) \
65 PLUGIN_PROTO((*plugin_##name##_func),t1 p1); \
66 void plugin_call_##name(t1 p1) PLUGIN_CALL(name,p1) \
67 PLUGIN_REGISTER(name,t1 p1)
69 #define PLUGIN_FUNC3(name,t1,p1,t2,p2,t3,p3) \
70 PLUGIN_PROTO((*plugin_##name##_func),t1 p1,t2 p2,t3 p3); \
71 void plugin_call_##name(t1 p1,t2 p2, t3 p3) PLUGIN_CALL(name,p1,p2,p3) \
72 PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3)
74 #define PLUGIN_FUNC4(name,t1,p1,t2,p2,t3,p3,t4,p4) \
75 PLUGIN_PROTO((*plugin_##name##_func),t1 p1,t2 p2,t3 p3,t4 p4); \
76 void plugin_call_##name(t1 p1,t2 p2, t3 p3, t4 p4) PLUGIN_CALL(name,p1,p2,p3,p4) \
77 PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3,t4 p4)
84 GList *plugin_types[plugin_type_last];
86 #define PLUGIN_TYPE(type,newargs) \
88 struct type##_methods; \
90 plugin_register_##type##_type(const char *name, struct type##_priv *(*new_) newargs) \
92 struct name_val *nv; \
93 nv=g_new(struct name_val, 1); \
94 nv->name=g_strdup(name); \
96 plugin_types[plugin_type_##type]=g_list_append(plugin_types[plugin_type_##type], nv); \
100 plugin_get_##type##_type(const char *name) \
102 return plugin_get_type(plugin_type_##type, #type, name); \
106 #define PLUGIN_FUNC1(name,t1,p1) \
107 void plugin_register_##name(void(*func)(t1 p1)); \
108 void plugin_call_##name(t1 p1);
110 #define PLUGIN_FUNC3(name,t1,p1,t2,p2,t3,p3) \
111 void plugin_register_##name(void(*func)(t1 p1,t2 p2,t3 p3)); \
112 void plugin_call_##name(t1 p1,t2 p2,t3 p3);
114 #define PLUGIN_FUNC4(name,t1,p1,t2,p2,t3,p3,t4,p4) \
115 void plugin_register_##name(void(*func)(t1 p1,t2 p2,t3 p3,t4 p4)); \
116 void plugin_call_##name(t1 p1,t2 p2,t3 p3,t4 p4);
118 #define PLUGIN_TYPE(type,newargs) \
119 struct type##_priv; \
120 struct type##_methods; \
121 void plugin_register_##type##_type(const char *name, struct type##_priv *(*new_) newargs); \
122 void *plugin_get_##type##_type(const char *name);
126 #include "plugin_def.h"
129 #define plugin_module_cat3(pre,mod,post) pre##mod##post
130 #define plugin_module_cat2(pre,mod,post) plugin_module_cat3(pre,mod,post)
131 #define plugin_module_cat(pre,post) plugin_module_cat2(pre,MODULE,post)
132 #define plugin_init plugin_module_cat(module_,_init)
138 void plugin_init(void);
139 int plugin_load(struct plugin *pl);
140 char *plugin_get_name(struct plugin *pl);
141 int plugin_get_active(struct plugin *pl);
142 void plugin_set_active(struct plugin *pl, int active);
143 void plugin_set_lazy(struct plugin *pl, int lazy);
144 void plugin_call_init(struct plugin *pl);
145 void plugin_unload(struct plugin *pl);
146 void plugin_destroy(struct plugin *pl);
147 struct plugins *plugins_new(void);
148 struct plugin *plugin_new(struct attr *parent, struct attr ** attrs);
149 void plugins_init(struct plugins *pls);
150 void plugins_destroy(struct plugins *pls);
151 void *plugin_get_type(enum plugin_type type, const char *type_name, const char *name);
152 /* end of prototypes */