@@ -995,6 +995,16 @@ const char *object_class_get_name(ObjectClass *klass);
*/
bool object_class_is_abstract(ObjectClass *klass);
+/**
+ * object_class_implements_type:
+ * @klass: The class to check the implementation for.
+ * @typename: The QOM typename of the implementation to check to.
+ *
+ * Returns: %true if @klass implements %typename, %false otherwise.
+ */
+bool object_class_implements_type(ObjectClass *class,
+ const char *typename);
+
/**
* object_class_by_name:
* @typename: The QOM typename to obtain the class for.
@@ -992,6 +992,17 @@ static ObjectClass *object_class_dynamic_cast_ambiguous(ObjectClass *class,
return ret;
}
+bool object_class_implements_type(ObjectClass *class,
+ const char *typename)
+{
+ ObjectClass *k;
+ bool ambiguous = false;
+
+ k = object_class_dynamic_cast_ambiguous(class, typename, &ambiguous);
+
+ return k || ambiguous;
+}
+
ObjectClass *object_class_dynamic_cast(ObjectClass *class,
const char *typename)
{
Add the object_class_implements_type() method to check whether a class implement a type, which can be ambiguous for interfaces. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/qom/object.h | 10 ++++++++++ qom/object.c | 11 +++++++++++ 2 files changed, 21 insertions(+)