42 #include "itkConfigure.h"
43 #include "ITKCommonExport.h"
79 # define ITK_NOOP_STATEMENT static_assert(true, "")
82 #if defined(ITK_FUTURE_LEGACY_REMOVE)
84 # define ITK_MACROEND_NOOP_STATEMENT ITK_NOOP_STATEMENT
90 # define ITK_MACROEND_NOOP_STATEMENT
98 #define ITK_PRAGMA(x) _Pragma(#x)
104 #if defined(__clang__) && defined(__has_warning)
105 # define CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
106 # define CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
107 # if __has_warning("-Wfloat-equal")
108 # define CLANG_SUPPRESS_Wfloat_equal ITK_PRAGMA(clang diagnostic ignored "-Wfloat-equal")
110 # define CLANG_SUPPRESS_Wfloat_equal
112 # if __has_warning("-Wc++14-extensions")
113 # define CLANG_SUPPRESS_Wc__14_extensions ITK_PRAGMA(clang diagnostic ignored "-Wc++14-extensions")
115 # define CLANG_SUPPRESS_Wc__14_extensions
118 # define CLANG_PRAGMA_PUSH
119 # define CLANG_PRAGMA_POP
120 # define CLANG_SUPPRESS_Wfloat_equal
121 # define CLANG_SUPPRESS_Wc__14_extensions
125 #if defined(__INTEL_COMPILER)
126 # define INTEL_PRAGMA_WARN_PUSH ITK_PRAGMA(warning push)
127 # define INTEL_PRAGMA_WARN_POP ITK_PRAGMA(warning pop)
128 # define INTEL_SUPPRESS_warning_1292 ITK_PRAGMA(warning disable 1292)
130 # define INTEL_PRAGMA_WARN_PUSH
131 # define INTEL_PRAGMA_WARN_POP
132 # define INTEL_SUPPRESS_warning_1292
143 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
144 # define ITK_GCC_PRAGMA_DIAG(x) ITK_PRAGMA(GCC diagnostic x)
145 # define ITK_GCC_PRAGMA_DIAG_PUSH() ITK_GCC_PRAGMA_DIAG(push)
146 # define ITK_GCC_PRAGMA_DIAG_POP() ITK_GCC_PRAGMA_DIAG(pop)
148 # define ITK_GCC_PRAGMA_DIAG(x)
149 # define ITK_GCC_PRAGMA_DIAG_PUSH()
150 # define ITK_GCC_PRAGMA_DIAG_POP()
165 #if defined(_MSC_VER) && (_MSC_VER < 1900)
166 # error "Visual Studio < 2015 is not supported under ITKv5"
168 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
169 # error "SUNPro C++ < 5.14.0 is not supported under ITKv5 and above"
171 #if defined(__CYGWIN__)
172 # error "The Cygwin compiler is not supported in ITKv4 and above"
174 #if defined(__BORLANDC__)
175 # error "The Borland C compiler is not supported in ITKv4 and above"
177 #if defined(__MWERKS__)
178 # error "The MetroWerks compiler is not supported in ITKv4 and above"
180 #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && \
181 ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 8)))
182 # error "GCC < 4.8 is not supported under ITKv5"
188 # error "The SGI compiler is not supported under ITKv4 and above"
190 #if defined(__APPLE__)
191 # if defined(__clang__) && (__cplusplus < 201103L)
192 # error "Apple LLVM < 5.0 (clang < 3.3) is not supported under ITKv5"
194 #elif defined(__clang__) && ((__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3)))
195 # error "Clang < 3.3 is not supported under ITKv5"
197 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1504)
198 # error "Intel C++ < 15.0.4 is not supported under ITKv5"
202 #if defined(_WIN32) || defined(WIN32)
203 # define ITK_ABI_IMPORT __declspec(dllimport)
204 # define ITK_ABI_EXPORT __declspec(dllexport)
205 # define ITK_ABI_HIDDEN
208 # define ITK_ABI_IMPORT __attribute__((visibility("default")))
209 # define ITK_ABI_EXPORT __attribute__((visibility("default")))
210 # define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
212 # define ITK_ABI_IMPORT
213 # define ITK_ABI_EXPORT
214 # define ITK_ABI_HIDDEN
219 #ifndef ITK_TEMPLATE_EXPORT
220 # ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
221 # define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
223 # define ITK_TEMPLATE_EXPORT
228 #ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
229 # define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
231 # define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
234 #ifndef ITK_FORWARD_EXPORT
236 # if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
237 defined(USE_COMPILER_HIDDEN_VISIBILITY)
238 # define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
240 # define ITK_FORWARD_EXPORT
248 #define ITK_NOEXCEPT_OR_THROW error "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT"
250 #if !defined(ITK_LEGACY_REMOVE)
251 # define ITK_DELETE_FUNCTION = delete
253 # define ITK_DELETE_FUNCTION error "Replace ITK_DELETE_FUNCTION with = delete"
260 #if defined(ITK_FUTURE_LEGACY_REMOVE)
261 # define ITK_CONSTEXPR_FUNC "Replace ITK_CONSTEXPR_FUNC with constexpr"
262 # define ITK_CONSTEXPR_VAR "Replace ITK_CONSTEXPR_VAR with constexpr"
264 # define itkExposeEnumValue(name) static_cast<int>(name)
268 # define ITK_CONSTEXPR_FUNC constexpr
269 # define ITK_CONSTEXPR_VAR constexpr
272 # define itkExposeEnumValue(name) static_cast<int>(name)
277 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
279 # define ITK_FALLTHROUGH __attribute__((fallthrough))
281 #elif defined(__has_warning)
282 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
283 # define ITK_FALLTHROUGH [[clang::fallthrough]]
287 #ifndef ITK_FALLTHROUGH
288 # define ITK_FALLTHROUGH ((void)0)
311 #define itkNewMacro(x) \
312 itkSimpleNewMacro(x); \
313 itkCreateAnotherMacro(x); \
315 ITK_MACROEND_NOOP_STATEMENT
318 #define itkSimpleNewMacro(x) \
319 static Pointer New() \
321 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
322 if (smartPtr == nullptr) \
326 smartPtr->UnRegister(); \
329 ITK_MACROEND_NOOP_STATEMENT
331 #define itkCreateAnotherMacro(x) \
332 ::itk::LightObject::Pointer CreateAnother() const override \
334 ::itk::LightObject::Pointer smartPtr; \
335 smartPtr = x::New().GetPointer(); \
338 ITK_MACROEND_NOOP_STATEMENT
340 #define itkCloneMacro(x) \
341 Pointer Clone() const \
343 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
346 ITK_MACROEND_NOOP_STATEMENT
360 #define itkFactorylessNewMacro(x) \
361 static Pointer New() \
364 x * rawPtr = new x; \
366 rawPtr->UnRegister(); \
369 ::itk::LightObject::Pointer CreateAnother() const override \
371 ::itk::LightObject::Pointer smartPtr; \
372 smartPtr = x::New().GetPointer(); \
375 ITK_MACROEND_NOOP_STATEMENT
387 #define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
388 TypeName(const TypeName &) = delete; \
389 TypeName & operator=(const TypeName &) = delete; \
390 TypeName(TypeName &&) = delete; \
391 TypeName & operator=(TypeName &&) = delete
393 #if !defined(ITK_FUTURE_LEGACY_REMOVE)
394 # define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
396 # define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
397 static_assert(false, "Replace deprecated ITK_DISALLOW_COPY_AND_ASSIGN with modern ITK_DISALLOW_COPY_AND_MOVE")
402 #define itkTypeMacro(thisClass, superclass) \
403 const char * GetNameOfClass() const override { return #thisClass; } \
404 ITK_MACROEND_NOOP_STATEMENT
406 #define itkTypeMacroNoParent(thisClass) \
407 virtual const char * GetNameOfClass() const { return #thisClass; } \
408 ITK_MACROEND_NOOP_STATEMENT
418 extern ITKCommon_EXPORT
void
419 OutputWindowDisplayText(
const char *);
422 extern ITKCommon_EXPORT
void
423 OutputWindowDisplayErrorText(
const char *);
425 extern ITKCommon_EXPORT
void
426 OutputWindowDisplayWarningText(
const char *);
428 extern ITKCommon_EXPORT
void
429 OutputWindowDisplayGenericOutputText(
const char *);
431 extern ITKCommon_EXPORT
void
432 OutputWindowDisplayDebugText(
const char *);
440 # define itkDebugMacro(x) ITK_NOOP_STATEMENT
441 # define itkDebugStatement(x) ITK_NOOP_STATEMENT
443 # define itkDebugMacro(x) \
446 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
448 std::ostringstream itkmsg; \
449 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
450 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
451 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
458 # define itkDebugStatement(x) x
464 #define itkWarningMacro(x) \
467 if (::itk::Object::GetGlobalWarningDisplay()) \
469 std::ostringstream itkmsg; \
470 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
471 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
472 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
477 #define itkWarningStatement(x) x
479 #if defined(ITK_CPP_FUNCTION)
480 # if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
481 # define ITK_LOCATION __FUNCSIG__
482 # elif defined(__GNUC__)
483 # define ITK_LOCATION __PRETTY_FUNCTION__
485 # define ITK_LOCATION __FUNCTION__
488 # define ITK_LOCATION "unknown"
491 #define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
494 class newexcp : public parentexcp \
498 static constexpr const char * const default_exception_message = whatmessage; \
500 using parentexcp::parentexcp; \
501 itkTypeMacro(newexcp, parentexcp); \
504 ITK_MACROEND_NOOP_STATEMENT
507 #define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
509 std::ostringstream exceptionDescriptionOutputStringStream; \
510 exceptionDescriptionOutputStringStream << "ITK ERROR: " x; \
511 throw ::itk::ExceptionType( \
512 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
514 ITK_MACROEND_NOOP_STATEMENT
516 #define itkSpecializedExceptionMacro(ExceptionType) \
517 itkSpecializedMessageExceptionMacro(ExceptionType, << ::itk::ExceptionType::default_exception_message)
522 #define itkExceptionMacro(x) \
523 itkSpecializedMessageExceptionMacro(ExceptionObject, << this->GetNameOfClass() << "(" << this << "): " x)
525 #define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
527 #define itkGenericOutputMacro(x) \
529 if (::itk::Object::GetGlobalWarningDisplay()) \
531 std::ostringstream itkmsg; \
532 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" x << "\n\n"; \
533 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str()); \
536 ITK_MACROEND_NOOP_STATEMENT
541 #define itkLogMacro(x, y) \
543 if (this->GetLogger()) \
545 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
548 ITK_MACROEND_NOOP_STATEMENT
550 #define itkLogMacroStatic(obj, x, y) \
552 if (obj->GetLogger()) \
554 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
557 ITK_MACROEND_NOOP_STATEMENT
588 #if defined(ITK_LEGACY_REMOVE)
589 # define itkLegacyMacro(method)
591 # if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
593 # define itkLegacyMacro(method) method
597 # if defined(__GNUC__) && !defined(__INTEL_COMPILER)
598 # define itkLegacyMacro(method) method __attribute__((deprecated))
599 # elif defined(_MSC_VER)
600 # define itkLegacyMacro(method) __declspec(deprecated) method
602 # define itkLegacyMacro(method) method
629 #if defined(ITK_LEGACY_SILENT)
630 # define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
631 # define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
632 # define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
633 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
635 # define itkLegacyBodyMacro(method, version) \
636 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
637 # define itkLegacyReplaceBodyMacro(method, version, replace) \
638 itkWarningMacro(#method " was deprecated for ITK " #version \
639 " and will be removed in a future version. Use " #replace " instead.")
640 # define itkGenericLegacyBodyMacro(method, version) \
641 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
642 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
643 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
644 " and will be removed in a future version. Use " #replace " instead.")
651 #define ITK_CACHE_LINE_ALIGNMENT 64
659 #define itkPadStruct(mincachesize, oldtype, newtype) \
660 struct newtype : public oldtype \
662 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
669 #if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
670 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
671 #elif defined(_MSC_VER)
672 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
674 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
677 #if defined(ITK_FUTURE_LEGACY_REMOVE)
700 # define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
701 #else // LEGACY_REMOVE
702 # define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
718 #define itkForLoopAssignmentMacro( \
719 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
720 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
722 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
734 #define itkForLoopRoundingAndAssignmentMacro( \
735 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
736 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
738 DestinationArray[i] = itk::Math::Round<DestinationElementType>(SourceArray[i]); \
745 # ifdef _POSIX_SOURCE
746 # define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
748 # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
752 # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
755 #define itkAssertOrThrowMacro(test, message) \
758 std::ostringstream msgstr; \
760 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
762 ITK_MACROEND_NOOP_STATEMENT
765 # define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
767 # define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
790 #define itkStaticConstMacro(name, type, value) static constexpr type name = value
792 #define itkGetStaticConstMacro(name) (Self::name)
795 #define itkSetInputMacro(name, type) \
796 virtual void Set##name(const type * _arg) \
798 itkDebugMacro("setting input " #name " to " << _arg); \
799 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
801 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
805 ITK_MACROEND_NOOP_STATEMENT
809 #define itkGetInputMacro(name, type) \
810 virtual const type * Get##name() const \
812 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
813 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
815 ITK_MACROEND_NOOP_STATEMENT
820 #define itkSetDecoratedInputMacro(name, type) \
821 virtual void Set##name##Input(const SimpleDataObjectDecorator<type> * _arg) \
823 itkDebugMacro("setting input " #name " to " << _arg); \
824 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
826 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
830 virtual void Set##name(const SimpleDataObjectDecorator<type> * _arg) { this->Set##name##Input(_arg); } \
831 virtual void Set##name(const type & _arg) \
833 using DecoratorType = SimpleDataObjectDecorator<type>; \
834 itkDebugMacro("setting input " #name " to " << _arg); \
835 const DecoratorType * oldInput = \
836 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
838 CLANG_SUPPRESS_Wfloat_equal \
839 if (oldInput && oldInput->Get() == _arg) \
844 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
845 newInput->Set(_arg); \
846 this->Set##name##Input(newInput); \
848 ITK_MACROEND_NOOP_STATEMENT
853 #define itkGetDecoratedInputMacro(name, type) \
854 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
856 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
857 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
859 virtual const type & Get##name() const \
861 itkDebugMacro("Getting input " #name); \
862 using DecoratorType = SimpleDataObjectDecorator<type>; \
863 const DecoratorType * input = \
864 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
865 if (input == nullptr) \
867 itkExceptionMacro(<< "input" #name " is not set"); \
869 return input->Get(); \
871 ITK_MACROEND_NOOP_STATEMENT
876 #define itkSetGetDecoratedInputMacro(name, type) \
877 itkSetDecoratedInputMacro(name, type); \
878 itkGetDecoratedInputMacro(name, type)
884 #define itkSetDecoratedObjectInputMacro(name, type) \
885 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
887 itkDebugMacro("setting input " #name " to " << _arg); \
888 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
890 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
894 virtual void Set##name(const type * _arg) \
896 using DecoratorType = DataObjectDecorator<type>; \
897 itkDebugMacro("setting input " #name " to " << _arg); \
898 const DecoratorType * oldInput = \
899 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
900 if (oldInput && oldInput->Get() == _arg) \
904 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
905 newInput->Set(_arg); \
906 this->Set##name##Input(newInput); \
908 ITK_MACROEND_NOOP_STATEMENT
915 #define itkGetDecoratedObjectInputMacro(name, type) \
916 virtual const DataObjectDecorator<type> * Get##name##Input() const \
918 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
919 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
921 virtual const type * Get##name() const \
923 itkDebugMacro("Getting input " #name); \
924 using DecoratorType = DataObjectDecorator<type>; \
925 const DecoratorType * input = \
926 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
927 if (input == nullptr) \
931 return input->Get(); \
933 ITK_MACROEND_NOOP_STATEMENT
938 #define itkSetGetDecoratedObjectInputMacro(name, type) \
939 itkSetDecoratedObjectInputMacro(name, type); \
940 itkGetDecoratedObjectInputMacro(name, type)
944 #define itkSetMacro(name, type) \
945 virtual void Set##name(const type _arg) \
947 itkDebugMacro("setting " #name " to " << _arg); \
949 CLANG_SUPPRESS_Wfloat_equal \
950 if (this->m_##name != _arg) \
952 this->m_##name = _arg; \
957 ITK_MACROEND_NOOP_STATEMENT
961 #define itkGetMacro(name, type) \
962 virtual type Get##name() { return this->m_##name; } \
963 ITK_MACROEND_NOOP_STATEMENT
969 #define itkGetConstMacro(name, type) \
970 virtual type Get##name() const { return this->m_##name; } \
971 ITK_MACROEND_NOOP_STATEMENT
978 #define itkGetConstReferenceMacro(name, type) \
979 virtual const type & Get##name() const { return this->m_##name; } \
980 ITK_MACROEND_NOOP_STATEMENT
987 #define itkSetEnumMacro(name, type) \
988 virtual void Set##name(const type _arg) \
990 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
991 if (this->m_##name != _arg) \
993 this->m_##name = _arg; \
997 ITK_MACROEND_NOOP_STATEMENT
1004 #define itkGetEnumMacro(name, type) \
1005 virtual type Get##name() const { return this->m_##name; } \
1006 ITK_MACROEND_NOOP_STATEMENT
1012 #define itkSetStringMacro(name) \
1013 virtual void Set##name(const char * _arg) \
1015 if (_arg && (_arg == this->m_##name)) \
1021 this->m_##name = _arg; \
1025 this->m_##name = ""; \
1029 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1030 ITK_MACROEND_NOOP_STATEMENT
1037 #define itkGetStringMacro(name) \
1038 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1039 ITK_MACROEND_NOOP_STATEMENT
1045 #define itkSetClampMacro(name, type, min, max) \
1046 virtual void Set##name(type _arg) \
1048 const type temp_extrema = (_arg < min ? min : (_arg > max ? max : _arg)); \
1049 itkDebugMacro("setting " << #name " to " << _arg); \
1051 CLANG_SUPPRESS_Wfloat_equal \
1052 if (this->m_##name != temp_extrema) \
1054 this->m_##name = temp_extrema; \
1059 ITK_MACROEND_NOOP_STATEMENT
1069 #define itkSetObjectMacro(name, type) \
1070 virtual void Set##name(type * _arg) \
1072 itkDebugMacro("setting " << #name " to " << _arg); \
1074 CLANG_SUPPRESS_Wfloat_equal \
1075 if (this->m_##name != _arg) \
1077 this->m_##name = _arg; \
1082 ITK_MACROEND_NOOP_STATEMENT
1111 #define itkGetConstObjectMacro(name, type) \
1112 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1113 ITK_MACROEND_NOOP_STATEMENT
1116 #if defined(ITK_FUTURE_LEGACY_REMOVE)
1122 # define itkGetObjectMacro(name, type) \
1123 virtual type * Get##name() \
1125 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1128 # define itkGetModifiableObjectMacro(name, type) \
1129 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1130 itkGetConstObjectMacro(name, type)
1132 #else // defined ( ITK_FUTURE_LEGACY_REMOVE )
1135 # define itkGetObjectMacro(name, type) \
1136 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1137 ITK_MACROEND_NOOP_STATEMENT
1138 # define itkGetModifiableObjectMacro(name, type) \
1139 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1140 itkGetConstObjectMacro(name, type); \
1141 itkGetObjectMacro(name, type)
1142 #endif // defined ( ITK_FUTURE_LEGACY_REMOVE )
1151 #define itkGetConstReferenceObjectMacro(name, type) \
1152 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1153 ITK_MACROEND_NOOP_STATEMENT
1159 #define itkSetConstObjectMacro(name, type) \
1160 virtual void Set##name(const type * _arg) \
1162 itkDebugMacro("setting " << #name " to " << _arg); \
1163 if (this->m_##name != _arg) \
1165 this->m_##name = _arg; \
1169 ITK_MACROEND_NOOP_STATEMENT
1174 #define itkBooleanMacro(name) \
1175 virtual void name##On() { this->Set##name(true); } \
1176 virtual void name##Off() { this->Set##name(false); }
1183 #define itkSetVectorMacro(name, type, count) \
1184 virtual void Set##name(type data[]) \
1187 for (i = 0; i < count; i++) \
1190 CLANG_SUPPRESS_Wfloat_equal \
1191 if (data[i] != this->m_##name[i]) \
1200 for (i = 0; i < count; i++) \
1202 this->m_##name[i] = data[i]; \
1206 ITK_MACROEND_NOOP_STATEMENT
1212 #define itkGetVectorMacro(name, type, count) \
1213 virtual type * Get##name() const { return this->m_##name; } \
1214 ITK_MACROEND_NOOP_STATEMENT
1220 #define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1227 #define itkGPUKernelMacro(kernel) \
1231 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1232 kernel() = delete; \
1233 ~kernel() = delete; \
1234 static const char * GetOpenCLSource(); \
1238 #define itkGetOpenCLSourceFromKernelMacro(kernel) \
1239 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); }
1243 #define itkPrintSelfObjectMacro(name) \
1244 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1246 os << indent << #name << ": (null)" << std::endl; \
1250 os << indent << #name << ": " << std::endl; \
1251 this->m_##name->Print(os, indent.GetNextIndent()); \
1253 ITK_MACROEND_NOOP_STATEMENT
1257 #define itkSetDecoratedOutputMacro(name, type) \
1258 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1260 itkDebugMacro("setting output " #name " to " << _arg); \
1261 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1263 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1267 virtual void Set##name(const type & _arg) \
1269 using DecoratorType = SimpleDataObjectDecorator<type>; \
1270 itkDebugMacro("setting output " #name " to " << _arg); \
1271 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1274 if (output->Get() == _arg) \
1280 output->Set(_arg); \
1285 typename DecoratorType::Pointer newOutput = DecoratorType::New(); \
1286 newOutput->Set(_arg); \
1287 this->Set##name##Output(newOutput); \
1290 ITK_MACROEND_NOOP_STATEMENT
1294 #define itkGetDecoratedOutputMacro(name, type) \
1295 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1297 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1298 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1300 virtual const type & Get##name() const \
1302 itkDebugMacro("Getting output " #name); \
1303 using DecoratorType = SimpleDataObjectDecorator<type>; \
1304 const DecoratorType * output = \
1305 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1306 if (output == nullptr) \
1308 itkExceptionMacro(<< "output" #name " is not set"); \
1310 return output->Get(); \
1312 ITK_MACROEND_NOOP_STATEMENT
1325 #if defined(ITKV4_COMPATIBILITY)
1326 # define ITK_ITERATOR_VIRTUAL virtual
1327 # define ITK_ITERATOR_OVERRIDE override
1328 # define ITK_ITERATOR_FINAL
1329 #elif !defined(ITK_LEGACY_REMOVE)
1330 # define ITK_ITERATOR_VIRTUAL virtual
1331 # define ITK_ITERATOR_OVERRIDE override
1332 # define ITK_ITERATOR_FINAL final
1334 # define ITK_ITERATOR_VIRTUAL
1335 # define ITK_ITERATOR_OVERRIDE
1336 # define ITK_ITERATOR_FINAL
1339 #if defined(ITKV4_COMPATIBILITY)
1341 # define ITKv5_CONST
1344 # define ITKv5_CONST const
1347 #define itkExceptionObject_h
1349 #undef itkExceptionObject_h