ITK  6.0.0
Insight Toolkit
itkProgressAccumulator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 itkProgressAccumulator_h
19 #define itkProgressAccumulator_h
20 
21 #include "itkCommand.h"
22 #include "itkProcessObject.h"
23 #include <vector>
24 
25 namespace itk
26 {
40 class ITKCommon_EXPORT ProgressAccumulator : public Object
41 {
42 public:
43 
46  using Superclass = Object;
49 
53 
55  itkNewMacro(Self);
56 
58  itkOverrideGetNameOfClassMacro(ProgressAccumulator);
59 
61  itkGetConstMacro(AccumulatedProgress, float);
62 
64  itkSetObjectMacro(MiniPipelineFilter, ProcessObject);
65 
67  itkGetModifiableObjectMacro(MiniPipelineFilter, ProcessObject);
68 
82  void
83  RegisterInternalFilter(GenericFilterType * filter, float weight);
84 
88  void
89  UnregisterAllFilters();
90 
97 #if !defined(ITK_LEGACY_REMOVE)
98  void
99  ResetProgress();
100 #endif
101 
114 #if !defined(ITK_LEGACY_REMOVE)
115  void
116  ResetFilterProgressAndKeepAccumulatedProgress();
117 #endif
118 
119 protected:
121  ~ProgressAccumulator() override;
122  void
123  PrintSelf(std::ostream & os, Indent indent) const override;
124 
125 private:
129 
132  {
133  // Pointer to the filter
135 
136  // The weight of the filter in total progress of the mini-pipeline
137  float Weight;
138 
139  // The tags for adding/removing observers to mini-pipeline filter
140  unsigned long ProgressObserverTag;
141  unsigned long StartObserverTag;
142 
143  float AccumulatedProgress{ 0.0 };
144  };
145 
147  void
148  ReportProgress(Object * who, const EventObject & event);
149 
151  GenericFilterPointer m_MiniPipelineFilter{};
152 
154  using FilterRecordVector = std::vector<struct FilterRecord>;
155 
157  float m_AccumulatedProgress{};
158 
160  float m_BaseAccumulatedProgress{};
161 
166  FilterRecordVector m_FilterRecord{};
167 
169  CommandPointer m_CallbackCommand{};
170 };
171 } // End namespace itk
172 
173 #endif // itkProgressAccumulator_h_
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::ProgressAccumulator::FilterRecord::Filter
GenericFilterPointer Filter
Definition: itkProgressAccumulator.h:134
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ProgressAccumulator::FilterRecord::Weight
float Weight
Definition: itkProgressAccumulator.h:137
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkProcessObject.h
itk::ProgressAccumulator
Facilitates progress reporting for filters that wrap around multiple other filters.
Definition: itkProgressAccumulator.h:40
itk::MemberCommand
A Command subclass that calls a pointer to a member function.
Definition: itkCommand.h:86
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProgressAccumulator::FilterRecord
Definition: itkProgressAccumulator.h:131
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::ProcessObject
class ITK_FORWARD_EXPORT ProcessObject
Definition: itkDataObject.h:41
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::EventObject
Abstraction of the Events used to communicating among filters and with GUIs.
Definition: itkEventObject.h:58
itkCommand.h
itk::ProgressAccumulator::FilterRecord::StartObserverTag
unsigned long StartObserverTag
Definition: itkProgressAccumulator.h:141
itk::ProgressAccumulator::FilterRecord::ProgressObserverTag
unsigned long ProgressObserverTag
Definition: itkProgressAccumulator.h:140
itk::ProgressAccumulator::FilterRecordVector
std::vector< struct FilterRecord > FilterRecordVector
Definition: itkProgressAccumulator.h:154