gstobject: add gst_object_has_as_ancestor and deprecate previous function

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()
This commit is contained in:
Stefan Sauer 2015-05-15 13:43:12 +02:00
parent 3492105a06
commit b8c6ebd0f2
5 changed files with 46 additions and 15 deletions

View 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

View 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;
@ -841,6 +841,32 @@ gst_object_has_ancestor (GstObject * object, GstObject * ancestor)
return FALSE;
}
/**
* 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

View 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);

View 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;

View 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