qom: Introduce object_class_is_abstract()

This lets a caller check if an ObjectClass as returned by, e.g.,
object_class_by_name() is instantiatable.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
This commit is contained in:
Andreas Färber 2013-01-23 12:20:18 +01:00
parent d89e12188d
commit 1786237894
2 changed files with 13 additions and 0 deletions

View File

@ -690,6 +690,14 @@ ObjectClass *object_class_get_parent(ObjectClass *klass);
*/
const char *object_class_get_name(ObjectClass *klass);
/**
* object_class_is_abstract:
* @klass: The class to obtain the abstractness for.
*
* Returns: %true if @klass is abstract, %false otherwise.
*/
bool object_class_is_abstract(ObjectClass *klass);
/**
* object_class_by_name:
* @typename: The QOM typename to obtain the class for.

View File

@ -501,6 +501,11 @@ ObjectClass *object_get_class(Object *obj)
return obj->class;
}
bool object_class_is_abstract(ObjectClass *klass)
{
return klass->type->abstract;
}
const char *object_class_get_name(ObjectClass *klass)
{
return klass->type->name;