navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
plugin.h
Go to the documentation of this file.
1 
20 #ifndef PLUGIN_C
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 struct plugin;
27 
54 };
55 #endif
56 
57 struct container;
58 struct popup;
59 struct popup_item;
60 #undef PLUGIN_FUNC1
61 #undef PLUGIN_FUNC3
62 #undef PLUGIN_FUNC4
63 #undef PLUGIN_CATEGORY
64 #define PLUGIN_PROTO(name,...) void name(__VA_ARGS__)
65 
66 #ifdef PLUGIN_C
67 #define PLUGIN_REGISTER(name,...) \
68 void \
69 plugin_register_##name(PLUGIN_PROTO((*func),__VA_ARGS__)) \
70 { \
71  plugin_##name##_func=func; \
72 }
73 
74 #define PLUGIN_CALL(name,...) \
75 { \
76  if (plugin_##name##_func) \
77  (*plugin_##name##_func)(__VA_ARGS__); \
78 }
79 
80 #define PLUGIN_FUNC1(name,t1,p1) \
81 PLUGIN_PROTO((*plugin_##name##_func),t1 p1); \
82 void plugin_call_##name(t1 p1) PLUGIN_CALL(name,p1) \
83 PLUGIN_REGISTER(name,t1 p1)
84 
85 #define PLUGIN_FUNC3(name,t1,p1,t2,p2,t3,p3) \
86 PLUGIN_PROTO((*plugin_##name##_func),t1 p1,t2 p2,t3 p3); \
87 void plugin_call_##name(t1 p1,t2 p2, t3 p3) PLUGIN_CALL(name,p1,p2,p3) \
88 PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3)
89 
90 #define PLUGIN_FUNC4(name,t1,p1,t2,p2,t3,p3,t4,p4) \
91 PLUGIN_PROTO((*plugin_##name##_func),t1 p1,t2 p2,t3 p3,t4 p4); \
92 void plugin_call_##name(t1 p1,t2 p2, t3 p3, t4 p4) PLUGIN_CALL(name,p1,p2,p3,p4) \
93 PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3,t4 p4)
94 
95 struct name_val {
96  char *name;
97  void *val;
98 };
99 
100 GList *plugin_categories[plugin_category_last];
101 
102 #define PLUGIN_CATEGORY(category,newargs) \
103 struct category##_priv; \
104 struct category##_methods; \
105 void \
106 plugin_register_category_##category(const char *name, struct category##_priv *(*new_) newargs) \
107 { \
108  struct name_val *nv; \
109  nv=g_new(struct name_val, 1); \
110  nv->name=g_strdup(name); \
111  nv->val=new_; \
112  plugin_categories[plugin_category_##category]=g_list_append(plugin_categories[plugin_category_##category], nv); \
113 } \
114  \
115 void * \
116 plugin_get_category_##category(const char *name) \
117 { \
118  return plugin_get_category(plugin_category_##category, #category, name); \
119 }
120 
121 #else
122 #define PLUGIN_FUNC1(name,t1,p1) \
123 void plugin_register_##name(void(*func)(t1 p1)); \
124 void plugin_call_##name(t1 p1);
125 
126 #define PLUGIN_FUNC3(name,t1,p1,t2,p2,t3,p3) \
127 void plugin_register_##name(void(*func)(t1 p1,t2 p2,t3 p3)); \
128 void plugin_call_##name(t1 p1,t2 p2,t3 p3);
129 
130 #define PLUGIN_FUNC4(name,t1,p1,t2,p2,t3,p3,t4,p4) \
131 void plugin_register_##name(void(*func)(t1 p1,t2 p2,t3 p3,t4 p4)); \
132 void plugin_call_##name(t1 p1,t2 p2,t3 p3,t4 p4);
133 
134 #define PLUGIN_CATEGORY(category,newargs) \
135 struct category##_priv; \
136 struct category##_methods; \
137 void plugin_register_category_##category(const char *name, struct category##_priv *(*new_) newargs); \
138 void *plugin_get_category_##category(const char *name);
139 
140 #endif
141 
142 #include "plugin_def.h"
143 
144 #ifndef USE_PLUGINS
145 #define plugin_module_cat3(pre,mod,post) pre##mod##post
146 #define plugin_module_cat2(pre,mod,post) plugin_module_cat3(pre,mod,post)
147 #define plugin_module_cat(pre,post) plugin_module_cat2(pre,MODULE,post)
148 #define plugin_init plugin_module_cat(module_,_init)
149 #endif
150 
151 struct attr;
152 
153 /* prototypes */
154 void plugin_init(void);
155 int plugin_load(struct plugin *pl);
156 char *plugin_get_name(struct plugin *pl);
157 int plugin_get_active(struct plugin *pl);
158 void plugin_set_active(struct plugin *pl, int active);
159 void plugin_set_lazy(struct plugin *pl, int lazy);
160 void plugin_call_init(struct plugin *pl);
161 void plugin_unload(struct plugin *pl);
162 void plugin_destroy(struct plugin *pl);
163 struct plugins *plugins_new(void);
164 struct plugin *plugin_new(struct attr *parent, struct attr ** attrs);
165 void plugins_init(struct plugins *pls);
166 void plugins_destroy(struct plugins *pls);
167 void *plugin_get_category(enum plugin_category category, const char *category_name, const char *name);
168 /* end of prototypes */
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 
Definition: plugin.h:41
struct attr active
Definition: speech.c:82
void plugin_set_active(struct plugin *pl, int active)
Definition: plugin.c:216
#define plugin_init
Definition: plugin.h:148
Definition: plugin.h:37
Definition: gpx2navit_txt.h:51
Definition: plugin.h:47
struct plugin * plugin_new(struct attr *parent, struct attr **attrs)
Definition: plugin.c:272
plugin_category
All existing plugin categories.
Definition: plugin.h:35
struct plugins * pls
Definition: plugin.h:45
void plugin_unload(struct plugin *pl)
Definition: plugin.c:248
Definition: plugin.h:53
Definition: plugin.c:139
void plugins_init(struct plugins *pls)
Definition: plugin.c:345
int plugin_load(struct plugin *pl)
Definition: plugin.c:172
Definition: plugin.h:49
Definition: plugin.c:150
void * plugin_get_category(enum plugin_category category, const char *category_name, const char *name)
Definition: plugin.c:401
void plugin_set_lazy(struct plugin *pl, int lazy)
Definition: plugin.c:222
Definition: plugin.h:51
Definition: attr.h:156
Definition: plugin.h:39
struct plugins * plugins_new(void)
Definition: plugin.c:263
Definition: plugin.h:43
char name[0]
Definition: street.c:559
int plugin_get_active(struct plugin *pl)
Definition: plugin.c:210
void plugins_destroy(struct plugins *pls)
Definition: plugin.c:371
char * plugin_get_name(struct plugin *pl)
Definition: plugin.c:204
void plugin_call_init(struct plugin *pl)
Definition: plugin.c:242
void plugin_destroy(struct plugin *pl)
Definition: plugin.c:257