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 "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(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);
93 void SetWarning(std::string e);
94 itkGetConstMacro(Warning, std::string);
95 itkSetMacro(VerboseWarningOff, bool);
96 itkGetConstMacro(VerboseWarningOff, bool);
97 itkBooleanMacro(VerboseWarningOff);
98 GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff);
100 // Use this function to cancel the filter between step
106 virtual ~FilterBase() {}
107 void StartNewStep(std::string s);
108 template<class TInternalImageType>
109 void StopCurrentStep(typename TInternalImageType::Pointer p);
110 void StopCurrentStep();
112 bool m_VerboseOption;
115 int m_CurrentStepNumber;
117 std::string m_CurrentStepId;
118 std::string m_CurrentStepBaseId;
119 std::string m_CurrentStepName;
120 std::string m_Warning;
121 bool m_VerboseWarningOff;
123 Timer m_CurrentStepTimer;
127 FilterBase(const Self&); //purposely not implemented
128 void operator=(const Self&); //purposely not implemented
131 //--------------------------------------------------------------------
133 } // end namespace clitk
134 //--------------------------------------------------------------------
136 #ifndef ITK_MANUAL_INSTANTIATION
137 #include "clitkFilterBase.txx"
140 #endif // CLITKFILTERBASE_H