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(VerboseStep, bool);
64 itkGetConstMacro(VerboseStep, bool);
65 itkBooleanMacro(VerboseStep);
66 GGO_DefineOption_Flag(verboseStep, SetVerboseStep);
68 itkSetMacro(WriteStep, bool);
69 itkGetConstMacro(WriteStep, bool);
70 itkBooleanMacro(WriteStep);
71 GGO_DefineOption_Flag(writeStep, SetWriteStep);
73 itkSetMacro(CurrentStepNumber, int);
74 itkGetConstMacro(CurrentStepNumber, int);
75 itkSetMacro(CurrentStepId, std::string);
76 itkGetConstMacro(CurrentStepId, std::string);
77 itkSetMacro(CurrentStepBaseId, std::string);
78 itkGetConstMacro(CurrentStepBaseId, std::string);
80 // Convenient function for verbose option
81 template<class OptionType>
82 void VerboseOption(std::string name, OptionType value);
83 template<class OptionType>
84 void VerboseOption(std::string name, int nb, OptionType value);
85 template<class OptionType>
86 void VerboseOptionV(std::string name, int nb, OptionType * value);
89 void SetLastError(std::string e);
90 void ResetLastError();
91 itkGetConstMacro(LastError, std::string);
92 bool HasError() { return (GetLastError() != ""); }
93 itkSetMacro(StopOnError, bool);
94 itkGetConstMacro(StopOnError, bool);
95 itkBooleanMacro(StopOnError);
97 void SetWarning(std::string e);
98 itkGetConstMacro(Warning, std::string);
99 itkSetMacro(VerboseWarningOff, bool);
100 itkGetConstMacro(VerboseWarningOff, bool);
101 itkBooleanMacro(VerboseWarningOff);
102 GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff);
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;
116 std::string m_CurrentStepId;
117 std::string m_CurrentStepBaseId;
118 std::string m_LastError;
120 std::string m_Warning;
121 bool m_VerboseWarningOff;
124 FilterBase(const Self&); //purposely not implemented
125 void operator=(const Self&); //purposely not implemented
128 //--------------------------------------------------------------------
130 } // end namespace clitk
131 //--------------------------------------------------------------------
133 #ifndef ITK_MANUAL_INSTANTIATION
134 #include "clitkFilterBase.txx"
137 #endif // CLITKFILTERBASE_H