1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 /* A hook is a function to call with the supplied hook data, and with
25 call site specific data (e.g., hooks for events are called with a
26 pointer to the current event). */
28 typedef gboolean (*LttvHook
)(void *hook_data
, void *call_data
);
31 /* A list of hooks allows registering hooks to be called later. */
33 typedef GArray LttvHooks
;
36 /* Create and destroy a list of hooks */
38 LttvHooks
*lttv_hooks_new();
40 void lttv_hooks_destroy(LttvHooks
*h
);
43 /* Add a hook and its hook data to the list */
45 void lttv_hooks_add(LttvHooks
*h
, LttvHook f
, void *hook_data
);
48 /* Add a list of hooks to the list h */
50 void lttv_hooks_add_list(LttvHooks
*h
, LttvHooks
*list
);
53 /* Remove a hook from the list. Return the hook data. */
55 void *lttv_hooks_remove(LttvHooks
*h
, LttvHook f
);
58 /* Remove a hook from the list checking that the hook data match. */
60 void lttv_hooks_remove_data(LttvHooks
*h
, LttvHook f
, void *hook_data
);
63 /* Remove a list of hooks from the hooks list in h. */
65 void lttv_hooks_remove_data_list(LttvHooks
*h
, LttvHook
*list
);
68 /* Return the number of hooks in the list */
70 unsigned lttv_hooks_number(LttvHooks
*h
);
73 /* Return the hook at the specified position in the list */
75 void lttv_hooks_get(LttvHooks
*h
, unsigned i
, LttvHook
*f
, void **hook_data
);
78 /* Remove the specified hook. The position of the following hooks may change */
80 void lttv_hooks_remove_by_position(LttvHooks
*h
, unsigned i
);
83 /* Call all the hooks in the list, each with its hook data,
84 with the specified call data. Return TRUE if one hook returned TRUE. */
86 gboolean
lttv_hooks_call(LttvHooks
*h
, void *call_data
);
89 /* Call the hooks in the list until one returns true, in which case TRUE is
92 gboolean
lttv_hooks_call_check(LttvHooks
*h
, void *call_data
);
95 /* Sometimes different hooks need to be called based on the case. The
96 case is represented by an unsigned integer id */
98 typedef GPtrArray LttvHooksById
;
101 /* Create and destroy a hooks by id list */
103 LttvHooksById
*lttv_hooks_by_id_new();
105 void lttv_hooks_by_id_destroy(LttvHooksById
*h
);
108 /* Obtain the hooks for a given id, creating a list if needed */
110 LttvHooks
*lttv_hooks_by_id_find(LttvHooksById
*h
, unsigned id
);
113 /* Return an id larger than any for which a list exists. */
115 unsigned lttv_hooks_by_id_max_id(LttvHooksById
*h
);
118 /* Get the list of hooks for an id, NULL if none exists */
120 LttvHooks
*lttv_hooks_by_id_get(LttvHooksById
*h
, unsigned id
);
123 /* Remove the list of hooks associated with an id */
125 void lttv_hooks_by_id_remove(LttvHooksById
*h
, unsigned id
);
This page took 0.03086 seconds and 4 git commands to generate.