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 "clitkFilterMacros.txx"
25 #include "clitkLabelizeParameters.h"
28 #include "itkObject.h"
32 //--------------------------------------------------------------------
34 Convenient class to manage options from GGO gengetopt) to filter
36 //--------------------------------------------------------------------
40 // Standard class typedefs
41 typedef FilterBase Self;
43 // Run-time type information (and related methods)
44 itkTypeMacro(FilterBase, Object);
46 // Needed by itkSetMacro (cannot inherit from itkObject because of
47 // multiple inheritance)
48 virtual void Modified() {}
49 virtual bool GetDebug() const { return false; }
51 // To put in class that inherit from FilterBase
52 #define FILTERBASE_INIT \
53 virtual void Modified() { Superclass::Modified(); } \
54 virtual bool GetDebug() const { return Superclass::GetDebug(); }
56 // Verbose options management
57 itkSetMacro(VerboseOption, bool);
58 itkGetConstMacro(VerboseOption, bool);
59 itkBooleanMacro(VerboseOption);
60 GGO_DefineOption_Flag(verboseOption, SetVerboseOption);
63 itkSetMacro(NumberOfSteps, int);
64 itkGetConstMacro(NumberOfSteps, int);
65 itkSetMacro(VerboseStep, bool);
66 itkGetConstMacro(VerboseStep, bool);
67 itkBooleanMacro(VerboseStep);
68 GGO_DefineOption_Flag(verboseStep, SetVerboseStep);
70 itkSetMacro(WriteStep, bool);
71 itkGetConstMacro(WriteStep, bool);
72 itkBooleanMacro(WriteStep);
73 GGO_DefineOption_Flag(writeStep, SetWriteStep);
75 itkSetMacro(CurrentStepNumber, int);
76 itkGetConstMacro(CurrentStepNumber, int);
77 itkSetMacro(CurrentStepId, std::string);
78 itkGetConstMacro(CurrentStepId, std::string);
79 itkSetMacro(CurrentStepBaseId, std::string);
80 itkGetConstMacro(CurrentStepBaseId, std::string);
81 itkSetMacro(CurrentStepName, std::string);
82 itkGetConstMacro(CurrentStepName, std::string);
84 // Convenient function for verbose option
85 template<class OptionType>
86 void VerboseOption(std::string name, OptionType value);
87 template<class OptionType>
88 void VerboseOption(std::string name, int nb, OptionType value);
89 template<class OptionType>
90 void VerboseOptionV(std::string name, int nb, OptionType * value);
93 void SetLastError(std::string e);
94 void ResetLastError();
95 itkGetConstMacro(LastError, std::string);
96 bool HasError() { return (GetLastError() != ""); }
97 itkSetMacro(StopOnError, bool);
98 itkGetConstMacro(StopOnError, bool);
99 itkBooleanMacro(StopOnError);
101 void SetWarning(std::string e);
102 itkGetConstMacro(Warning, std::string);
103 itkSetMacro(VerboseWarningOff, bool);
104 itkGetConstMacro(VerboseWarningOff, bool);
105 itkBooleanMacro(VerboseWarningOff);
106 GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff);
108 // Use this function to stop (when threaded)
113 virtual ~FilterBase() {}
114 void StartNewStep(std::string s);
115 template<class TInternalImageType>
116 void StopCurrentStep(typename TInternalImageType::Pointer p);
117 void StopCurrentStep();
119 bool m_VerboseOption;
122 int m_CurrentStepNumber;
124 std::string m_CurrentStepId;
125 std::string m_CurrentStepBaseId;
126 std::string m_LastError;
127 std::string m_CurrentStepName;
129 std::string m_Warning;
130 bool m_VerboseWarningOff;
134 FilterBase(const Self&); //purposely not implemented
135 void operator=(const Self&); //purposely not implemented
138 //--------------------------------------------------------------------
140 } // end namespace clitk
141 //--------------------------------------------------------------------
143 #ifndef ITK_MANUAL_INSTANTIATION
144 #include "clitkFilterBase.txx"
147 #endif // CLITKFILTERBASE_H