00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkProgressAccumulator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/11/17 22:41:08 $ 00007 Version: $Revision: 1.10 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkProgressAccumulator_h_ 00018 #define __itkProgressAccumulator_h_ 00019 00020 #include "itkCommand.h" 00021 #include "itkObject.h" 00022 #include "itkProcessObject.h" 00023 #include <vector> 00024 00025 namespace itk { 00026 00039 class ITKCommon_EXPORT ProgressAccumulator : public Object 00040 { 00041 public: 00042 00044 typedef ProgressAccumulator Self; 00045 typedef Object Superclass; 00046 typedef SmartPointer<Self> Pointer; 00047 typedef SmartPointer<const Self> ConstPointer; 00048 00050 typedef ProcessObject GenericFilterType; 00051 typedef GenericFilterType::Pointer GenericFilterPointer; 00052 00054 itkNewMacro(Self); 00055 00057 itkTypeMacro(ProgressAccumulator,Object); 00058 00060 itkGetMacro(AccumulatedProgress,float); 00061 00063 itkSetObjectMacro(MiniPipelineFilter,ProcessObject); 00064 00066 itkGetConstObjectMacro(MiniPipelineFilter,ProcessObject); 00067 00072 void RegisterInternalFilter(GenericFilterType *filter, float weight); 00073 00077 void UnregisterAllFilters(); 00078 00084 void ResetProgress(); 00085 void ResetFilterProgressAndKeepAccumulatedProgress(); 00087 00088 protected: 00089 ProgressAccumulator(); 00090 virtual ~ProgressAccumulator(); 00091 void PrintSelf(std::ostream &s, Indent indent) const; 00092 00093 private: 00095 typedef MemberCommand< Self > CommandType; 00096 typedef CommandType::Pointer CommandPointer; 00097 00099 struct FilterRecord 00100 { 00101 // Pointer to the filter 00102 GenericFilterPointer Filter; 00103 00104 // The weight of the filter in total progress of the mini-pipeline 00105 float Weight; 00106 00107 // The tags for adding/removing observers to mini-pipeline filter 00108 unsigned long ProgressObserverTag; 00109 unsigned long IterationObserverTag; 00110 00111 // The progress accumulated by the filter since last Reset() 00112 float Progress; 00113 }; 00114 00116 void ReportProgress(Object * object, const EventObject & event); 00117 00119 GenericFilterPointer m_MiniPipelineFilter; 00120 00122 typedef std::vector<struct FilterRecord> FilterRecordVector; 00123 00125 float m_AccumulatedProgress; 00126 00128 float m_BaseAccumulatedProgress; 00129 00134 FilterRecordVector m_FilterRecord; 00135 00137 CommandPointer m_CallbackCommand; 00138 }; 00139 00140 } // End namespace itk 00141 00142 #endif // __itkProgressAccumulator_h_ 00143 00144