#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
* functions. Hook removal does not change list order.
*/
-#define LTTV_PRIO_DEFAULT 0
+#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 */
/* 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. */
/* Remove a list of hooks from the hooks list in h. */
-void lttv_hooks_remove_data_list(LttvHooks *h, LttvHooks *list);
+void lttv_hooks_remove_list(LttvHooks *h, LttvHooks *list);
/* Return the number of hooks in the list */
/* 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);
/* 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 */