From: Peter Crosthwaite <peter.crosthwa...@xilinx.com> Function for looking up a class by name then getting its parent.
Signed-off-by: Peter Crosthwaite <peter.crosthwa...@xilinx.com> --- include/qom/object.h | 9 +++++++++ qom/object.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 23fc048..f5ce2e8 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -706,6 +706,15 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass, ObjectClass *object_class_get_parent(ObjectClass *klass); /** + * object_class_get_parent_by_name: + * Lookup a class by name and get its parent. + * @typename: The class to lookup and obtain the parent for. + * + * Returns: The parent for @typename's class or %NULL if none. + */ +ObjectClass *object_class_get_parent_by_name(const char *typename); + +/** * object_class_get_name: * @klass: The class to obtain the QOM typename for. * diff --git a/qom/object.c b/qom/object.c index cbd7e86..4a3197d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -608,6 +608,11 @@ ObjectClass *object_class_get_parent(ObjectClass *class) return type->class; } +ObjectClass *object_class_get_parent_by_name(const char *typename) +{ + return object_class_get_parent(object_class_by_name(typename)); +} + typedef struct OCFData { void (*fn)(ObjectClass *klass, void *opaque); -- 1.8.3.rc1.44.gb387c77.dirty