ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkConditionalConstIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkConditionalConstIterator_h
19 #define __itkConditionalConstIterator_h
20 
21 #include "itkIndex.h"
22 
23 namespace itk
24 {
37 template< class TImage >
39 {
40 public:
43 
48  itkStaticConstMacro(NDimension, unsigned int, TImage::ImageDimension);
49 
51  typedef typename TImage::IndexType IndexType;
52 
54  typedef typename TImage::SizeType SizeType;
55 
57  typedef typename TImage::RegionType RegionType;
58 
60  typedef TImage ImageType;
61 
63  typedef typename TImage::InternalPixelType InternalPixelType;
64 
66  typedef typename TImage::PixelType PixelType;
67 
69  virtual bool IsPixelIncluded(const IndexType & index) const = 0;
70 
73  Self & operator=(const Self & it)
74  {
75  m_IsAtEnd = it.m_IsAtEnd; // copy the end flag
76  m_Image = it.m_Image; // copy the smart pointer
77  m_Region = it.m_Region; // copy the region
78  return *this;
79  }
80 
82  static unsigned int GetIteratorDimension(void)
83  {
84  return Self::NDimension;
85  }
86 
88  virtual const IndexType GetIndex() = 0;
89 
91  virtual const PixelType Get(void) const = 0;
92 
94  virtual bool IsAtEnd() = 0;
95 
97  virtual void operator++() = 0;
98 
101 
103  virtual ~ConditionalConstIterator();
104 protected: //made protected so other iterators can access
105 
107  //SmartPointer<const ImageType> m_Image;
108  typename ImageType::ConstWeakPointer m_Image;
109 
112 
114  bool m_IsAtEnd;
115 };
116 } // end namespace itk
117 
118 // Define instantiation macro for this template.
119 #define ITK_TEMPLATE_ConditionalConstIterator(_, EXPORT, TypeX, TypeY) \
120  namespace itk \
121  { \
122  _( 1 ( class EXPORT ConditionalConstIterator< ITK_TEMPLATE_1 TypeX > ) ) \
123  namespace Templates \
124  { \
125  typedef ConditionalConstIterator< ITK_TEMPLATE_1 TypeX > \
126  ConditionalConstIterator##TypeY; \
127  } \
128  }
129 
130 #if ITK_TEMPLATE_EXPLICIT
131 //HACK attempt to make static const unsigned ints work template<class TImage>
132 // const unsigned int ConditionalConstIterator<TImage>::ImageDimension;
133 #include "Templates/itkConditionalConstIterator+-.h"
134 #endif
135 
136 #if ITK_TEMPLATE_TXX
137 #include "itkConditionalConstIterator.hxx"
138 #endif
139 
140 #endif
141