ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkProgressAccumulator.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 __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  typedef Object Superclass;
49 
53 
55  itkNewMacro(Self);
56 
58  itkTypeMacro(ProgressAccumulator, Object);
59 
61  itkGetConstMacro(AccumulatedProgress, float);
62 
64  itkSetObjectMacro(MiniPipelineFilter, ProcessObject);
65 
67  itkGetConstObjectMacro(MiniPipelineFilter, ProcessObject);
68 
73  void RegisterInternalFilter(GenericFilterType *filter, float weight);
74 
78  void UnregisterAllFilters();
79 
85  void ResetProgress();
86 
87  void ResetFilterProgressAndKeepAccumulatedProgress();
88 
89 protected:
91  virtual ~ProgressAccumulator();
92  void PrintSelf(std::ostream & s, Indent indent) const;
93 
94 private:
98 
100  struct FilterRecord {
101  // Pointer to the filter
103 
104  // The weight of the filter in total progress of the mini-pipeline
105  float Weight;
106 
107  // The tags for adding/removing observers to mini-pipeline filter
108  unsigned long ProgressObserverTag;
109  unsigned long IterationObserverTag;
110 
111  // The progress accumulated by the filter since last Reset()
112  float Progress;
113  };
114 
116  void ReportProgress(Object *object, const EventObject & event);
117 
120 
122  typedef std::vector< struct FilterRecord > FilterRecordVector;
123 
126 
129 
135 
138 };
139 } // End namespace itk
140 
141 #endif // __itkProgressAccumulator_h_
142