Various fixes for the build/install problems update to the docs/manual. Added a simpl...
[platform/upstream/gstreamer.git] / gst / gstobject.h
1 /* Gnome-Streamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library 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.
8  *
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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * 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.
18  */
19
20
21 #ifndef __GST_OBJECT_H__
22 #define __GST_OBJECT_H__
23
24
25 #include <gtk/gtk.h>
26 #include <gst/gsttrace.h>
27 //#include "config.h"
28
29 #undef HAVE_ATOMIC_H
30
31 #ifdef HAVE_ATOMIC_H
32 #include <asm/atomic.h>
33 #endif
34
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39
40
41 #define GST_TYPE_OBJECT \
42   (gst_object_get_type())
43 #define GST_OBJECT(obj) \
44   (GTK_CHECK_CAST((obj),GST_TYPE_OBJECT,GstObject))
45 #define GST_OBJECT_CLASS(klass) \
46   (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_OBJECT,GstObjectClass))
47 #define GST_IS_OBJECT(obj) \
48   (GTK_CHECK_TYPE((obj),GST_TYPE_OBJECT))
49 #define GST_IS_OBJECT_CLASS(obj) \
50   (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_OBJECT))
51
52 typedef struct _GstObject GstObject;
53 typedef struct _GstObjectClass GstObjectClass;
54
55 struct _GstObject {
56   GtkObject object;
57
58   /* have to have a refcount for the object */
59 #ifdef HAVE_ATOMIC_H
60   atomic_t refcount;
61 #else
62   int refcount;
63 #endif
64
65   /* locking for all sorts of things (like the refcount) */
66   GMutex *lock;
67
68   /* this objects parent */
69   GstObject *parent;
70 };
71
72 struct _GstObjectClass {
73   GtkObjectClass parent_class;
74
75   /* signals */
76   void (*parent_set) (GstObject *object,GstObject *parent);
77
78   /* functions go here */
79 };
80
81
82 #define GST_FLAGS(obj)                  GTK_OBJECT_FLAGS(obj)
83 #define GST_FLAG_IS_SET(obj,flag)       (GST_FLAGS (obj) & (flag))
84 #define GST_FLAG_SET(obj,flag)          G_STMT_START{ (GST_FLAGS (obj) |= (flag)); }G_STMT_END
85 #define GST_FLAG_UNSET(obj,flag)        G_STMT_START{ (GST_FLAGS (obj) &= ~(flag)); }G_STMT_END
86
87 #define GST_LOCK(obj)           (g_mutex_lock(GST_OBJECT(obj)->lock))
88 #define GST_TRYLOCK(obj)        (g_mutex_trylock(GST_OBJECT(obj)->lock))
89 #define GST_UNLOCK(obj)         (g_mutex_unlock(GST_OBJECT(obj)->lock))
90
91
92 /* normal GtkObject stuff */
93 GtkType gst_object_get_type(void);
94 GstObject* gst_object_new(void);
95
96 /* parentage routines */
97 void gst_object_set_parent(GstObject *object,GstObject *parent);
98 GstObject *gst_object_get_parent(GstObject *object);
99 void gst_object_unparent(GstObject *object);
100
101 /* refcounting */
102 //void gst_object_ref(GstObject *object);
103 #define gst_object_ref(object) gtk_object_ref(GTK_OBJECT(object));
104 //void gst_object_unref(GstObject *object);
105 #define gst_object_unref(object) gtk_object_unref(GTK_OBJECT(object));
106 //void gst_object_sink(GstObject *object);
107 #define gst_object_sink(object) gtk_object_sink(GTK_OBJECT(object));
108
109 /* destroying an object */
110 #define gst_object_destroy(object) gtk_object_destroy(GTK_OBJECT(object))
111
112
113 #ifdef __cplusplus
114 }
115 #endif /* __cplusplus */
116
117
118 #endif /* __GST_OBJECT_H__ */     
119