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://www.centreleonberard.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 "clitkTimer.h"
24 #include "clitkFilterMacros.txx"
25 #include "clitkLabelizeParameters.h"
28 #include "itkObject.h"
32 //--------------------------------------------------------------------
34 Convenient class to manage options from GGO (gengetopt) to filter
36 //--------------------------------------------------------------------
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(VerboseFlag, bool);
59 itkGetConstMacro(VerboseFlag, bool);
60 itkBooleanMacro(VerboseFlag);
63 itkSetMacro(VerboseOptionFlag, bool);
64 itkGetConstMacro(VerboseOptionFlag, bool);
65 itkBooleanMacro(VerboseOptionFlag);
68 itkSetMacro(VerboseMemoryFlag, bool);
69 itkGetConstMacro(VerboseMemoryFlag, bool);
70 itkBooleanMacro(VerboseMemoryFlag);
73 itkSetMacro(NumberOfSteps, int);
74 itkGetConstMacro(NumberOfSteps, int);
75 itkSetMacro(VerboseStepFlag, bool);
76 itkGetConstMacro(VerboseStepFlag, bool);
77 itkBooleanMacro(VerboseStepFlag);
79 itkSetMacro(WriteStepFlag, bool);
80 itkGetConstMacro(WriteStepFlag, bool);
81 itkBooleanMacro(WriteStepFlag);
83 itkSetMacro(CurrentStepNumber, int);
84 itkGetConstMacro(CurrentStepNumber, int);
85 itkSetMacro(CurrentStepId, std::string);
86 itkGetConstMacro(CurrentStepId, std::string);
87 itkSetMacro(CurrentStepBaseId, std::string);
88 itkGetConstMacro(CurrentStepBaseId, std::string);
89 itkSetMacro(CurrentStepName, std::string);
90 itkGetConstMacro(CurrentStepName, std::string);
95 // Convenient function for verbose option
96 template<class OptionType>
97 void VerboseOption(std::string name, OptionType value);
98 template<class OptionType>
99 void VerboseOption(std::string name, int nb, OptionType value);
100 template<class OptionType>
101 void VerboseOptionV(std::string name, int nb, OptionType * value);
103 void SetWarning(std::string e);
104 itkGetConstMacro(Warning, std::string);
105 itkSetMacro(VerboseWarningFlag, bool);
106 itkGetConstMacro(VerboseWarningFlag, bool);
107 itkBooleanMacro(VerboseWarningFlag);
109 // Use this function to cancel the filter between step
115 virtual ~FilterBase() {}
116 void StartNewStep(std::string s);
117 template<class TInternalImageType>
118 void StopCurrentStep(typename TInternalImageType::Pointer p);
119 void StopCurrentStep();
122 bool m_VerboseOptionFlag;
123 bool m_VerboseStepFlag;
124 bool m_VerboseMemoryFlag;
125 bool m_WriteStepFlag;
126 int m_CurrentStepNumber;
128 std::string m_CurrentStepId;
129 std::string m_CurrentStepBaseId;
130 std::string m_CurrentStepName;
131 std::string m_Warning;
132 bool m_VerboseWarningFlag;
134 Timer m_CurrentStepTimer;
136 std::vector<int> m_SubstepNumbers;
137 std::vector<std::string> m_SubstepID;
140 FilterBase(const Self&); //purposely not implemented
141 void operator=(const Self&); //purposely not implemented
144 //--------------------------------------------------------------------
146 } // end namespace clitk
147 //--------------------------------------------------------------------
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "clitkFilterBase.txx"
153 #endif // CLITKFILTERBASE_H