]> Creatis software - clitk.git/blobdiff - common/clitkFilterBase.h
minor fixes
[clitk.git] / common / clitkFilterBase.h
index 7c3922a95a2822e625e5ee6e7421c105a589bc28..a53a181490b07ab0180e34b7d2e7c1b2e09ac879 100644 (file)
@@ -21,6 +21,7 @@
 
 // clitk
 #include "clitkCommon.h"
+#include "clitkTimer.h"
 #include "clitkFilterMacros.txx"
 #include "clitkLabelizeParameters.h"
 
@@ -60,6 +61,8 @@ namespace clitk {
     GGO_DefineOption_Flag(verboseOption, SetVerboseOption);
 
     // Steps management
+    itkSetMacro(NumberOfSteps, int);
+    itkGetConstMacro(NumberOfSteps, int);
     itkSetMacro(VerboseStep, bool);
     itkGetConstMacro(VerboseStep, bool);
     itkBooleanMacro(VerboseStep);
@@ -76,6 +79,8 @@ namespace clitk {
     itkGetConstMacro(CurrentStepId, std::string);
     itkSetMacro(CurrentStepBaseId, std::string);
     itkGetConstMacro(CurrentStepBaseId, std::string);
+    itkSetMacro(CurrentStepName, std::string);
+    itkGetConstMacro(CurrentStepName, std::string);
 
     // Convenient function for verbose option
     template<class OptionType>
@@ -101,6 +106,10 @@ namespace clitk {
     itkBooleanMacro(VerboseWarningOff);
     GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff);
     
+    // Use this function to stop (when threaded)
+    void SetMustStop(bool b);
+    bool GetMustStop();
+    
   protected:
     FilterBase();
     virtual ~FilterBase() {}    
@@ -113,12 +122,16 @@ namespace clitk {
     bool m_VerboseStep;
     bool m_WriteStep;
     int m_CurrentStepNumber;
+    int m_NumberOfSteps;
     std::string m_CurrentStepId;
     std::string m_CurrentStepBaseId;
     std::string m_LastError;
+    std::string m_CurrentStepName;
     bool m_StopOnError;
     std::string m_Warning;
     bool m_VerboseWarningOff;
+    bool m_MustStop;
+    Timer m_CurrentStepTimer;
 
   private:
     FilterBase(const Self&); //purposely not implemented
@@ -130,6 +143,8 @@ namespace clitk {
 } // end namespace clitk
 //--------------------------------------------------------------------
 
+#define StartNewStepOrStop(s) StartNewStep(s); if (GetMustStop()) return;
+
 #ifndef ITK_MANUAL_INSTANTIATION
 #include "clitkFilterBase.txx"
 #endif