1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
19 #ifndef CLITKFILTERBASE_H
20 #define CLITKFILTERBASE_H
23 #include "clitkCommon.h"
24 #include "clitkTimer.h"
25 #include "clitkFilterMacros.txx"
26 #include "clitkLabelizeParameters.h"
29 #include "itkObject.h"
33 //--------------------------------------------------------------------
35 Convenient class to manage options from GGO gengetopt) to filter
37 //--------------------------------------------------------------------
41 // Standard class typedefs
42 typedef FilterBase Self;
44 // Run-time type information (and related methods)
45 itkTypeMacro(FilterBase, Object);
47 // Needed by itkSetMacro (cannot inherit from itkObject because of
48 // multiple inheritance)
49 virtual void Modified() {}
50 virtual bool GetDebug() const { return false; }
52 // To put in class that inherit from FilterBase
53 #define FILTERBASE_INIT \
54 virtual void Modified() { Superclass::Modified(); } \
55 virtual bool GetDebug() const { return Superclass::GetDebug(); }
57 // Verbose options management
58 itkSetMacro(VerboseOption, bool);
59 itkGetConstMacro(VerboseOption, bool);
60 itkBooleanMacro(VerboseOption);
61 GGO_DefineOption_Flag(verboseOption, SetVerboseOption);
64 itkSetMacro(NumberOfSteps, int);
65 itkGetConstMacro(NumberOfSteps, int);
66 itkSetMacro(VerboseStep, bool);
67 itkGetConstMacro(VerboseStep, bool);
68 itkBooleanMacro(VerboseStep);
69 GGO_DefineOption_Flag(verboseStep, SetVerboseStep);
71 itkSetMacro(WriteStep, bool);
72 itkGetConstMacro(WriteStep, bool);
73 itkBooleanMacro(WriteStep);
74 GGO_DefineOption_Flag(writeStep, SetWriteStep);
76 itkSetMacro(CurrentStepNumber, int);
77 itkGetConstMacro(CurrentStepNumber, int);
78 itkSetMacro(CurrentStepId, std::string);
79 itkGetConstMacro(CurrentStepId, std::string);
80 itkSetMacro(CurrentStepBaseId, std::string);
81 itkGetConstMacro(CurrentStepBaseId, std::string);
82 itkSetMacro(CurrentStepName, std::string);
83 itkGetConstMacro(CurrentStepName, std::string);
85 // Convenient function for verbose option
86 template<class OptionType>
87 void VerboseOption(std::string name, OptionType value);
88 template<class OptionType>
89 void VerboseOption(std::string name, int nb, OptionType value);
90 template<class OptionType>
91 void VerboseOptionV(std::string name, int nb, OptionType * value);
94 void SetLastError(std::string e);
95 void ResetLastError();
96 itkGetConstMacro(LastError, std::string);
97 bool HasError() { return (GetLastError() != ""); }
98 itkSetMacro(StopOnError, bool);
99 itkGetConstMacro(StopOnError, bool);
100 itkBooleanMacro(StopOnError);
102 void SetWarning(std::string e);
103 itkGetConstMacro(Warning, std::string);
104 itkSetMacro(VerboseWarningOff, bool);
105 itkGetConstMacro(VerboseWarningOff, bool);
106 itkBooleanMacro(VerboseWarningOff);
107 GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff);
109 // Use this function to stop (when threaded)
110 void SetMustStop(bool b);
115 virtual ~FilterBase() {}
116 void StartNewStep(std::string s);
117 template<class TInternalImageType>
118 void StopCurrentStep(typename TInternalImageType::Pointer p);
119 void StopCurrentStep();
121 bool m_VerboseOption;
124 int m_CurrentStepNumber;
126 std::string m_CurrentStepId;
127 std::string m_CurrentStepBaseId;
128 std::string m_LastError;
129 std::string m_CurrentStepName;
131 std::string m_Warning;
132 bool m_VerboseWarningOff;
134 Timer m_CurrentStepTimer;
137 FilterBase(const Self&); //purposely not implemented
138 void operator=(const Self&); //purposely not implemented
141 //--------------------------------------------------------------------
143 } // end namespace clitk
144 //--------------------------------------------------------------------
146 #define StartNewStepOrStop(s) StartNewStep(s); if (GetMustStop()) return;
148 #ifndef ITK_MANUAL_INSTANTIATION
149 #include "clitkFilterBase.txx"
152 #endif // CLITKFILTERBASE_H