Refine the interactions between the hooks provided by the different modules.
[lttv.git] / ltt / branches / poly / include / lttv / module.h
index 5d1c3bae708c80af2f08195f84f4efd016f1eff2..6a0a45fba35fb64f58c76bc77ab2911266d20fb6 100644 (file)
@@ -6,78 +6,64 @@
 /* lttv modules are shared object files, to be loaded dynamically, which
    interact with the main module to provide additional capabilities. They
    typically register hooks to be called at various places, read and add
-   global or trace attributes, and add menu items and tabbed windows to the
-   graphical user interface. Both the hooks lists and the menus and windows
-   are accessed as global attributes. */
+   attributes...
 
+   Each lttv module must define a function named "init" with
+   the following signature. The init function may itself require other
+   modules using lttv_module_require. 
 
-/* Each lttv module must define a function named "init" with
-   the following signature. The init function may itself load pre-requisite 
-   modules using lttv_module_load. 
-
-   It should also define a function named "destroy", which free the
+   It should also define a function named "destroy" to free the
    resources reserved during execution.
 
    Most modules will not use the command line arguments passed as init 
    arguments. It is easier to simply register command line options 
    to be parsed by the main module. However, some modules
-   may require an "early access" to these arguments, for example a embedded
+   may require an "early access" to these arguments, for example an embedded
    python interpreter module which needs to know the modules written in
    python to load. */
 
-/* Initial draft by Michel Dagenais May 2003
- * Reworked by Mathieu Desnoyers, May 2003
- */
+typedef struct _LttvModule LttvModule;
 
-/* index_standalone is the index of the module in the modulesStanalone array.
- * If the module is only loaded "DEPENDANT", index is -1.
- */
+typedef void (*LttvModuleInit)(int argc, char **argv);
 
-typedef struct lttv_module_info_ {
-  GModule *module;
-  char *name;
-  char *directory;
-  char *pathname;
-  guint ref_count;
-  gint index_standalone;
-} lttv_module_info;
+typedef void (*LttvModuleDestroy)();
 
-/* Loading type of modules : 
- * STANDALONE : the program takes care of unloading the moduels
- * DEPENDANT : The module that load this module is required to unload
- *             it in it's destroy function.
- */
 
-typedef enum _loadtype
-{ STANDALONE, DEPENDANT
-} loadtype;
+/* Additional module search paths may be defined. */
 
-typedef void (*lttv_module_load_init)(int argc, char **argv) ;
+void lttv_module_path_add(const char *name);
 
 
-/* Load (if not already loaded) the named module. The init function of the
-   module is executed upon loading. */
+/* Load (or increment its reference count if already loaded) the named module.
+   The init function of the module is executed upon loading. */
 
-lttv_module_info *lttv_module_load(const char *name, int argc, char **argv,loadtype);
+LttvModule *lttv_module_load(const char *name, int argc, char **argv);
 
 
+/* Module m depends on the named module. The named module will be loaded,
+   remembered by m as a dependent, and unloaded when m is unloaded. */
 
-/* Unload (if already loaded) the named module. The destroy function of the
-   module is executed before unloading. */
+LttvModule *lttv_module_require(LttvModule *m, const char *name, int argc,
+    char **argv);
 
-typedef void (*lttv_module_unload_destroy)() ;
 
-int lttv_module_unload_pathname(const char *pathname,loadtype) ;
+/* Decrement the reference count of the specified module and unload it if 0.
+   The destroy function of the module is executed before unloading. 
+   Dependent modules are unloaded. */
 
-int lttv_module_unload_name(const char *name,loadtype) ;
+void lttv_module_unload(LttvModule *m) ;
 
-int lttv_module_unload(lttv_module_info *moduleInfo,loadtype);
 
-/* Unload all the modules */
-void lttv_module_unload_all();
+/* List the loaded modules. The returned array contains nb elements and
+   must be freed with g_free. */
 
-/* Additional module search paths may be defined. */
+LttvModule **lttv_module_list(guint *nb);
 
-void lttv_module_path_add(const char *name);
+
+/* Obtain information about a module. The list of dependent module is
+   returned and must be freed with g_free. */
+
+LttvModule **lttv_module_info(LttvModule *m, const char **name, 
+    guint *ref_count, guint *load_count, guint *nb_dependents);
 
 #endif // MODULES_H
This page took 0.03674 seconds and 4 git commands to generate.