From patchwork Thu Jul 11 01:46:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 258279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AD11B2C02F4 for ; Thu, 11 Jul 2013 11:51:57 +1000 (EST) Received: from localhost ([::1]:49963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ux631-0004a8-KT for incoming@patchwork.ozlabs.org; Wed, 10 Jul 2013 21:51:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ux62j-0004Wj-QN for qemu-devel@nongnu.org; Wed, 10 Jul 2013 21:51:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ux62i-0005pR-VH for qemu-devel@nongnu.org; Wed, 10 Jul 2013 21:51:37 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:35010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ux62i-0005pH-P9 for qemu-devel@nongnu.org; Wed, 10 Jul 2013 21:51:36 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa11so7285173pad.5 for ; Wed, 10 Jul 2013 18:51:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=im+jUMBOfZU7BlqjLyl9c7s35E5V47zbb5rcd48pLs4=; b=cf8aZmz7BMadFKKTZ6kiNKSnd058BDWzmuweM3GzW7Y+DMy3b7v06iQ3UmSErP6lNa YbQaG5t4QBkEPT+xIMuOBJ2widdLw6vO5+xQeMi+othUvVFB74EW95mHZqQeEPAmaJWk aHuzQpvbE6CKEqyM5t4t6/KxuLuZY1MW1FZRJjhEbq0rKMcbzeaFCDe4PWSVycv4Vt1I H5OzRlvUlQcygVjey6FC5R8mvQ4X49S9tiX6wiPCPj+t7UN0s0foj2iLVnJISq9ycXaT 69k7udNFzsg2bdy/HZt2OqJSCzKPxRHY9AcKL9kD06vihtvmf5QxtbOi/aen+KxUyvxE Ip1w== X-Received: by 10.66.141.104 with SMTP id rn8mr35914248pab.52.1373507495946; Wed, 10 Jul 2013 18:51:35 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id bg3sm36626835pbb.44.2013.07.10.18.51.31 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 10 Jul 2013 18:51:34 -0700 (PDT) From: peter.crosthwaite@xilinx.com To: afaerber@suse.de Date: Thu, 11 Jul 2013 11:46:36 +1000 Message-Id: <5a8e017911bb208d69bd476c129c107ee1d7c0df.1373440128.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty In-Reply-To: References: X-Gm-Message-State: ALoCoQmj8KVqvqcqttNYzv19G2rzKyiIJLkT5ZigLoTm2lNIZ97SuSOpDUhhn+y6p5Fv7I5JQPn4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.220.46 Cc: hutao@cn.fujitsu.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, mst@redhat.com Subject: [Qemu-devel] [PATCH qom-next v2 2/5] qom/object: Add object_class_get_parent_by_name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite Function for looking up a class by name then getting its parent. Signed-off-by: Peter Crosthwaite --- 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);