Patchwork [qom-next,v2,2/5] qom/object: Add object_class_get_parent_by_name

login
register
mail settings
Submitter Peter Crosthwaite
Date July 11, 2013, 1:46 a.m.
Message ID <5a8e017911bb208d69bd476c129c107ee1d7c0df.1373440128.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/258279/
State New
Headers show

Comments

Peter Crosthwaite - July 11, 2013, 1:46 a.m.
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Function for looking up a class by name then getting its parent.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 include/qom/object.h | 9 +++++++++
 qom/object.c         | 5 +++++
 2 files changed, 14 insertions(+)

Patch

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