ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkThreadedIteratorRangePartitioner.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 itkThreadedIteratorRangePartitioner_h
19 #define itkThreadedIteratorRangePartitioner_h
20 
22 #include "itkObjectFactory.h"
23 
24 namespace itk
25 {
26 
27 // Forward reference because of circular dependencies
28 template< typename TIterator >
29 class ITK_TEMPLATE_EXPORT ThreadedIteratorRangePartitioner;
30 
38 template< typename TIterator >
39 class ITK_TEMPLATE_EXPORT ThreadedIteratorRangePartitionerDomain
40 {
41 public:
42  using IteratorType = TIterator;
44 
46 
48  {
49  this->m_Begin = begin;
50  this->m_End = end;
51  }
52 
54  {
55  this->m_Begin = rhs.m_Begin;
56  this->m_End = rhs.m_End;
57  }
58 
59  void operator=( const Self & rhs )
60  {
61  if ( this == & rhs )
62  {
63  return;
64  }
65  this->m_Begin = rhs.m_Begin;
66  this->m_End = rhs.m_End;
67  }
68 
69  const IteratorType & Begin() const
70  {
71  return this->m_Begin;
72  }
73  const IteratorType & End() const
74  {
75  return this->m_End;
76  }
77 
78 private:
82 };
83 
108 template< typename TIterator >
109 class ITK_TEMPLATE_EXPORT ThreadedIteratorRangePartitioner
110  : public ThreadedDomainPartitioner< ThreadedIteratorRangePartitionerDomain< TIterator > >
111 {
112 public:
113  ITK_DISALLOW_COPY_AND_ASSIGN(ThreadedIteratorRangePartitioner);
114 
120 
122  itkNewMacro(Self);
123 
126 
128  using DomainType = typename Superclass::DomainType;
129 
130  using IteratorType = TIterator;
131 
144  ThreadIdType PartitionDomain(const ThreadIdType threadId,
145  const ThreadIdType requestedTotal,
146  const DomainType& completeDomain,
147  DomainType& subDomain) const override;
148 
149 protected:
151  ~ThreadedIteratorRangePartitioner() override = default;
152 };
153 
154 } // end namespace itk
155 
156 #ifndef ITK_MANUAL_INSTANTIATION
157 #include "itkThreadedIteratorRangePartitioner.hxx"
158 #endif
159 
160 #endif
Light weight base class for most itk classes.
class ITK_TEMPLATE_EXPORT ThreadedIteratorRangePartitioner
Virtual base class for partitioning a domain into subsets to be processed per thread when parallel pr...
ThreadedIteratorRangePartitionerDomain(const IteratorType &begin, const IteratorType &end)
Partitions an iterator range for threading.
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
Domain type for the ThreadedIteratorRangePartitioner.