alternative to assert
[gtkD.git] / gtkD / srcgstreamer / gstreamer / ObjectGst.d
blob0ad319d0f1e6af9c301ec6124d542721d59b88c5
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GstObject.html
26 * outPack = gstreamer
27 * outFile = ObjectGst
28 * strct = GstObject
29 * realStrct=
30 * ctorStrct=
31 * clss = ObjectGst
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gst_object_
40 * - gst_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gst_object_save_thyself
45 * - gst_object_restore_thyself
46 * - gst_class_signal_emit_by_name
47 * - gst_class_signal_connect
48 * imports:
49 * - glib.Str
50 * - gobject.ObjectG
51 * - glib.ErrorG
52 * - glib.ListG
53 * structWrap:
54 * - GError* -> ErrorG
55 * - GList* -> ListG
56 * - GObject* -> ObjectG
57 * - GstObject* -> ObjectGst
58 * module aliases:
59 * local aliases:
62 module gstreamer.ObjectGst;
64 private import gstreamerc.gstreamertypes;
66 private import gstreamerc.gstreamer;
68 private import glib.Str;
69 private import gobject.ObjectG;
70 private import glib.ErrorG;
71 private import glib.ListG;
75 /**
76 * Description
77 * GstObject provides a root for the object hierarchy tree filed in by the
78 * GStreamer library. It is currently a thin wrapper on top of
79 * GObject. It is an abstract class that is not very usable on its own.
80 * GstObject gives us basic refcounting, parenting functionality and locking.
81 * Most of the function are just extended for special GStreamer needs and can be
82 * found under the same name in the base class of GstObject which is GObject
83 * (e.g. g_object_ref() becomes gst_object_ref()).
84 * The most interesting difference between GstObject and GObject is the
85 * "floating" reference count. A GObject is created with a reference count of
86 * 1, owned by the creator of the GObject. (The owner of a reference is the
87 * code section that has the right to call gst_object_unref() in order to
88 * remove that reference.) A GstObject is created with a reference count of 1
89 * also, but it isn't owned by anyone; Instead, the initial reference count
90 * of a GstObject is "floating". The floating reference can be removed by
91 * anyone at any time, by calling gst_object_sink(). gst_object_sink() does
92 * nothing if an object is already sunk (has no floating reference).
93 * When you add a GstElement to its parent container, the parent container will
94 * do this:
95 * gst_object_ref (GST_OBJECT (child_element));
96 * gst_object_sink (GST_OBJECT (child_element));
97 * This means that the container now owns a reference to the child element
98 * (since it called gst_object_ref()), and the child element has no floating
99 * reference.
100 * The purpose of the floating reference is to keep the child element alive
101 * until you add it to a parent container, which then manages the lifetime of
102 * the object itself:
103 * element = gst_element_factory_make (factoryname, name);
104 * // element has one floating reference to keep it alive
105 * gst_bin_add (GST_BIN (bin), element);
106 * // element has one non-floating reference owned by the container
107 * Another effect of this is, that calling gst_object_unref() on a bin object,
108 * will also destoy all the GstElement objects in it. The same is true for
109 * calling gst_bin_remove().
110 * Special care has to be taken for all methods that gst_object_sink() an object
111 * since if the caller of those functions had a floating reference to the object,
112 * the object reference is now invalid.
113 * In contrast to GObject instances, GstObject adds a name property. The functions
114 * gst_object_set_name() and gst_object_get_name() are used to set/get the name
115 * of the object.
116 * Last reviewed on 2005-11-09 (0.9.4)
118 private import gobject.ObjectG;
119 public class ObjectGst : ObjectG
122 /** the main Gtk struct */
123 protected GstObject* gstObject;
126 public GstObject* getObjectGstStruct()
128 return gstObject;
132 /** the main Gtk struct as a void* */
133 protected void* getStruct()
135 return cast(void*)gstObject;
139 * Sets our main struct and passes it to the parent class
141 public this (GstObject* gstObject)
143 super(cast(GObject*)gstObject);
144 this.gstObject = gstObject;
150 // imports for the signal processing
151 private import gobject.Signals;
152 private import gtkc.gdktypes;
153 int[char[]] connectedSignals;
155 void delegate(ObjectG, GParamSpec*, ObjectGst)[] onDeepNotifyListeners;
156 void addOnDeepNotify(void delegate(ObjectG, GParamSpec*, ObjectGst) dlg)
158 if ( !("deep-notify" in connectedSignals) )
160 Signals.connectData(
161 getStruct(),
162 "deep-notify",
163 cast(GCallback)&callBackDeepNotify,
164 cast(void*)this,
165 null,
166 cast(ConnectFlags)0);
167 connectedSignals["deep-notify"] = 1;
169 onDeepNotifyListeners ~= dlg;
171 extern(C) static void callBackDeepNotify(GstObject* gstobjectStruct, GObject* propObject, GParamSpec* prop, ObjectGst objectGst)
173 bit consumed = false;
175 foreach ( void delegate(ObjectG, GParamSpec*, ObjectGst) dlg ; objectGst.onDeepNotifyListeners )
177 dlg(new ObjectG(propObject), prop, objectGst);
180 return consumed;
183 void delegate(gpointer, ObjectGst)[] onObjectSavedListeners;
184 void addOnObjectSaved(void delegate(gpointer, ObjectGst) dlg)
186 if ( !("object-saved" in connectedSignals) )
188 Signals.connectData(
189 getStruct(),
190 "object-saved",
191 cast(GCallback)&callBackObjectSaved,
192 cast(void*)this,
193 null,
194 cast(ConnectFlags)0);
195 connectedSignals["object-saved"] = 1;
197 onObjectSavedListeners ~= dlg;
199 extern(C) static void callBackObjectSaved(GstObject* gstobjectStruct, gpointer xmlNode, ObjectGst objectGst)
201 bit consumed = false;
203 foreach ( void delegate(gpointer, ObjectGst) dlg ; objectGst.onObjectSavedListeners )
205 dlg(xmlNode, objectGst);
208 return consumed;
211 void delegate(ObjectG, ObjectGst)[] onParentSetListeners;
212 void addOnParentSet(void delegate(ObjectG, ObjectGst) dlg)
214 if ( !("parent-set" in connectedSignals) )
216 Signals.connectData(
217 getStruct(),
218 "parent-set",
219 cast(GCallback)&callBackParentSet,
220 cast(void*)this,
221 null,
222 cast(ConnectFlags)0);
223 connectedSignals["parent-set"] = 1;
225 onParentSetListeners ~= dlg;
227 extern(C) static void callBackParentSet(GstObject* gstobjectStruct, GObject* parent, ObjectGst objectGst)
229 bit consumed = false;
231 foreach ( void delegate(ObjectG, ObjectGst) dlg ; objectGst.onParentSetListeners )
233 dlg(new ObjectG(parent), objectGst);
236 return consumed;
239 void delegate(ObjectG, ObjectGst)[] onParentUnsetListeners;
240 void addOnParentUnset(void delegate(ObjectG, ObjectGst) dlg)
242 if ( !("parent-unset" in connectedSignals) )
244 Signals.connectData(
245 getStruct(),
246 "parent-unset",
247 cast(GCallback)&callBackParentUnset,
248 cast(void*)this,
249 null,
250 cast(ConnectFlags)0);
251 connectedSignals["parent-unset"] = 1;
253 onParentUnsetListeners ~= dlg;
255 extern(C) static void callBackParentUnset(GstObject* gstobjectStruct, GObject* parent, ObjectGst objectGst)
257 bit consumed = false;
259 foreach ( void delegate(ObjectG, ObjectGst) dlg ; objectGst.onParentUnsetListeners )
261 dlg(new ObjectG(parent), objectGst);
264 return consumed;
289 * Sets the name of object, or gives object a guaranteed unique
290 * name (if name is NULL).
291 * This function makes a copy of the provided name, so the caller
292 * retains ownership of the name it sent.
293 * object:
294 * a GstObject
295 * name:
296 * new name of object
297 * Returns:
298 * TRUE if the name could be set. Since Objects that have
299 * a parent cannot be renamed, this function returns FALSE in those
300 * cases.
301 * MT safe. This function grabs and releases object's LOCK.
303 public int setName(char[] name)
305 // gboolean gst_object_set_name (GstObject *object, const gchar *name);
306 return gst_object_set_name(gstObject, Str.toStringz(name));
310 * Returns a copy of the name of object.
311 * Caller should g_free() the return value after usage.
312 * For a nameless object, this returns NULL, which you can safely g_free()
313 * as well.
314 * object:
315 * a GstObject
316 * Returns:
317 * the name of object. g_free() after usage.
318 * MT safe. This function grabs and releases object's LOCK.
320 public char[] getName()
322 // gchar* gst_object_get_name (GstObject *object);
323 return Str.toString(gst_object_get_name(gstObject) );
327 * Sets the parent of object to parent. The object's reference count will
328 * be incremented, and any floating reference will be removed (see gst_object_sink()).
329 * This function causes the parent-set signal to be emitted when the parent
330 * was successfully set.
331 * object:
332 * a GstObject
333 * parent:
334 * new parent of object
335 * Returns:
336 * TRUE if parent could be set or FALSE when object
337 * already had a parent or object and parent are the same.
338 * MT safe. Grabs and releases object's LOCK.
340 public int setParent(ObjectGst parent)
342 // gboolean gst_object_set_parent (GstObject *object, GstObject *parent);
343 return gst_object_set_parent(gstObject, (parent is null) ? null : parent.getObjectGstStruct());
347 * Returns the parent of object. This function increases the refcount
348 * of the parent object so you should gst_object_unref() it after usage.
349 * object:
350 * a GstObject
351 * Returns:
352 * parent of object, this can be NULL if object has no
353 * parent. unref after usage.
354 * MT safe. Grabs and releases object's LOCK.
356 public ObjectGst getParent()
358 // GstObject* gst_object_get_parent (GstObject *object);
359 return new ObjectGst( gst_object_get_parent(gstObject) );
363 * Clear the parent of object, removing the associated reference.
364 * This function decreases the refcount of object.
365 * MT safe. Grabs and releases object's lock.
366 * object:
367 * a GstObject to unparent
369 public void unparent()
371 // void gst_object_unparent (GstObject *object);
372 gst_object_unparent(gstObject);
376 * Returns a copy of the name prefix of object.
377 * Caller should g_free() the return value after usage.
378 * For a prefixless object, this returns NULL, which you can safely g_free()
379 * as well.
380 * object:
381 * a GstObject
382 * Returns:
383 * the name prefix of object. g_free() after usage.
384 * MT safe. This function grabs and releases object's LOCK.
386 public char[] getNamePrefix()
388 // gchar* gst_object_get_name_prefix (GstObject *object);
389 return Str.toString(gst_object_get_name_prefix(gstObject) );
393 * Sets the name prefix of object to name_prefix.
394 * This function makes a copy of the provided name prefix, so the caller
395 * retains ownership of the name prefix it sent.
396 * MT safe. This function grabs and releases object's LOCK.
397 * object:
398 * a GstObject
399 * name_prefix:
400 * new name prefix of object
402 public void setNamePrefix(char[] namePrefix)
404 // void gst_object_set_name_prefix (GstObject *object, const gchar *name_prefix);
405 gst_object_set_name_prefix(gstObject, Str.toStringz(namePrefix));
409 * A default deep_notify signal callback for an object. The user data
410 * should contain a pointer to an array of strings that should be excluded
411 * from the notify. The default handler will print the new value of the property
412 * using g_print.
413 * MT safe. This function grabs and releases object's LOCK for getting its
414 * path string.
415 * object:
416 * the GObject that signalled the notify.
417 * orig:
418 * a GstObject that initiated the notify.
419 * pspec:
420 * a GParamSpec of the property.
421 * excluded_props:
422 * a set of user-specified properties to exclude or
423 * NULL to show all changes.
425 public static void defaultDeepNotify(ObjectG object, ObjectGst orig, GParamSpec* pspec, char** excludedProps)
427 // void gst_object_default_deep_notify (GObject *object, GstObject *orig, GParamSpec *pspec, gchar **excluded_props);
428 gst_object_default_deep_notify((object is null) ? null : object.getObjectGStruct(), (orig is null) ? null : orig.getObjectGstStruct(), pspec, excludedProps);
432 * A default error function.
433 * The default handler will simply print the error string using g_print.
434 * source:
435 * the GstObject that initiated the error.
436 * error:
437 * the GError.
438 * debug:
439 * an additional debug information string, or NULL.
441 public void defaultError(ErrorG error, char[] dbug)
443 // void gst_object_default_error (GstObject *source, GError *error, gchar *debug);
444 gst_object_default_error(gstObject, (error is null) ? null : error.getErrorGStruct(), Str.toStringz(dbug));
448 * Checks to see if there is any object named name in list. This function
449 * does not do any locking of any kind. You might want to protect the
450 * provided list with the lock of the owner of the list. This function
451 * will lock each GstObject in the list to compare the name, so be
452 * carefull when passing a list with a locked object.
453 * list:
454 * a list of GstObject to check through
455 * name:
456 * the name to search for
457 * Returns:
458 * TRUE if a GstObject named name does not appear in list,
459 * FALSE if it does.
460 * MT safe. Grabs and releases the LOCK of each object in the list.
462 public static int checkUniqueness(ListG list, char[] name)
464 // gboolean gst_object_check_uniqueness (GList *list, const gchar *name);
465 return gst_object_check_uniqueness((list is null) ? null : list.getListGStruct(), Str.toStringz(name));
469 * Check if object has an ancestor ancestor somewhere up in
470 * the hierarchy.
471 * object:
472 * a GstObject to check
473 * ancestor:
474 * a GstObject to check as ancestor
475 * Returns:
476 * TRUE if ancestor is an ancestor of object.
477 * MT safe. Grabs and releases object's locks.
479 public int hasAncestor(ObjectGst ancestor)
481 // gboolean gst_object_has_ancestor (GstObject *object, GstObject *ancestor);
482 return gst_object_has_ancestor(gstObject, (ancestor is null) ? null : ancestor.getObjectGstStruct());
488 * Increments the refence count on object. This function
489 * does not take the lock on object because it relies on
490 * atomic refcounting.
491 * This object returns the input parameter to ease writing
492 * constructs like :
493 * result = gst_object_ref (object->parent);
494 * object:
495 * a GstObject to reference
496 * Returns:
497 * A pointer to object
499 public static void* doref(void* object)
501 // gpointer gst_object_ref (gpointer object);
502 return gst_object_ref(object);
506 * Decrements the refence count on object. If reference count hits
507 * zero, destroy object. This function does not take the lock
508 * on object as it relies on atomic refcounting.
509 * The unref method should never be called with the LOCK held since
510 * this might deadlock the dispose function.
511 * object:
512 * a GstObject to unreference
514 public static void unref(void* object)
516 // void gst_object_unref (gpointer object);
517 gst_object_unref(object);
521 * If object was floating, the GST_OBJECT_FLOATING flag is removed
522 * and object is unreffed. When object was not floating,
523 * this function does nothing.
524 * Any newly created object has a refcount of 1 and is floating.
525 * This function should be used when creating a new object to
526 * symbolically 'take ownership' of object. This done by first doing a
527 * gst_object_ref() to keep a reference to object and then gst_object_sink()
528 * to remove and unref any floating references to object.
529 * Use gst_object_set_parent() to have this done for you.
530 * MT safe. This function grabs and releases object lock.
531 * object:
532 * a GstObject to sink
534 public static void sink(void* object)
536 // void gst_object_sink (gpointer object);
537 gst_object_sink(object);
541 * Unrefs the GstObject pointed to by oldobj, refs newobj and
542 * puts newobj in *oldobj. Be carefull when calling this
543 * function, it does not take any locks. You might want to lock
544 * the object owning oldobj pointer before calling this
545 * function.
546 * Make sure not to LOCK oldobj because it might be unreffed
547 * which could cause a deadlock when it is disposed.
548 * oldobj:
549 * pointer to a place of a GstObject to replace
550 * newobj:
551 * a new GstObject
553 public static void replace(GstObject** oldobj, ObjectGst newobj)
555 // void gst_object_replace (GstObject **oldobj, GstObject *newobj);
556 gst_object_replace(oldobj, (newobj is null) ? null : newobj.getObjectGstStruct());
560 * Generates a string describing the path of object in
561 * the object hierarchy. Only useful (or used) for debugging.
562 * object:
563 * a GstObject
564 * Returns:
565 * a string describing the path of object. You must
566 * g_free() the string after usage.
567 * MT safe. Grabs and releases the GstObject's LOCK for all objects
568 * in the hierarchy.
570 public char[] getPathString()
572 // gchar* gst_object_get_path_string (GstObject *object);
573 return Str.toString(gst_object_get_path_string(gstObject) );