1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
19 #ifndef __G_GOBJECT_H__
20 #define __G_GOBJECT_H__
22 #include <gobject/gtype.h>
23 #include <gobject/gvalue.h>
24 #include <gobject/gparam.h>
29 #endif /* __cplusplus */
32 /* --- type macros --- */
33 #define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)
34 #define G_OBJECT(object) (G_IS_OBJECT (object) ? ((GObject*) (object)) : \
35 G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
36 #define G_OBJECT_CLASS(class) (G_IS_OBJECT_CLASS (class) ? ((GObjectClass*) (class)) : \
37 G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))
38 #define G_IS_OBJECT(object) (((GObject*) (object)) != NULL && \
39 G_IS_OBJECT_CLASS (((GTypeInstance*) (object))->g_class))
40 #define G_IS_OBJECT_CLASS(class) (((GTypeClass*) (class)) != NULL && \
41 G_TYPE_IS_OBJECT (((GTypeClass*) (class))->g_type))
42 #define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
43 #define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
44 #define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object)))
45 #define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
46 #define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class)))
47 #define G_IS_VALUE_OBJECT(value) (G_TYPE_CHECK_CLASS_TYPE ((value), G_TYPE_OBJECT))
49 #define G_NOTIFY_PRIORITY (G_PRIORITY_HIGH_IDLE + 20)
52 /* --- typedefs & structures --- */
53 typedef struct _GObject GObject;
54 typedef struct _GObjectClass GObjectClass;
55 typedef void (*GObjectGetParamFunc) (GObject *object,
59 const gchar *trailer);
60 typedef void (*GObjectSetParamFunc) (GObject *object,
64 const gchar *trailer);
65 typedef void (*GObjectFinalizeFunc) (GObject *object);
68 GTypeInstance g_type_instance;
76 GTypeClass g_type_class;
79 GParamSpec **param_specs;
81 void (*get_param) (GObject *object,
85 const gchar *trailer);
86 void (*set_param) (GObject *object,
90 const gchar *trailer);
91 void (*queue_param_changed) (GObject *object,
93 void (*dispatch_param_changed) (GObject *object,
95 void (*shutdown) (GObject *object);
96 void (*finalize) (GObject *object);
100 /* --- prototypes --- */
101 void g_object_class_install_param (GObjectClass *oclass,
103 GParamSpec *pspec /* +1 ref */);
104 GParamSpec* g_object_class_find_param_spec (GObjectClass *oclass,
105 const gchar *param_name);
106 gpointer g_object_new (GType object_type,
107 const gchar *first_param_name,
109 gpointer g_object_new_valist (GType object_type,
110 const gchar *first_param_name,
112 void g_object_set (GObject *object,
113 const gchar *first_param_name,
115 void g_object_get (GObject *object,
116 const gchar *first_param_name,
118 void g_object_set_valist (GObject *object,
119 const gchar *first_param_name,
121 void g_object_get_valist (GObject *object,
122 const gchar *first_param_name,
124 void g_object_set_param (GObject *object,
125 const gchar *param_name,
126 const GValue *value);
127 void g_object_get_param (GObject *object,
128 const gchar *param_name,
130 void g_object_queue_param_changed (GObject *object,
131 const gchar *param_name);
132 GObject* g_object_ref (GObject *object);
133 void g_object_unref (GObject *object);
134 gpointer g_object_get_qdata (GObject *object,
136 void g_object_set_qdata (GObject *object,
139 void g_object_set_qdata_full (GObject *object,
142 GDestroyNotify destroy);
143 gpointer g_object_steal_qdata (GObject *object,
145 void g_value_set_object (GValue *value,
147 GObject* g_value_get_object (GValue *value);
148 GObject* g_value_dup_object (GValue *value);
151 /* --- implementation macros --- */
152 #define G_WARN_INVALID_PARAM_ID(object, param_id, pspec) \
154 GObject *_object = (GObject*) (object); \
155 GParamSpec *_pspec = (GParamSpec*) (pspec); \
156 guint _param_id = (param_id); \
157 g_warning ("%s: invalid parameter id %u for \"%s\" of type `%s' in `%s'", \
161 g_type_name (G_PARAM_SPEC_TYPE (_pspec)), \
162 BSE_OBJECT_TYPE_NAME (_object)); \
169 #endif /* __cplusplus */
171 #endif /* __G_GOBJECT_H__ */