From 053adf87d6f06ee56378e9a614843787e2d9d336 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 28 Jun 2005 09:13:24 +0000 Subject: [PATCH] Implement level() method for the SUIT_DataObject class --- src/SUIT/SUIT_DataObject.cxx | 16 ++++++++++++++++ src/SUIT/SUIT_DataObject.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/SUIT/SUIT_DataObject.cxx b/src/SUIT/SUIT_DataObject.cxx index c4f31bb0e..839fffdee 100755 --- a/src/SUIT/SUIT_DataObject.cxx +++ b/src/SUIT/SUIT_DataObject.cxx @@ -123,6 +123,22 @@ SUIT_DataObject* SUIT_DataObject::childObject( const int idx ) const return child; } +/*! + Returns the level of the object in the data tree. + 0 means that object is top-level. +*/ + +int SUIT_DataObject::level() const +{ + int lev = 0; + SUIT_DataObject* p = parent(); + while ( p ) { + p = p->parent(); + lev++; + } + return lev; +} + /*! Returns the next data object in the child list of the parent. */ diff --git a/src/SUIT/SUIT_DataObject.h b/src/SUIT/SUIT_DataObject.h index cc4cf374c..eef2fb87b 100755 --- a/src/SUIT/SUIT_DataObject.h +++ b/src/SUIT/SUIT_DataObject.h @@ -36,6 +36,7 @@ public: int childCount() const; int childPos( const SUIT_DataObject* ) const; SUIT_DataObject* childObject( const int ) const; + int level() const; SUIT_DataObject* nextBrother() const; SUIT_DataObject* prevBrother() const; -- 2.39.2