2 * Copyright (C) 2005 David Schleef <ds@schleef.org>
4 * gstminiobject.h: Header for GstMiniObject
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #ifndef __GST_MINI_OBJECT_H__
24 #define __GST_MINI_OBJECT_H__
26 #include <gst/gstconfig.h>
28 #include <glib-object.h>
32 #define GST_TYPE_MINI_OBJECT (gst_mini_object_get_type())
33 #define GST_IS_MINI_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MINI_OBJECT))
34 #define GST_IS_MINI_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MINI_OBJECT))
35 #define GST_MINI_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MINI_OBJECT, GstMiniObjectClass))
36 #define GST_MINI_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MINI_OBJECT, GstMiniObject))
37 #define GST_MINI_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MINI_OBJECT, GstMiniObjectClass))
38 #define GST_MINI_OBJECT_CAST(obj) ((GstMiniObject*)(obj))
40 typedef struct _GstMiniObject GstMiniObject;
41 typedef struct _GstMiniObjectClass GstMiniObjectClass;
44 * GstMiniObjectCopyFunction:
45 * @obj: MiniObject to copy
47 * Virtual function prototype for methods to create copies of instances.
49 * Returns: reference to cloned instance.
51 typedef GstMiniObject * (*GstMiniObjectCopyFunction) (const GstMiniObject *obj);
53 * GstMiniObjectFinalizeFunction:
54 * @obj: MiniObject to finalize
56 * Virtual function prototype for methods to free ressources used by
59 typedef void (*GstMiniObjectFinalizeFunction) (GstMiniObject *obj);
62 * GST_MINI_OBJECT_FLAGS:
63 * @obj: MiniObject to return flags for.
65 * This macro returns the entire set of flags for the mini-object.
67 #define GST_MINI_OBJECT_FLAGS(obj) (GST_MINI_OBJECT(obj)->flags)
69 * GST_MINI_OBJECT_FLAG_IS_SET:
70 * @obj: MiniObject to check for flags.
71 * @flag: Flag to check for
73 * This macro checks to see if the given flag is set.
75 #define GST_MINI_OBJECT_FLAG_IS_SET(obj,flag) (GST_MINI_OBJECT_FLAGS (obj) & (flag))
77 * GST_MINI_OBJECT_FLAG_SET:
78 * @obj: MiniObject to set flag in.
79 * @flag: Flag to set, can by any number of bits in guint32.
81 * This macro sets the given bits.
83 #define GST_MINI_OBJECT_FLAG_SET(obj,flag) (GST_MINI_OBJECT_FLAGS (obj) |= (flag))
85 * GST_MINI_OBJECT_FLAG_UNSET:
86 * @obj: MiniObject to unset flag in.
87 * @flag: Flag to set, must be a single bit in guint32.
89 * This macro usets the given bits.
91 #define GST_MINI_OBJECT_FLAG_UNSET(obj,flag) (GST_MINI_OBJECT_FLAGS (obj) &= ~(flag))
94 * GST_VALUE_HOLDS_MINI_OBJECT:
95 * @value: the #GValue to check
97 * Checks if the given #GValue contains a #GST_TYPE_MINI_OBJECT value.
99 #define GST_VALUE_HOLDS_MINI_OBJECT(value) (G_VALUE_HOLDS(value, GST_TYPE_MINI_OBJECT))
102 * GstMiniObjectFlags:
103 * @GST_MINI_OBJECT_FLAG_READONLY: is the miniobject readonly or writable
104 * @GST_MINI_OBJECT_FLAG_LAST: first flag that can be used by subclasses.
106 * Flags for the padtemplate
111 GST_MINI_OBJECT_FLAG_READONLY = (1<<0),
113 GST_MINI_OBJECT_FLAG_LAST = (1<<4)
114 } GstMiniObjectFlags;
117 * GST_MINI_OBJECT_REFCOUNT:
118 * @obj: MiniObject get the refcount for.
120 * Get access to the reference count field of the mini-object.
122 #define GST_MINI_OBJECT_REFCOUNT(obj) ((GST_MINI_OBJECT_CAST(obj))->refcount)
124 * GST_MINI_OBJECT_REFCOUNT_VALUE:
125 * @obj: MiniObject get the refcount value for.
127 * Get the reference count value of the mini-object.
129 #define GST_MINI_OBJECT_REFCOUNT_VALUE(obj) (g_atomic_int_get (&(GST_MINI_OBJECT_CAST(obj))->refcount))
131 struct _GstMiniObject {
132 GTypeInstance instance;
136 gpointer _gst_reserved[GST_PADDING];
139 struct _GstMiniObjectClass {
140 GTypeClass type_class;
142 GstMiniObjectCopyFunction copy;
143 GstMiniObjectFinalizeFunction finalize;
145 gpointer _gst_reserved[GST_PADDING];
148 GType gst_mini_object_get_type (void);
150 GstMiniObject * gst_mini_object_new (GType type);
151 GstMiniObject * gst_mini_object_copy (const GstMiniObject *mini_object);
152 gboolean gst_mini_object_is_writable (const GstMiniObject *mini_object);
153 GstMiniObject * gst_mini_object_make_writable (GstMiniObject *mini_object);
155 GstMiniObject * gst_mini_object_ref (GstMiniObject *mini_object);
156 void gst_mini_object_unref (GstMiniObject *mini_object);
158 void gst_mini_object_replace (GstMiniObject **olddata, GstMiniObject *newdata);
160 GParamSpec * gst_param_spec_mini_object (const char *name, const char *nick,
161 const char *blurb, GType object_type, GParamFlags flags);
163 void gst_value_set_mini_object (GValue *value, GstMiniObject *mini_object);
164 void gst_value_take_mini_object (GValue *value, GstMiniObject *mini_object);
165 GstMiniObject * gst_value_get_mini_object (const GValue *value);