ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkChildTreeIterator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkChildTreeIterator_h
00019 #define __itkChildTreeIterator_h
00020 
00021 #include "itkTreeIteratorBase.h"
00022 
00023 namespace itk
00024 {
00025 template< class TTreeType >
00026 class ChildTreeIterator:public TreeIteratorBase< TTreeType >
00027 {
00028 public:
00029 
00031   typedef ChildTreeIterator                       Self;
00032   typedef TreeIteratorBase< TTreeType >           Superclass;
00033   typedef TTreeType                               TreeType;
00034   typedef typename TTreeType::ValueType           ValueType;
00035   typedef typename Superclass::TreeNodeType       TreeNodeType;
00036   typedef typename TreeNodeType::ChildIdentifier  ChildIdentifier;
00037   typedef typename Superclass::NodeType           NodeType;
00038 
00040   ChildTreeIterator(TreeType *tree, const TreeNodeType *start = NULL);
00041 
00043   ChildTreeIterator(const TreeIteratorBase< TTreeType > & iterator);
00044 
00046   NodeType GetType() const;
00047 
00049   virtual bool GoToChild(ChildIdentifier number = 0);
00050 
00052   virtual bool GoToParent();
00053 
00055   TreeIteratorBase< TTreeType > * Clone();
00056 
00058   Self & operator=(Superclass & iterator)
00059   {
00060     Superclass::operator=(iterator);
00061     ChildTreeIterator< TTreeType > & it =
00062       static_cast< ChildTreeIterator< TTreeType > & >( iterator );
00063     m_ListPosition = it.m_ListPosition;
00064     m_ParentNode = it.m_ParentNode;
00065     return *this;
00066   }
00068 
00069 protected:
00070 
00072   const ValueType & Next();
00073 
00075   bool HasNext() const;
00076 
00077 private:
00078 
00079   mutable ChildIdentifier  m_ListPosition;
00080   TreeNodeType *           m_ParentNode;
00081 };
00082 
00083 } // end namespace itk
00084 
00085 #if ITK_TEMPLATE_TXX
00086 #include "itkChildTreeIterator.hxx"
00087 #endif
00088 
00089 #endif
00090