2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstobject.h: Header for base GstObject
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.
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.
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.
24 #ifndef __GST_OBJECT_H__
25 #define __GST_OBJECT_H__
28 #include <gst/gsttrace.h>
35 #include <asm/atomic.h>
43 #endif /* __cplusplus */
46 #define GST_TYPE_OBJECT \
47 (gst_object_get_type())
48 #define GST_OBJECT(obj) \
49 (GTK_CHECK_CAST((obj),GST_TYPE_OBJECT,GstObject))
50 #define GST_OBJECT_CLASS(klass) \
51 (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_OBJECT,GstObjectClass))
52 #define GST_IS_OBJECT(obj) \
53 (GTK_CHECK_TYPE((obj),GST_TYPE_OBJECT))
54 #define GST_IS_OBJECT_CLASS(obj) \
55 (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_OBJECT))
57 typedef struct _GstObject GstObject;
58 typedef struct _GstObjectClass GstObjectClass;
60 #define GST_OBJECT_FLAG_LAST 4
65 /* have to have a refcount for the object */
72 /* locking for all sorts of things (like the refcount) */
75 /* this objects parent */
79 struct _GstObjectClass {
80 GtkObjectClass parent_class;
83 void (*parent_set) (GstObject *object,GstObject *parent);
85 /* functions go here */
89 #define GST_FLAGS(obj) GTK_OBJECT_FLAGS(obj)
90 #define GST_FLAG_IS_SET(obj,flag) (GST_FLAGS (obj) & (1<<(flag)))
91 #define GST_FLAG_SET(obj,flag) G_STMT_START{ (GST_FLAGS (obj) |= (1<<(flag))); }G_STMT_END
92 #define GST_FLAG_UNSET(obj,flag) G_STMT_START{ (GST_FLAGS (obj) &= ~(1<<(flag))); }G_STMT_END
94 #define GST_LOCK(obj) (g_mutex_lock(GST_OBJECT(obj)->lock))
95 #define GST_TRYLOCK(obj) (g_mutex_trylock(GST_OBJECT(obj)->lock))
96 #define GST_UNLOCK(obj) (g_mutex_unlock(GST_OBJECT(obj)->lock))
99 /* normal GtkObject stuff */
100 GtkType gst_object_get_type (void);
101 GstObject* gst_object_new (void);
103 /* parentage routines */
104 void gst_object_set_parent (GstObject *object,GstObject *parent);
105 GstObject* gst_object_get_parent (GstObject *object);
106 void gst_object_unparent (GstObject *object);
109 #define gst_object_ref(object) gtk_object_ref(GTK_OBJECT(object));
110 #define gst_object_unref(object) gtk_object_unref(GTK_OBJECT(object));
111 #define gst_object_sink(object) gtk_object_sink(GTK_OBJECT(object));
113 /* destroying an object */
114 #define gst_object_destroy(object) gtk_object_destroy(GTK_OBJECT(object))
116 /* printing out the 'path' of the object */
117 gchar * gst_object_get_path_string (GstObject *object);
122 #endif /* __cplusplus */
125 #endif /* __GST_OBJECT_H__ */