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é <phi...@linaro.org> --- include/qom/object.h | 10 ++++++++++ qom/object.c | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 9192265db76..fd74d4be89f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -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. diff --git a/qom/object.c b/qom/object.c index 1620a87ef44..b9948937935 100644 --- a/qom/object.c +++ b/qom/object.c @@ -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) { -- 2.47.1