warning fixed for lttvwindow and controlflow view
[lttv.git] / ltt / branches / poly / lttv / lttv / hook.h
index 803304c0e3606fa99bb19b272377bc7623a67379..1227203514dd20a18d51cffded051b56fcb73bcd 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;
@@ -20,6 +22,7 @@
 #define HOOK_H
 
 #include <glib.h>
+#include <ltt/compiler.h>
 
 /* A hook is a function to call with the supplied hook data, and with 
    call site specific data (e.g., hooks for events are called with a 
@@ -32,6 +35,18 @@ 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 50
+#define LTTV_PRIO_HIGH 0
+#define LTTV_PRIO_LOW 99
+
+typedef gint LttvHookPrio;
 
 /* Create and destroy a list of hooks */
 
@@ -42,12 +57,12 @@ 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 */
 
-void lttv_hooks_add_list(LttvHooks *h, LttvHooks *list);
+void lttv_hooks_add_list(LttvHooks *h, const LttvHooks *list);
 
 
 /* Remove a hook from the list. Return the hook data. */
@@ -62,7 +77,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_list(LttvHooks *h, LttvHooks *list);
 
 
 /* Return the number of hooks in the list */
@@ -70,28 +85,41 @@ 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 */
+/* The hook is removed from the list event if its ref_count is higher than 1 */
 
 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 */
 
@@ -117,7 +145,14 @@ unsigned lttv_hooks_by_id_max_id(LttvHooksById *h);
 
 /* Get the list of hooks for an id, NULL if none exists */
 
-LttvHooks *lttv_hooks_by_id_get(LttvHooksById *h, unsigned id);
+static inline LttvHooks *lttv_hooks_by_id_get(LttvHooksById *h, unsigned id)
+{
+  LttvHooks *ret;
+  if(likely(id < h->len)) ret = h->pdata[id];
+  else ret = NULL;
+
+  return ret;
+}
 
 
 /* Remove the list of hooks associated with an id */
This page took 0.024464 seconds and 4 git commands to generate.