gstobject: add gst_object_has_as_ancestor and deprecate previous function
authorStefan Sauer <ensonic@users.sf.net>
Fri, 15 May 2015 11:43:12 +0000 (13:43 +0200)
committerStefan Sauer <ensonic@users.sf.net>
Fri, 15 May 2015 11:55:19 +0000 (13:55 +0200)
The old gst_object_has_ancestor will call the new code. This establishes the
symetry with the new gst_object_has_as_parent.

API: gst_object_has_as_ancestor()

docs/gst/gstreamer-sections.txt
gst/gstobject.c
gst/gstobject.h
tests/check/gst/gstobject.c
win32/common/libgstreamer.def

index 403c72f..dba70f5 100644 (file)
@@ -1712,6 +1712,7 @@ gst_object_unparent
 gst_object_default_deep_notify
 gst_object_default_error
 gst_object_check_uniqueness
+gst_object_has_as_ancestor
 gst_object_has_ancestor
 gst_object_ref
 gst_object_unref
index c24e435..1f58c8d 100644 (file)
@@ -807,7 +807,7 @@ gst_object_has_as_parent (GstObject * object, GstObject * parent)
 }
 
 /**
- * gst_object_has_ancestor:
+ * gst_object_has_as_ancestor:
  * @object: a #GstObject to check
  * @ancestor: a #GstObject to check as ancestor
  *
@@ -819,7 +819,7 @@ gst_object_has_as_parent (GstObject * object, GstObject * parent)
  * MT safe. Grabs and releases @object's locks.
  */
 gboolean
-gst_object_has_ancestor (GstObject * object, GstObject * ancestor)
+gst_object_has_as_ancestor (GstObject * object, GstObject * ancestor)
 {
   GstObject *parent, *tmp;
 
@@ -842,6 +842,32 @@ gst_object_has_ancestor (GstObject * object, GstObject * ancestor)
 }
 
 /**
+ * gst_object_has_ancestor:
+ * @object: a #GstObject to check
+ * @ancestor: a #GstObject to check as ancestor
+ *
+ * Check if @object has an ancestor @ancestor somewhere up in
+ * the hierarchy. One can e.g. check if a #GstElement is inside a #GstPipeline.
+ *
+ * Returns: %TRUE if @ancestor is an ancestor of @object.
+ *
+ * Deprecated: Use gst_object_has_as_ancestor() instead.
+ *
+ * MT safe. Grabs and releases @object's locks.
+ */
+/* FIXME 2.0: remove */
+#ifndef GST_REMOVE_DEPRECATED
+#ifdef GST_DISABLE_DEPRECATED
+gboolean gst_object_has_ancestor (GstObject * object, GstObject * ancestor);
+#endif
+gboolean
+gst_object_has_ancestor (GstObject * object, GstObject * ancestor)
+{
+  return gst_object_has_as_ancestor (object, ancestor);
+}
+#endif
+
+/**
  * gst_object_check_uniqueness:
  * @list: (transfer none) (element-type Gst.Object): a list of #GstObject to
  *      check through
index 6c41a69..b478f3b 100644 (file)
@@ -213,7 +213,10 @@ gboolean   gst_object_set_parent           (GstObject *object, GstObject *parent);
 GstObject*     gst_object_get_parent           (GstObject *object);
 void           gst_object_unparent             (GstObject *object);
 gboolean       gst_object_has_as_parent                (GstObject *object, GstObject *parent);
+gboolean       gst_object_has_as_ancestor      (GstObject *object, GstObject *ancestor);
+#ifndef GST_DISABLE_DEPRECATED
 gboolean       gst_object_has_ancestor         (GstObject *object, GstObject *ancestor);
+#endif
 
 void            gst_object_default_deep_notify  (GObject *object, GstObject *orig,
                                                  GParamSpec *pspec, gchar **excluded_props);
index e405566..f88579d 100644 (file)
@@ -456,7 +456,7 @@ GST_START_TEST (test_fake_object_parentage_dispose)
 
 GST_END_TEST;
 
-GST_START_TEST (test_fake_object_has_ancestor)
+GST_START_TEST (test_fake_object_has_as_ancestor)
 {
   GstObject *object1, *object2, *object3, *object4;
   gboolean result;
@@ -490,40 +490,40 @@ GST_START_TEST (test_fake_object_has_ancestor)
 
   /* An object isn't its own parent, but it is its own ancestor */
   fail_if (gst_object_has_as_parent (object1, object1));
-  fail_unless (gst_object_has_ancestor (object1, object1));
+  fail_unless (gst_object_has_as_ancestor (object1, object1));
 
   fail_if (gst_object_has_as_parent (object4, object4));
-  fail_unless (gst_object_has_ancestor (object4, object4));
+  fail_unless (gst_object_has_as_ancestor (object4, object4));
 
   /* direct parents */
   fail_unless (gst_object_has_as_parent (object1, object3));
-  fail_unless (gst_object_has_ancestor (object1, object3));
+  fail_unless (gst_object_has_as_ancestor (object1, object3));
 
   fail_unless (gst_object_has_as_parent (object2, object3));
-  fail_unless (gst_object_has_ancestor (object2, object3));
+  fail_unless (gst_object_has_as_ancestor (object2, object3));
 
   fail_unless (gst_object_has_as_parent (object3, object4));
-  fail_unless (gst_object_has_ancestor (object3, object4));
+  fail_unless (gst_object_has_as_ancestor (object3, object4));
 
   /* grandparents */
   fail_if (gst_object_has_as_parent (object1, object4));
-  fail_unless (gst_object_has_ancestor (object1, object4));
+  fail_unless (gst_object_has_as_ancestor (object1, object4));
 
   fail_if (gst_object_has_as_parent (object2, object4));
-  fail_unless (gst_object_has_ancestor (object2, object4));
+  fail_unless (gst_object_has_as_ancestor (object2, object4));
 
   /* not ancestors */
   fail_if (gst_object_has_as_parent (object1, object2));
-  fail_if (gst_object_has_ancestor (object1, object2));
+  fail_if (gst_object_has_as_ancestor (object1, object2));
 
   fail_if (gst_object_has_as_parent (object3, object1));
-  fail_if (gst_object_has_ancestor (object3, object1));
+  fail_if (gst_object_has_as_ancestor (object3, object1));
 
   fail_if (gst_object_has_as_parent (object4, object1));
-  fail_if (gst_object_has_ancestor (object4, object1));
+  fail_if (gst_object_has_as_ancestor (object4, object1));
 
   fail_if (gst_object_has_as_parent (object4, object3));
-  fail_if (gst_object_has_ancestor (object4, object3));
+  fail_if (gst_object_has_as_ancestor (object4, object3));
 
   /* unparent everything */
   gst_object_unparent (object3);
@@ -558,7 +558,7 @@ gst_object_suite (void)
   tcase_add_test (tc_chain, test_fake_object_parentage);
   tcase_add_test (tc_chain, test_fake_object_parentage_dispose);
 
-  tcase_add_test (tc_chain, test_fake_object_has_ancestor);
+  tcase_add_test (tc_chain, test_fake_object_has_as_ancestor);
   //tcase_add_checked_fixture (tc_chain, setup, teardown);
 
   return s;
index fbccec0..04df312 100644 (file)
@@ -781,6 +781,7 @@ EXPORTS
        gst_object_get_value_array
        gst_object_has_active_control_bindings
        gst_object_has_ancestor
+       gst_object_has_as_ancestor
        gst_object_has_as_parent
        gst_object_ref
        gst_object_ref_sink