multiple traces/tracefiles change
[lttv.git] / ltt / branches / poly / include / lttv / module.h
index 5d1c3bae708c80af2f08195f84f4efd016f1eff2..39319151f8184bc5fbd0ddc745d96ade65a8db46 100644 (file)
@@ -1,3 +1,21 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Michel Dagenais
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 
+ * MA 02111-1307, USA.
+ */
+
 #ifndef MODULES_H
 #define MODULES_H
 
 /* 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)(LttvModule *self, 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;
-
-/* 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 void (*LttvModuleDestroy)();
 
-typedef enum _loadtype
-{ STANDALONE, DEPENDANT
-} loadtype;
 
-typedef void (*lttv_module_load_init)(int argc, char **argv) ;
+/* Additional module search paths may be defined. */
 
+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. */
 
-lttv_module_info *lttv_module_load(const char *name, int argc, char **argv,loadtype);
+/* Load (or increment its reference count if already loaded) the named module.
+   The init function of the module is executed upon loading. */
 
+LttvModule *lttv_module_load(const char *name, int argc, char **argv);
 
 
-/* Unload (if already loaded) the named module. The destroy function of the
-   module is executed before unloading. */
+/* 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. */
 
-typedef void (*lttv_module_unload_destroy)() ;
+LttvModule *lttv_module_require(LttvModule *m, const char *name, int argc,
+    char **argv);
 
-int lttv_module_unload_pathname(const char *pathname,loadtype) ;
 
-int lttv_module_unload_name(const char *name,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(lttv_module_info *moduleInfo,loadtype);
+void lttv_module_unload(LttvModule *m) ;
 
-/* Unload all the modules */
-void lttv_module_unload_all();
 
-/* Additional module search paths may be defined. */
+/* List the loaded modules. The returned array contains nb elements and
+   must be freed with g_free. */
 
-void lttv_module_path_add(const char *name);
+LttvModule **lttv_module_list(guint *nb);
+
+
+/* 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);
 
+char * lttv_module_name(LttvModule *m);
 #endif // MODULES_H
This page took 0.035845 seconds and 4 git commands to generate.