Patchwork qom: Introduce object_class_is_abstract()

login
register
mail settings
Submitter Andreas Färber
Date Jan. 28, 2012, 5:51 p.m.
Message ID <1327773079-31169-1-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/138399/
State New
Headers show

Comments

Andreas Färber - Jan. 28, 2012, 5:51 p.m.
Since struct TypeImpl is not public, this is useful for enumerating
available types.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/qemu/object.h |    8 ++++++++
 qom/object.c          |    5 +++++
 2 files changed, 13 insertions(+), 0 deletions(-)
Andreas Färber - Jan. 28, 2012, 6:24 p.m.
Am 28.01.2012 18:51, schrieb Andreas Färber:
> Since struct TypeImpl is not public, this is useful for enumerating
> available types.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>

BTW Anthony, this cc-less patch shows that an entry is missing in
MAINTAINERS. Could you please add an appropriate one? Thanks!

Andreas

Patch

diff --git a/include/qemu/object.h b/include/qemu/object.h
index ba37850..8ec45f2 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -428,6 +428,14 @@  ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
  */
 const char *object_class_get_name(ObjectClass *klass);
 
+/**
+ * object_class_is_abstract:
+ * @klass: The class to obtain the abstractness for.
+ *
+ * Returns: Whether @klass is an abstract class or not.
+ */
+bool object_class_is_abstract(ObjectClass *klass);
+
 ObjectClass *object_class_by_name(const char *typename);
 
 void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
diff --git a/qom/object.c b/qom/object.c
index 57cc592..1821959 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -451,6 +451,11 @@  const char *object_class_get_name(ObjectClass *klass)
     return klass->type->name;
 }
 
+bool object_class_is_abstract(ObjectClass *klass)
+{
+    return klass->type->abstract;
+}
+
 ObjectClass *object_class_by_name(const char *typename)
 {
     TypeImpl *type = type_get_by_name(typename);