minor add
[lttv.git] / ltt / branches / poly / lttv / lttv / hook.h
... / ...
CommitLineData
1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
19#ifndef HOOK_H
20#define HOOK_H
21
22#include <glib.h>
23
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). */
27
28typedef gboolean (*LttvHook)(void *hook_data, void *call_data);
29
30
31/* A list of hooks allows registering hooks to be called later. */
32
33typedef GArray LttvHooks;
34
35
36/* Create and destroy a list of hooks */
37
38LttvHooks *lttv_hooks_new();
39
40void lttv_hooks_destroy(LttvHooks *h);
41
42
43/* Add a hook and its hook data to the list */
44
45void lttv_hooks_add(LttvHooks *h, LttvHook f, void *hook_data);
46
47
48/* Add a list of hooks to the list h */
49
50void lttv_hooks_add_list(LttvHooks *h, LttvHooks *list);
51
52
53/* Remove a hook from the list. Return the hook data. */
54
55void *lttv_hooks_remove(LttvHooks *h, LttvHook f);
56
57
58/* Remove a hook from the list checking that the hook data match. */
59
60void lttv_hooks_remove_data(LttvHooks *h, LttvHook f, void *hook_data);
61
62
63/* Remove a list of hooks from the hooks list in h. */
64
65void lttv_hooks_remove_data_list(LttvHooks *h, LttvHook *list);
66
67
68/* Return the number of hooks in the list */
69
70unsigned lttv_hooks_number(LttvHooks *h);
71
72
73/* Return the hook at the specified position in the list */
74
75void lttv_hooks_get(LttvHooks *h, unsigned i, LttvHook *f, void **hook_data);
76
77
78/* Remove the specified hook. The position of the following hooks may change */
79
80void lttv_hooks_remove_by_position(LttvHooks *h, unsigned i);
81
82
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. */
85
86gboolean lttv_hooks_call(LttvHooks *h, void *call_data);
87
88
89/* Call the hooks in the list until one returns true, in which case TRUE is
90 returned. */
91
92gboolean lttv_hooks_call_check(LttvHooks *h, void *call_data);
93
94
95/* Sometimes different hooks need to be called based on the case. The
96 case is represented by an unsigned integer id */
97
98typedef GPtrArray LttvHooksById;
99
100
101/* Create and destroy a hooks by id list */
102
103LttvHooksById *lttv_hooks_by_id_new();
104
105void lttv_hooks_by_id_destroy(LttvHooksById *h);
106
107
108/* Obtain the hooks for a given id, creating a list if needed */
109
110LttvHooks *lttv_hooks_by_id_find(LttvHooksById *h, unsigned id);
111
112
113/* Return an id larger than any for which a list exists. */
114
115unsigned lttv_hooks_by_id_max_id(LttvHooksById *h);
116
117
118/* Get the list of hooks for an id, NULL if none exists */
119
120LttvHooks *lttv_hooks_by_id_get(LttvHooksById *h, unsigned id);
121
122
123/* Remove the list of hooks associated with an id */
124
125void lttv_hooks_by_id_remove(LttvHooksById *h, unsigned id);
126
127#endif // HOOK_H
This page took 0.021803 seconds and 4 git commands to generate.