epoc32/include/stdapis/glib-2.0/glib/ghook.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/* GLIB - Library of useful routines for C programming
williamr@2
     2
 * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
williamr@2
     3
 * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
williamr@2
     4
 *
williamr@2
     5
 * This library is free software; you can redistribute it and/or
williamr@2
     6
 * modify it under the terms of the GNU Lesser General Public
williamr@2
     7
 * License as published by the Free Software Foundation; either
williamr@2
     8
 * version 2 of the License, or (at your option) any later version.
williamr@2
     9
 *
williamr@2
    10
 * This library is distributed in the hope that it will be useful,
williamr@2
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
williamr@2
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
williamr@2
    13
 * Lesser General Public License for more details.
williamr@2
    14
 *
williamr@2
    15
 * You should have received a copy of the GNU Lesser General Public
williamr@2
    16
 * License along with this library; if not, write to the
williamr@2
    17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
williamr@2
    18
 * Boston, MA 02111-1307, USA.
williamr@2
    19
 */
williamr@2
    20
williamr@2
    21
/*
williamr@2
    22
 * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
williamr@2
    23
 * file for a list of people on the GLib Team.  See the ChangeLog
williamr@2
    24
 * files for a list of changes.  These files are distributed with
williamr@2
    25
 * GLib at ftp://ftp.gtk.org/pub/gtk/. 
williamr@2
    26
 */
williamr@2
    27
williamr@2
    28
#ifndef __G_HOOK_H__
williamr@2
    29
#define __G_HOOK_H__
williamr@2
    30
williamr@2
    31
#include <_ansi.h>
williamr@2
    32
#include <glib/gmem.h>
williamr@2
    33
williamr@2
    34
G_BEGIN_DECLS
williamr@2
    35
williamr@2
    36
williamr@2
    37
/* --- typedefs --- */
williamr@2
    38
typedef struct _GHook		GHook;
williamr@2
    39
typedef struct _GHookList	GHookList;
williamr@2
    40
williamr@2
    41
typedef gint		(*GHookCompareFunc)	(GHook		*new_hook,
williamr@2
    42
						 GHook		*sibling);
williamr@2
    43
typedef gboolean	(*GHookFindFunc)	(GHook		*hook,
williamr@2
    44
						 gpointer	 data);
williamr@2
    45
typedef void		(*GHookMarshaller)	(GHook		*hook,
williamr@2
    46
						 gpointer	 marshal_data);
williamr@2
    47
typedef gboolean	(*GHookCheckMarshaller)	(GHook		*hook,
williamr@2
    48
						 gpointer	 marshal_data);
williamr@2
    49
typedef void		(*GHookFunc)		(gpointer	 data);
williamr@2
    50
typedef gboolean	(*GHookCheckFunc)	(gpointer	 data);
williamr@2
    51
typedef void		(*GHookFinalizeFunc)	(GHookList      *hook_list,
williamr@2
    52
						 GHook          *hook);
williamr@2
    53
typedef enum
williamr@2
    54
{
williamr@2
    55
  G_HOOK_FLAG_ACTIVE	    = 1 << 0,
williamr@2
    56
  G_HOOK_FLAG_IN_CALL	    = 1 << 1,
williamr@2
    57
  G_HOOK_FLAG_MASK	    = 0x0f
williamr@2
    58
} GHookFlagMask;
williamr@2
    59
#define G_HOOK_FLAG_USER_SHIFT	(4)
williamr@2
    60
williamr@2
    61
williamr@2
    62
/* --- structures --- */
williamr@2
    63
struct _GHookList
williamr@2
    64
{
williamr@2
    65
  gulong	    seq_id;
williamr@2
    66
  guint		    hook_size : 16;
williamr@2
    67
  guint		    is_setup : 1;
williamr@2
    68
  GHook		   *hooks;
williamr@2
    69
  gpointer	    dummy3;
williamr@2
    70
  GHookFinalizeFunc finalize_hook;
williamr@2
    71
  gpointer	    dummy[2];
williamr@2
    72
};
williamr@2
    73
struct _GHook
williamr@2
    74
{
williamr@2
    75
  gpointer	 data;
williamr@2
    76
  GHook		*next;
williamr@2
    77
  GHook		*prev;
williamr@2
    78
  guint		 ref_count;
williamr@2
    79
  gulong	 hook_id;
williamr@2
    80
  guint		 flags;
williamr@2
    81
  gpointer	 func;
williamr@2
    82
  GDestroyNotify destroy;
williamr@2
    83
};
williamr@2
    84
williamr@2
    85
williamr@2
    86
/* --- macros --- */
williamr@2
    87
#define	G_HOOK(hook)			((GHook*) (hook))
williamr@2
    88
#define	G_HOOK_FLAGS(hook)		(G_HOOK (hook)->flags)
williamr@2
    89
#define	G_HOOK_ACTIVE(hook)		((G_HOOK_FLAGS (hook) & \
williamr@2
    90
					  G_HOOK_FLAG_ACTIVE) != 0)
williamr@2
    91
#define	G_HOOK_IN_CALL(hook)		((G_HOOK_FLAGS (hook) & \
williamr@2
    92
					  G_HOOK_FLAG_IN_CALL) != 0)
williamr@2
    93
#define G_HOOK_IS_VALID(hook)		(G_HOOK (hook)->hook_id != 0 && \
williamr@2
    94
					 (G_HOOK_FLAGS (hook) & \
williamr@2
    95
                                          G_HOOK_FLAG_ACTIVE))
williamr@2
    96
#define G_HOOK_IS_UNLINKED(hook)	(G_HOOK (hook)->next == NULL && \
williamr@2
    97
					 G_HOOK (hook)->prev == NULL && \
williamr@2
    98
					 G_HOOK (hook)->hook_id == 0 && \
williamr@2
    99
					 G_HOOK (hook)->ref_count == 0)
williamr@2
   100
williamr@2
   101
williamr@2
   102
/* --- prototypes --- */
williamr@2
   103
/* callback maintenance functions */
williamr@2
   104
IMPORT_C void	 g_hook_list_init		(GHookList		*hook_list,
williamr@2
   105
					 guint			 hook_size);
williamr@2
   106
IMPORT_C void	 g_hook_list_clear		(GHookList		*hook_list);
williamr@2
   107
IMPORT_C GHook*	 g_hook_alloc			(GHookList		*hook_list);
williamr@2
   108
IMPORT_C void	 g_hook_free			(GHookList		*hook_list,
williamr@2
   109
					 GHook			*hook);
williamr@2
   110
IMPORT_C GHook *	 g_hook_ref			(GHookList		*hook_list,
williamr@2
   111
					 GHook			*hook);
williamr@2
   112
IMPORT_C void	 g_hook_unref			(GHookList		*hook_list,
williamr@2
   113
					 GHook			*hook);
williamr@2
   114
IMPORT_C gboolean g_hook_destroy			(GHookList		*hook_list,
williamr@2
   115
					 gulong			 hook_id);
williamr@2
   116
IMPORT_C void	 g_hook_destroy_link		(GHookList		*hook_list,
williamr@2
   117
					 GHook			*hook);
williamr@2
   118
IMPORT_C void	 g_hook_prepend			(GHookList		*hook_list,
williamr@2
   119
					 GHook			*hook);
williamr@2
   120
IMPORT_C void	 g_hook_insert_before		(GHookList		*hook_list,
williamr@2
   121
					 GHook			*sibling,
williamr@2
   122
					 GHook			*hook);
williamr@2
   123
IMPORT_C void	 g_hook_insert_sorted		(GHookList		*hook_list,
williamr@2
   124
					 GHook			*hook,
williamr@2
   125
					 GHookCompareFunc	 func);
williamr@2
   126
IMPORT_C GHook*	 g_hook_get			(GHookList		*hook_list,
williamr@2
   127
					 gulong			 hook_id);
williamr@2
   128
IMPORT_C GHook*	 g_hook_find			(GHookList		*hook_list,
williamr@2
   129
					 gboolean		 need_valids,
williamr@2
   130
					 GHookFindFunc		 func,
williamr@2
   131
					 gpointer		 data);
williamr@2
   132
IMPORT_C GHook*	 g_hook_find_data		(GHookList		*hook_list,
williamr@2
   133
					 gboolean		 need_valids,
williamr@2
   134
					 gpointer		 data);
williamr@2
   135
IMPORT_C GHook*	 g_hook_find_func		(GHookList		*hook_list,
williamr@2
   136
					 gboolean		 need_valids,
williamr@2
   137
					 gpointer		 func);
williamr@2
   138
IMPORT_C GHook*	 g_hook_find_func_data		(GHookList		*hook_list,
williamr@2
   139
					 gboolean		 need_valids,
williamr@2
   140
					 gpointer		 func,
williamr@2
   141
					 gpointer		 data);
williamr@2
   142
/* return the first valid hook, and increment its reference count */
williamr@2
   143
IMPORT_C GHook*	 g_hook_first_valid		(GHookList		*hook_list,
williamr@2
   144
					 gboolean		 may_be_in_call);
williamr@2
   145
/* return the next valid hook with incremented reference count, and
williamr@2
   146
 * decrement the reference count of the original hook
williamr@2
   147
 */
williamr@2
   148
IMPORT_C GHook*	 g_hook_next_valid		(GHookList		*hook_list,
williamr@2
   149
					 GHook			*hook,
williamr@2
   150
					 gboolean		 may_be_in_call);
williamr@2
   151
/* GHookCompareFunc implementation to insert hooks sorted by their id */
williamr@2
   152
IMPORT_C gint	 g_hook_compare_ids		(GHook			*new_hook,
williamr@2
   153
					 GHook			*sibling);
williamr@2
   154
/* convenience macros */
williamr@2
   155
#define	 g_hook_append( hook_list, hook )  \
williamr@2
   156
     g_hook_insert_before ((hook_list), NULL, (hook))
williamr@2
   157
/* invoke all valid hooks with the (*GHookFunc) signature.
williamr@2
   158
 */
williamr@2
   159
IMPORT_C void	 g_hook_list_invoke		(GHookList		*hook_list,
williamr@2
   160
					 gboolean		 may_recurse);
williamr@2
   161
/* invoke all valid hooks with the (*GHookCheckFunc) signature,
williamr@2
   162
 * and destroy the hook if FALSE is returned.
williamr@2
   163
 */
williamr@2
   164
IMPORT_C void	 g_hook_list_invoke_check	(GHookList		*hook_list,
williamr@2
   165
					 gboolean		 may_recurse);
williamr@2
   166
/* invoke a marshaller on all valid hooks.
williamr@2
   167
 */
williamr@2
   168
IMPORT_C void	 g_hook_list_marshal		(GHookList		*hook_list,
williamr@2
   169
					 gboolean		 may_recurse,
williamr@2
   170
					 GHookMarshaller	 marshaller,
williamr@2
   171
					 gpointer		 marshal_data);
williamr@2
   172
IMPORT_C void	 g_hook_list_marshal_check	(GHookList		*hook_list,
williamr@2
   173
					 gboolean		 may_recurse,
williamr@2
   174
					 GHookCheckMarshaller	 marshaller,
williamr@2
   175
					 gpointer		 marshal_data);
williamr@2
   176
williamr@2
   177
G_END_DECLS
williamr@2
   178
williamr@2
   179
#endif /* __G_HOOK_H__ */
williamr@2
   180