From b5bfc150e3dcd5a7b29f7e8f17c77f20e016820d Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 17 Mar 2008 11:55:46 -0700 Subject: [PATCH] add TypeId::IsChildOf --- src/core/type-id.cc | 10 ++++++++++ src/core/type-id.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/core/type-id.cc b/src/core/type-id.cc index 61a443edb..562cd7513 100644 --- a/src/core/type-id.cc +++ b/src/core/type-id.cc @@ -475,6 +475,16 @@ TypeId::GetParent (void) const uint16_t parent = Singleton::Get ()->GetParent (m_tid); return TypeId (parent); } +bool +TypeId::IsChildOf (TypeId other) const +{ + TypeId tmp = *this; + while (tmp != other && tmp != tmp) + { + tmp = tmp.GetParent (); + } + return tmp == other; +} std::string TypeId::GetGroupName (void) const { diff --git a/src/core/type-id.h b/src/core/type-id.h index 4a4ffe8da..ab649e36c 100644 --- a/src/core/type-id.h +++ b/src/core/type-id.h @@ -90,6 +90,8 @@ public: */ TypeId GetParent (void) const; + bool IsChildOf (TypeId other) const; + /** * \returns the name of the group associated to this TypeId. */