ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkDataObjectConstIterator.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 __itkDataObjectConstIterator_h
00019 #define __itkDataObjectConstIterator_h
00020 
00021 #include "itkProcessObject.h"
00022 
00023 namespace itk
00024 {
00030 class DataObjectConstIterator
00031 {
00032 public:
00033 
00034   typedef DataObject::DataObjectIdentifierType DataObjectIdentifierType;
00035 
00036   DataObjectConstIterator() {}
00037 
00038   DataObjectConstIterator(const DataObjectConstIterator & iter)
00039   {
00040     m_Iterator = iter.m_Iterator;
00041     m_Begin = iter.m_Begin;
00042     m_End = iter.m_End;
00043   }
00044 
00045   DataObjectConstIterator & operator=(const DataObjectConstIterator & iter)
00046   {
00047     m_Iterator = iter.m_Iterator;
00048     m_Begin = iter.m_Begin;
00049     m_End = iter.m_End;
00050     return *this;
00051   }
00052 
00053   const DataObject * GetDataObject() const
00054   {
00055     return m_Iterator->second;
00056   }
00057 
00058   const DataObjectIdentifierType & GetName() const
00059   {
00060     return m_Iterator->first;
00061   }
00062 
00063   DataObjectConstIterator operator++(int)
00064   {
00065     DataObjectConstIterator tmp = *this;
00066     ++(*this);
00067     return tmp;
00068   }
00069 
00070   DataObjectConstIterator & operator++()
00071   {
00072     ++m_Iterator;
00073     return *this;
00074   }
00075 
00076   bool operator==(const DataObjectConstIterator & iter) const
00077     {
00078     return m_Iterator == iter.m_Iterator && m_Begin == iter.m_Begin && m_End == iter.m_End;
00079     }
00080 
00081   bool operator!=(const DataObjectConstIterator & iter) const
00082     {
00083     return !( *this == iter );
00084     }
00085 
00086   void GoToBegin()
00087     {
00088       m_Iterator = m_Begin;
00089     }
00090 
00091     bool IsAtEnd() const
00092     {
00093       return m_Iterator == m_End;
00094     }
00095 
00096 protected:
00097   typedef ProcessObject::DataObjectPointerMap::const_iterator InternalIteratorType;
00098   InternalIteratorType m_Iterator;
00099   InternalIteratorType m_Begin;
00100   InternalIteratorType m_End;
00101 };
00102 }
00103 #endif
00104