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 //--------------------------------------------------------------------
42 // Standard class typedefs
43 typedef FilterBase Self;
45 // Run-time type information (and related methods)
46 itkTypeMacro(FilterBase, Object);
48 // Needed by itkSetMacro (cannot inherit from itkObject because of
49 // multiple inheritance)
50 virtual void Modified() {}
51 virtual bool GetDebug() const { return false; }
53 // To put in class that inherit from FilterBase
54 #define FILTERBASE_INIT \
55 virtual void Modified() { Superclass::Modified(); } \
56 virtual bool GetDebug() const { return Superclass::GetDebug(); }
58 // Verbose options management
59 itkSetMacro(VerboseOption, bool);
60 itkGetConstMacro(VerboseOption, bool);
61 itkBooleanMacro(VerboseOption);
62 GGO_DefineOption_Flag(verboseOption, SetVerboseOption);
65 itkSetMacro(NumberOfSteps, int);
66 itkGetConstMacro(NumberOfSteps, int);
67 itkSetMacro(VerboseStep, bool);
68 itkGetConstMacro(VerboseStep, bool);
69 itkBooleanMacro(VerboseStep);
70 GGO_DefineOption_Flag(verboseStep, SetVerboseStep);
72 itkSetMacro(WriteStep, bool);
73 itkGetConstMacro(WriteStep, bool);
74 itkBooleanMacro(WriteStep);
75 GGO_DefineOption_Flag(writeStep, SetWriteStep);
77 itkSetMacro(CurrentStepNumber, int);
78 itkGetConstMacro(CurrentStepNumber, int);
79 itkSetMacro(CurrentStepId, std::string);
80 itkGetConstMacro(CurrentStepId, std::string);
81 itkSetMacro(CurrentStepBaseId, std::string);
82 itkGetConstMacro(CurrentStepBaseId, std::string);
83 itkSetMacro(CurrentStepName, std::string);
84 itkGetConstMacro(CurrentStepName, std::string);
86 // Convenient function for verbose option
87 template<class OptionType>
88 void VerboseOption(std::string name, OptionType value);
89 template<class OptionType>
90 void VerboseOption(std::string name, int nb, OptionType value);
91 template<class OptionType>
92 void VerboseOptionV(std::string name, int nb, OptionType * value);
94 void SetWarning(std::string e);
95 itkGetConstMacro(Warning, std::string);
96 itkSetMacro(VerboseWarningOff, bool);
97 itkGetConstMacro(VerboseWarningOff, bool);
98 itkBooleanMacro(VerboseWarningOff);
99 GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff);
101 // Use this function to cancel the filter between step
107 virtual ~FilterBase() {}
108 void StartNewStep(std::string s);
109 template<class TInternalImageType>
110 void StopCurrentStep(typename TInternalImageType::Pointer p);
111 void StopCurrentStep();
113 bool m_VerboseOption;
116 int m_CurrentStepNumber;
118 std::string m_CurrentStepId;
119 std::string m_CurrentStepBaseId;
120 std::string m_CurrentStepName;
121 std::string m_Warning;
122 bool m_VerboseWarningOff;
124 Timer m_CurrentStepTimer;
128 FilterBase(const Self&); //purposely not implemented
129 void operator=(const Self&); //purposely not implemented
132 //--------------------------------------------------------------------
134 } // end namespace clitk
135 //--------------------------------------------------------------------
137 #ifndef ITK_MANUAL_INSTANTIATION
138 #include "clitkFilterBase.txx"
141 #endif // CLITKFILTERBASE_H