Hooks by priority
[lttv.git] / ltt / branches / poly / lttv / lttv / hook.h
index 803304c0e3606fa99bb19b272377bc7623a67379..bd68e0966304b2af1ce455fbb8a85d29fc915762 100644 (file)
@@ -1,6 +1,8 @@
 /* This file is part of the Linux Trace Toolkit viewer
  * Copyright (C) 2003-2004 Michel Dagenais
  *
+ * 25/05/2004 Mathieu Desnoyers : Hook priorities
+ *
  * 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;
@@ -32,6 +34,15 @@ typedef gboolean (*LttvHook)(void *hook_data, void *call_data);
 
 typedef GArray LttvHooks;
 
+/* A priority associated with each hook, from -19 (high prio) to 20 (low prio)
+ * 0 being the default priority.
+ *
+ * Priority ordering is done in the lttv_hooks_add and lttv_hooks_add_list 
+ * functions. Hook removal does not change list order.
+ */
+
+#define LTTV_PRIO_DEFAULT 0
+typedef gint LttvHookPrio;
 
 /* Create and destroy a list of hooks */
 
@@ -42,7 +53,7 @@ void lttv_hooks_destroy(LttvHooks *h);
 
 /* Add a hook and its hook data to the list */
 
-void lttv_hooks_add(LttvHooks *h, LttvHook f, void *hook_data);
+void lttv_hooks_add(LttvHooks *h, LttvHook f, void *hook_data, LttvHookPrio p);
 
 
 /* Add a list of hooks to the list h */
@@ -62,7 +73,7 @@ void lttv_hooks_remove_data(LttvHooks *h, LttvHook f, void *hook_data);
 
 /* Remove a list of hooks from the hooks list in h. */
 
-void lttv_hooks_remove_data_list(LttvHooks *h, LttvHook *list);
+void lttv_hooks_remove_data_list(LttvHooks *h, LttvHooks *list);
 
 
 /* Return the number of hooks in the list */
@@ -70,9 +81,11 @@ void lttv_hooks_remove_data_list(LttvHooks *h, LttvHook *list);
 unsigned lttv_hooks_number(LttvHooks *h);
 
 
-/* Return the hook at the specified position in the list */
+/* Return the hook at the specified position in the list.
+ * *f and *hook_data are NULL if no hook exists at that position. */
 
-void lttv_hooks_get(LttvHooks *h, unsigned i, LttvHook *f, void **hook_data);
+void lttv_hooks_get(LttvHooks *h, unsigned i, LttvHook *f, void **hook_data,
+                                              LttvHookPrio *p);
 
 
 /* Remove the specified hook. The position of the following hooks may change */
@@ -81,17 +94,27 @@ void lttv_hooks_remove_by_position(LttvHooks *h, unsigned i);
 
 
 /* Call all the hooks in the list, each with its hook data, 
-   with the specified call data. Return TRUE if one hook returned TRUE. */
+   with the specified call data, in priority order. Return TRUE if one hook
+   returned TRUE. */
 
 gboolean lttv_hooks_call(LttvHooks *h, void *call_data);
 
 
-/* Call the hooks in the list until one returns true, in which case TRUE is
  returned. */
+/* Call the hooks in the list in priority order until one returns true,
* in which case TRUE is returned. */
 
 gboolean lttv_hooks_call_check(LttvHooks *h, void *call_data);
 
 
+/* Call hooks from two lists in priority order. If priority is the same,
+ * hooks from h1 are called first. */
+
+gboolean lttv_hooks_call_merge(LttvHooks *h1, void *call_data1,
+                               LttvHooks *h2, void *call_data2);
+
+gboolean lttv_hooks_call_check_merge(LttvHooks *h1, void *call_data1,
+                                     LttvHooks *h2, void *call_data2);
+
 /* Sometimes different hooks need to be called based on the case. The
    case is represented by an unsigned integer id */
 
This page took 0.024939 seconds and 4 git commands to generate.