1 | /* GStreamer |
---|
2 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
---|
3 | * 2000 Wim Taymans <wtay@chello.be> |
---|
4 | * |
---|
5 | * gstobject.h: Header for base GstObject |
---|
6 | * |
---|
7 | * This library is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU Library General Public |
---|
9 | * License as published by the Free Software Foundation; either |
---|
10 | * version 2 of the License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This library is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | * Library General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU Library General Public |
---|
18 | * License along with this library; if not, write to the |
---|
19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
20 | * Boston, MA 02111-1307, USA. |
---|
21 | */ |
---|
22 | |
---|
23 | |
---|
24 | #ifndef __GST_OBJECT_H__ |
---|
25 | #define __GST_OBJECT_H__ |
---|
26 | |
---|
27 | #include <gst/gstconfig.h> |
---|
28 | |
---|
29 | #include <glib-object.h> /* note that this gets wrapped in __GST_OBJECT_H__ */ |
---|
30 | |
---|
31 | #include <gst/gsttypes.h> |
---|
32 | |
---|
33 | G_BEGIN_DECLS |
---|
34 | |
---|
35 | GST_EXPORT GType _gst_object_type; |
---|
36 | |
---|
37 | #define GST_TYPE_OBJECT (_gst_object_type) |
---|
38 | #define GST_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_OBJECT)) |
---|
39 | #define GST_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_OBJECT)) |
---|
40 | #define GST_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_OBJECT, GstObjectClass)) |
---|
41 | #define GST_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_OBJECT, GstObject)) |
---|
42 | #define GST_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_OBJECT, GstObjectClass)) |
---|
43 | |
---|
44 | /* make sure we don't change the object size but stil make it compile |
---|
45 | * without libxml */ |
---|
46 | #ifdef GST_DISABLE_LOADSAVE_REGISTRY |
---|
47 | #define xmlNodePtr gpointer |
---|
48 | #endif |
---|
49 | |
---|
50 | typedef enum |
---|
51 | { |
---|
52 | GST_DESTROYED = 0, |
---|
53 | GST_FLOATING, |
---|
54 | |
---|
55 | GST_OBJECT_FLAG_LAST = 4 |
---|
56 | } GstObjectFlags; |
---|
57 | |
---|
58 | struct _GstObject { |
---|
59 | GObject object; |
---|
60 | |
---|
61 | gchar *name; |
---|
62 | |
---|
63 | /* locking for all sorts of things */ |
---|
64 | GMutex *lock; |
---|
65 | /* this object's parent */ |
---|
66 | GstObject *parent; |
---|
67 | |
---|
68 | guint32 flags; |
---|
69 | |
---|
70 | gpointer _gst_reserved[GST_PADDING]; |
---|
71 | }; |
---|
72 | |
---|
73 | /* signal_object is used to signal to the whole class */ |
---|
74 | struct _GstObjectClass { |
---|
75 | GObjectClass parent_class; |
---|
76 | |
---|
77 | gchar *path_string_separator; |
---|
78 | GObject *signal_object; |
---|
79 | |
---|
80 | /* signals */ |
---|
81 | void (*parent_set) (GstObject *object, GstObject *parent); |
---|
82 | void (*parent_unset) (GstObject *object, GstObject *parent); |
---|
83 | void (*object_saved) (GstObject *object, xmlNodePtr parent); |
---|
84 | void (*deep_notify) (GstObject *object, GstObject *orig, GParamSpec *pspec); |
---|
85 | |
---|
86 | /* functions go here */ |
---|
87 | void (*destroy) (GstObject *object); |
---|
88 | |
---|
89 | xmlNodePtr (*save_thyself) (GstObject *object, xmlNodePtr parent); |
---|
90 | void (*restore_thyself) (GstObject *object, xmlNodePtr self); |
---|
91 | |
---|
92 | gpointer _gst_reserved[GST_PADDING]; |
---|
93 | }; |
---|
94 | |
---|
95 | #define GST_FLAGS(obj) (GST_OBJECT (obj)->flags) |
---|
96 | #define GST_FLAG_IS_SET(obj,flag) (GST_FLAGS (obj) & (1<<(flag))) |
---|
97 | #define GST_FLAG_SET(obj,flag) G_STMT_START{ (GST_FLAGS (obj) |= (1<<(flag))); }G_STMT_END |
---|
98 | #define GST_FLAG_UNSET(obj,flag) G_STMT_START{ (GST_FLAGS (obj) &= ~(1<<(flag))); }G_STMT_END |
---|
99 | |
---|
100 | #define GST_OBJECT_NAME(obj) (const gchar*)(((GstObject *)(obj))->name) |
---|
101 | #define GST_OBJECT_PARENT(obj) (((GstObject *)(obj))->parent) |
---|
102 | |
---|
103 | #define GST_OBJECT_DESTROYED(obj) (GST_FLAG_IS_SET (obj, GST_DESTROYED)) |
---|
104 | #define GST_OBJECT_FLOATING(obj) (GST_FLAG_IS_SET (obj, GST_FLOATING)) |
---|
105 | |
---|
106 | /* CR1: object locking - GObject 2.0 doesn't have threadsafe locking */ |
---|
107 | #define GST_LOCK(obj) (g_mutex_lock(GST_OBJECT(obj)->lock)) |
---|
108 | #define GST_TRYLOCK(obj) (g_mutex_trylock(GST_OBJECT(obj)->lock)) |
---|
109 | #define GST_UNLOCK(obj) (g_mutex_unlock(GST_OBJECT(obj)->lock)) |
---|
110 | #define GST_GET_LOCK(obj) (GST_OBJECT(obj)->lock) |
---|
111 | |
---|
112 | |
---|
113 | /* normal GObject stuff */ |
---|
114 | GType gst_object_get_type (void); |
---|
115 | |
---|
116 | /* name routines */ |
---|
117 | void gst_object_set_name (GstObject *object, const gchar *name); |
---|
118 | G_CONST_RETURN gchar* |
---|
119 | gst_object_get_name (GstObject *object); |
---|
120 | |
---|
121 | /* parentage routines */ |
---|
122 | void gst_object_set_parent (GstObject *object, GstObject *parent); |
---|
123 | GstObject* gst_object_get_parent (GstObject *object); |
---|
124 | void gst_object_unparent (GstObject *object); |
---|
125 | |
---|
126 | void gst_object_default_deep_notify (GObject *object, GstObject *orig, |
---|
127 | GParamSpec *pspec, gchar **excluded_props); |
---|
128 | |
---|
129 | gboolean gst_object_check_uniqueness (GList *list, const gchar *name); |
---|
130 | |
---|
131 | #ifndef GST_DISABLE_LOADSAVE_REGISTRY |
---|
132 | xmlNodePtr gst_object_save_thyself (GstObject *object, xmlNodePtr parent); |
---|
133 | void gst_object_restore_thyself (GstObject *object, xmlNodePtr self); |
---|
134 | #else |
---|
135 | #if defined _GNUC_ && _GNUC_ >= 3 |
---|
136 | #pragma GCC poison gst_object_save_thyself |
---|
137 | #pragma GCC poison gst_object_restore_thyself |
---|
138 | #endif |
---|
139 | #endif |
---|
140 | |
---|
141 | /* refcounting + life cycle */ |
---|
142 | GstObject * gst_object_ref (GstObject *object); |
---|
143 | void gst_object_unref (GstObject *object); |
---|
144 | void gst_object_sink (GstObject *object); |
---|
145 | |
---|
146 | /* replace object pointer */ |
---|
147 | void gst_object_replace (GstObject **oldobj, GstObject *newobj); |
---|
148 | |
---|
149 | /* printing out the 'path' of the object */ |
---|
150 | gchar * gst_object_get_path_string (GstObject *object); |
---|
151 | |
---|
152 | guint gst_class_signal_connect (GstObjectClass *klass, |
---|
153 | const gchar *name, |
---|
154 | gpointer func, |
---|
155 | gpointer func_data); |
---|
156 | |
---|
157 | #ifndef GST_DISABLE_LOADSAVE_REGISTRY |
---|
158 | void gst_class_signal_emit_by_name (GstObject *object, |
---|
159 | const gchar *name, |
---|
160 | xmlNodePtr self); |
---|
161 | #else |
---|
162 | #if defined _GNUC_ && _GNUC_ >= 3 |
---|
163 | #pragma GCC poison gst_class_signal_emit_by_name |
---|
164 | #endif |
---|
165 | #endif |
---|
166 | |
---|
167 | |
---|
168 | G_END_DECLS |
---|
169 | |
---|
170 | #endif /* __GST_OBJECT_H__ */ |
---|
171 | |
---|