Refine the interactions between the hooks provided by the different modules.
[lttv.git] / ltt / branches / poly / include / lttv / module.h
1 #ifndef MODULES_H
2 #define MODULES_H
3
4 #include <gmodule.h>
5
6 /* lttv modules are shared object files, to be loaded dynamically, which
7 interact with the main module to provide additional capabilities. They
8 typically register hooks to be called at various places, read and add
9 attributes...
10
11 Each lttv module must define a function named "init" with
12 the following signature. The init function may itself require other
13 modules using lttv_module_require.
14
15 It should also define a function named "destroy" to free the
16 resources reserved during execution.
17
18 Most modules will not use the command line arguments passed as init
19 arguments. It is easier to simply register command line options
20 to be parsed by the main module. However, some modules
21 may require an "early access" to these arguments, for example an embedded
22 python interpreter module which needs to know the modules written in
23 python to load. */
24
25 typedef struct _LttvModule LttvModule;
26
27 typedef void (*LttvModuleInit)(int argc, char **argv);
28
29 typedef void (*LttvModuleDestroy)();
30
31
32 /* Additional module search paths may be defined. */
33
34 void lttv_module_path_add(const char *name);
35
36
37 /* Load (or increment its reference count if already loaded) the named module.
38 The init function of the module is executed upon loading. */
39
40 LttvModule *lttv_module_load(const char *name, int argc, char **argv);
41
42
43 /* Module m depends on the named module. The named module will be loaded,
44 remembered by m as a dependent, and unloaded when m is unloaded. */
45
46 LttvModule *lttv_module_require(LttvModule *m, const char *name, int argc,
47 char **argv);
48
49
50 /* Decrement the reference count of the specified module and unload it if 0.
51 The destroy function of the module is executed before unloading.
52 Dependent modules are unloaded. */
53
54 void lttv_module_unload(LttvModule *m) ;
55
56
57 /* List the loaded modules. The returned array contains nb elements and
58 must be freed with g_free. */
59
60 LttvModule **lttv_module_list(guint *nb);
61
62
63 /* Obtain information about a module. The list of dependent module is
64 returned and must be freed with g_free. */
65
66 LttvModule **lttv_module_info(LttvModule *m, const char **name,
67 guint *ref_count, guint *load_count, guint *nb_dependents);
68
69 #endif // MODULES_H
This page took 0.040136 seconds and 4 git commands to generate.