Back to index

salome-kernel  6.5.0
SALOMEDSImpl_ChildNodeIterator.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:        SALOMEDSImpl_ChildNodeIterator.cxx
00024 // Created:     Wed Jan 26 16:43:08 2000
00025 // Author:      Denis PASCAL
00026 //              <dp@dingox.paris1.matra-dtv.fr>
00027 //
00028 #include "SALOMEDSImpl_ChildNodeIterator.hxx"
00029 
00030 #define ChildNodeIterator_UpToBrother \
00031 { \
00032     while (myNode && (myNode->Depth() > myFirstLevel) && myNode->myNext == NULL) \
00033       myNode = myNode->myFather; \
00034         if (myNode && (myNode->Depth() > myFirstLevel) && myNode->myFather != NULL) \
00035           myNode = myNode->myNext; \
00036         else \
00037           myNode = NULL; \
00038 }
00039 
00040 //=======================================================================
00041 //function : SALOMEDSImpl_ChildNodeIterator
00042 //purpose  : 
00043 //=======================================================================
00044 SALOMEDSImpl_ChildNodeIterator::SALOMEDSImpl_ChildNodeIterator()
00045      : myFirstLevel(0)
00046 {}
00047 
00048 //=======================================================================
00049 //function : SALOMEDSImpl_ChildNodeIterator
00050 //purpose  : 
00051 //=======================================================================
00052 
00053 SALOMEDSImpl_ChildNodeIterator::SALOMEDSImpl_ChildNodeIterator (const SALOMEDSImpl_AttributeTreeNode* aNode,
00054                                                                 const bool allLevels)
00055 : myNode(aNode->myFirst),
00056   myFirstLevel(allLevels ? aNode->Depth() : -1)
00057 {}
00058 
00059 //=======================================================================
00060 //function : Initialize
00061 //purpose  : 
00062 //=======================================================================
00063 
00064 void SALOMEDSImpl_ChildNodeIterator::Initialize(const SALOMEDSImpl_AttributeTreeNode* aNode,
00065                                                 const bool allLevels)
00066 {
00067   myNode = aNode->myFirst;
00068   myFirstLevel = allLevels ? aNode->Depth() : -1;
00069 }
00070 
00071 //=======================================================================
00072 //function : Next
00073 //purpose  : 
00074 //=======================================================================
00075 
00076 void SALOMEDSImpl_ChildNodeIterator::Next() 
00077 {
00078   if (myFirstLevel == -1) {
00079     myNode = myNode->myNext;
00080   }
00081   else {
00082     if (myNode->myFirst != NULL) myNode = myNode->myFirst;
00083     else ChildNodeIterator_UpToBrother;
00084   }
00085 }
00086 
00087 //=======================================================================
00088 //function : NextBrother
00089 //purpose  : 
00090 //=======================================================================
00091 
00092 void SALOMEDSImpl_ChildNodeIterator::NextBrother() 
00093 {
00094   if (myNode->myNext != NULL) myNode = myNode->myNext;
00095   else ChildNodeIterator_UpToBrother;
00096 }