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>
36 #include <asm/atomic.h>
44 #endif /* __cplusplus */
47 #define GST_TYPE_OBJECT \
48 (gst_object_get_type())
49 #define GST_OBJECT(obj) \
50 (GTK_CHECK_CAST((obj),GST_TYPE_OBJECT,GstObject))
51 #define GST_OBJECT_CLASS(klass) \
52 (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_OBJECT,GstObjectClass))
53 #define GST_IS_OBJECT(obj) \
54 (GTK_CHECK_TYPE((obj),GST_TYPE_OBJECT))
55 #define GST_IS_OBJECT_CLASS(obj) \
56 (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_OBJECT))
58 typedef struct _GstObject GstObject;
59 typedef struct _GstObjectClass GstObjectClass;
61 #define GST_OBJECT_FLAG_LAST 4
67 /* have to have a refcount for the object */
74 /* locking for all sorts of things (like the refcount) */
77 /* this objects parent */
81 struct _GstObjectClass {
82 GtkObjectClass parent_class;
84 gchar *path_string_separator;
87 void (*parent_set) (GstObject *object, GstObject *parent);
89 /* functions go here */
90 xmlNodePtr (*save_thyself) (GstObject *object, xmlNodePtr parent);
91 void (*restore_thyself) (GstObject *object, xmlNodePtr self);
94 #define GST_OBJECT_NAME(obj) (const gchar*)(((GstObject *)(obj))->name)
95 #define GST_OBJECT_PARENT(obj) (((GstObject *)(obj))->parent)
98 #define GST_FLAGS(obj) GTK_OBJECT_FLAGS(obj)
99 #define GST_FLAG_IS_SET(obj,flag) (GST_FLAGS (obj) & (1<<(flag)))
100 #define GST_FLAG_SET(obj,flag) G_STMT_START{ (GST_FLAGS (obj) |= (1<<(flag))); }G_STMT_END
101 #define GST_FLAG_UNSET(obj,flag) G_STMT_START{ (GST_FLAGS (obj) &= ~(1<<(flag))); }G_STMT_END
104 #define GST_LOCK(obj) (g_mutex_lock(GST_OBJECT(obj)->lock))
105 #define GST_TRYLOCK(obj) (g_mutex_trylock(GST_OBJECT(obj)->lock))
106 #define GST_UNLOCK(obj) (g_mutex_unlock(GST_OBJECT(obj)->lock))
107 #define GST_GET_LOCK(obj) (GST_OBJECT(obj)->lock)
110 /* normal GtkObject stuff */
111 GtkType gst_object_get_type (void);
112 GstObject* gst_object_new (void);
115 void gst_object_set_name (GstObject *object, const gchar *name);
116 const gchar* gst_object_get_name (GstObject *object);
118 /* parentage routines */
119 void gst_object_set_parent (GstObject *object,GstObject *parent);
120 GstObject* gst_object_get_parent (GstObject *object);
121 void gst_object_unparent (GstObject *object);
123 xmlNodePtr gst_object_save_thyself (GstObject *object, xmlNodePtr parent);
126 #define gst_object_ref(object) gtk_object_ref(GTK_OBJECT(object));
127 #define gst_object_unref(object) gtk_object_unref(GTK_OBJECT(object));
128 #define gst_object_sink(object) gtk_object_sink(GTK_OBJECT(object));
130 /* destroying an object */
131 #define gst_object_destroy(object) gtk_object_destroy(GTK_OBJECT(object))
133 /* printing out the 'path' of the object */
134 gchar * gst_object_get_path_string (GstObject *object);
139 #endif /* __cplusplus */
142 #endif /* __GST_OBJECT_H__ */