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_Wcpp14_extensions ITK_PRAGMA(clang diagnostic ignored "-Wc++14-extensions")
115 # define CLANG_SUPPRESS_Wcpp14_extensions
118 # define CLANG_PRAGMA_PUSH
119 # define CLANG_PRAGMA_POP
120 # define CLANG_SUPPRESS_Wfloat_equal
121 # define CLANG_SUPPRESS_Wcpp14_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()
157 #if defined(_MSC_VER) && (_MSC_VER < 1920)
158 # error "MSVC versions before Visual Studio 2019 are not supported under ITKv5.4"
160 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
161 # error "SUNPro C++ < 5.14.0 is not supported under ITKv5 and above"
163 #if defined(__CYGWIN__)
164 # error "The Cygwin compiler is not supported in ITKv4 and above"
166 #if defined(__BORLANDC__)
167 # error "The Borland C compiler is not supported in ITKv4 and above"
169 #if defined(__MWERKS__)
170 # error "The MetroWerks compiler is not supported in ITKv4 and above"
172 #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 7)
173 # error "GCC < 7 is not supported under ITKv5.4"
179 # error "The SGI compiler is not supported under ITKv4 and above"
181 #if defined(__APPLE__)
182 # if defined(__clang__) && (__cplusplus < 201703L)
183 # error "Apple LLVM compiling with a standard less than C++17 is not supported under ITKv5.4"
185 #elif defined(__clang__) && (__clang_major__ < 5)
186 # error "Clang < 5 is not supported under ITKv5.4"
188 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1910)
189 # error "Intel C++ < 19.1 is not supported under ITKv5.4"
193 #if defined(_WIN32) || defined(WIN32)
194 # define ITK_ABI_IMPORT __declspec(dllimport)
195 # define ITK_ABI_EXPORT __declspec(dllexport)
196 # define ITK_ABI_HIDDEN
199 # define ITK_ABI_IMPORT __attribute__((visibility("default")))
200 # define ITK_ABI_EXPORT __attribute__((visibility("default")))
201 # define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
203 # define ITK_ABI_IMPORT
204 # define ITK_ABI_EXPORT
205 # define ITK_ABI_HIDDEN
210 #ifndef ITK_TEMPLATE_EXPORT
211 # ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
212 # define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
214 # define ITK_TEMPLATE_EXPORT
219 #ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
220 # define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
222 # define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
225 #ifndef ITK_FORWARD_EXPORT
227 # if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
228 defined(USE_COMPILER_HIDDEN_VISIBILITY)
229 # define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
231 # define ITK_FORWARD_EXPORT
239 #define ITK_NOEXCEPT_OR_THROW error "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT"
241 #if !defined(ITK_LEGACY_REMOVE)
242 # define ITK_DELETE_FUNCTION = delete
244 # define ITK_DELETE_FUNCTION error "Replace ITK_DELETE_FUNCTION with = delete"
251 #if defined(ITK_FUTURE_LEGACY_REMOVE)
252 # define ITK_CONSTEXPR_FUNC "Replace ITK_CONSTEXPR_FUNC with constexpr"
253 # define ITK_CONSTEXPR_VAR "Replace ITK_CONSTEXPR_VAR with constexpr"
255 # define itkExposeEnumValue(name) static_cast<int>(name)
259 # define ITK_CONSTEXPR_FUNC constexpr
260 # define ITK_CONSTEXPR_VAR constexpr
263 # define itkExposeEnumValue(name) static_cast<int>(name)
268 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
270 # define ITK_FALLTHROUGH __attribute__((fallthrough))
272 #elif defined(__has_warning)
273 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
274 # define ITK_FALLTHROUGH [[clang::fallthrough]]
278 #ifndef ITK_FALLTHROUGH
279 # define ITK_FALLTHROUGH ((void)0)
302 #define itkNewMacro(x) \
303 itkSimpleNewMacro(x); \
304 itkCreateAnotherMacro(x); \
306 ITK_MACROEND_NOOP_STATEMENT
309 #define itkSimpleNewMacro(x) \
310 static Pointer New() \
312 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
313 if (smartPtr == nullptr) \
317 smartPtr->UnRegister(); \
320 ITK_MACROEND_NOOP_STATEMENT
322 #define itkCreateAnotherMacro(x) \
323 ::itk::LightObject::Pointer CreateAnother() const override \
325 ::itk::LightObject::Pointer smartPtr; \
326 smartPtr = x::New().GetPointer(); \
329 ITK_MACROEND_NOOP_STATEMENT
331 #define itkCloneMacro(x) \
332 Pointer Clone() const \
334 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
337 ITK_MACROEND_NOOP_STATEMENT
342 #define itkFactoryOnlyNewMacro(x) \
343 itkSimpleFactoryOnlyNewMacro(x); \
344 itkCreateAnotherMacro(x); \
346 ITK_MACROEND_NOOP_STATEMENT
349 #define itkSimpleFactoryOnlyNewMacro(x) \
350 static auto New()->Pointer \
352 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
353 if (smartPtr == nullptr) \
355 itkSpecializedMessageExceptionMacro(ExceptionObject, \
356 "Object factory failed to instantiate " << typeid(x).name()); \
358 smartPtr->UnRegister(); \
361 ITK_MACROEND_NOOP_STATEMENT
375 #define itkFactorylessNewMacro(x) \
376 static Pointer New() \
379 x * rawPtr = new x; \
381 rawPtr->UnRegister(); \
384 ::itk::LightObject::Pointer CreateAnother() const override \
386 ::itk::LightObject::Pointer smartPtr; \
387 smartPtr = x::New().GetPointer(); \
390 ITK_MACROEND_NOOP_STATEMENT
402 #define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
403 TypeName(const TypeName &) = delete; \
404 TypeName & operator=(const TypeName &) = delete; \
405 TypeName(TypeName &&) = delete; \
406 TypeName & operator=(TypeName &&) = delete
408 #if !defined(ITK_FUTURE_LEGACY_REMOVE)
409 # define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
411 # define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
412 static_assert(false, "Replace deprecated ITK_DISALLOW_COPY_AND_ASSIGN with modern ITK_DISALLOW_COPY_AND_MOVE")
420 #if __cplusplus >= 202002L
421 # define ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
427 #ifdef ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
430 # define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) ITK_MACROEND_NOOP_STATEMENT
434 # define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) \
435 bool operator!=(const TypeName & other) const { return !(this->operator==(other)); } \
436 ITK_MACROEND_NOOP_STATEMENT
441 #define itkTypeMacro(thisClass, superclass) \
442 const char * GetNameOfClass() const override { return #thisClass; } \
443 ITK_MACROEND_NOOP_STATEMENT
445 #define itkTypeMacroNoParent(thisClass) \
446 virtual const char * GetNameOfClass() const { return #thisClass; } \
447 ITK_MACROEND_NOOP_STATEMENT
457 extern ITKCommon_EXPORT
void
458 OutputWindowDisplayText(
const char *);
461 extern ITKCommon_EXPORT
void
462 OutputWindowDisplayErrorText(
const char *);
464 extern ITKCommon_EXPORT
void
465 OutputWindowDisplayWarningText(
const char *);
467 extern ITKCommon_EXPORT
void
468 OutputWindowDisplayGenericOutputText(
const char *);
470 extern ITKCommon_EXPORT
void
471 OutputWindowDisplayDebugText(
const char *);
480 # define itkDebugMacro(x) ITK_NOOP_STATEMENT
481 # define itkDebugStatement(x) ITK_NOOP_STATEMENT
483 # define itkDebugMacro(x) \
486 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
488 std::ostringstream itkmsg; \
489 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << '\n' \
490 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
491 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
498 # define itkDebugStatement(x) x
504 #define itkWarningMacro(x) \
507 if (::itk::Object::GetGlobalWarningDisplay()) \
509 std::ostringstream itkmsg; \
510 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << '\n' \
511 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
512 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
517 #define itkWarningStatement(x) x
519 #if defined(ITK_CPP_FUNCTION)
520 # if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
521 # define ITK_LOCATION __FUNCSIG__
522 # elif defined(__GNUC__)
523 # define ITK_LOCATION __PRETTY_FUNCTION__
525 # define ITK_LOCATION __FUNCTION__
528 # define ITK_LOCATION "unknown"
531 #define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
534 class newexcp : public parentexcp \
538 static constexpr const char * const default_exception_message = whatmessage; \
540 using parentexcp::parentexcp; \
541 itkTypeMacro(newexcp, parentexcp); \
544 ITK_MACROEND_NOOP_STATEMENT
547 #define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
549 std::ostringstream exceptionDescriptionOutputStringStream; \
550 exceptionDescriptionOutputStringStream << "ITK ERROR: " x; \
551 throw ::itk::ExceptionType( \
552 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
554 ITK_MACROEND_NOOP_STATEMENT
556 #define itkSpecializedExceptionMacro(ExceptionType) \
557 itkSpecializedMessageExceptionMacro(ExceptionType, << ::itk::ExceptionType::default_exception_message)
562 #define itkExceptionMacro(x) \
563 itkSpecializedMessageExceptionMacro(ExceptionObject, << this->GetNameOfClass() << '(' << this << "): " x)
565 #define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
567 #define itkGenericOutputMacro(x) \
569 if (::itk::Object::GetGlobalWarningDisplay()) \
571 std::ostringstream itkmsg; \
572 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" x << "\n\n"; \
573 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str()); \
576 ITK_MACROEND_NOOP_STATEMENT
581 #define itkLogMacro(x, y) \
583 if (this->GetLogger()) \
585 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
588 ITK_MACROEND_NOOP_STATEMENT
590 #define itkLogMacroStatic(obj, x, y) \
592 if (obj->GetLogger()) \
594 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
597 ITK_MACROEND_NOOP_STATEMENT
628 #if defined(ITK_LEGACY_REMOVE)
629 # define itkLegacyMacro(method)
631 # if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
633 # define itkLegacyMacro(method) method
636 # define itkLegacyMacro(method) [[deprecated]] method
662 #if defined(ITK_LEGACY_SILENT)
663 # define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
664 # define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
665 # define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
666 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
668 # define itkLegacyBodyMacro(method, version) \
669 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
670 # define itkLegacyReplaceBodyMacro(method, version, replace) \
671 itkWarningMacro(#method " was deprecated for ITK " #version \
672 " and will be removed in a future version. Use " #replace " instead.")
673 # define itkGenericLegacyBodyMacro(method, version) \
674 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
675 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
676 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
677 " and will be removed in a future version. Use " #replace " instead.")
684 #define ITK_CACHE_LINE_ALIGNMENT 64
692 #define itkPadStruct(mincachesize, oldtype, newtype) \
693 struct newtype : public oldtype \
695 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
702 #if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
703 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
704 #elif defined(_MSC_VER)
705 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
707 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
710 #if defined(ITK_FUTURE_LEGACY_REMOVE)
733 # define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
734 #else // LEGACY_REMOVE
735 # define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
751 #define itkForLoopAssignmentMacro( \
752 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
753 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
755 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
767 #define itkForLoopRoundingAndAssignmentMacro( \
768 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
769 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
771 DestinationArray[i] = ::itk::Math::Round<DestinationElementType>(SourceArray[i]); \
776 #if !defined(NDEBUG) && !defined(ITK_WRAPPING)
779 # define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
781 # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
785 # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
788 #define itkAssertOrThrowMacro(test, message) \
791 std::ostringstream msgstr; \
793 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
795 ITK_MACROEND_NOOP_STATEMENT
797 #if !defined(NDEBUG) && !defined(ITK_WRAPPING)
798 # define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
800 # define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
810 #ifdef ITK_FUTURE_LEGACY_REMOVE
811 # define itkStaticConstMacro(name, type, value) \
812 "Replace itkStaticConstMacro(name, type, value) with `static constexpr type name = value`"
813 # define itkGetStaticConstMacro(name) "Replace itkGetStaticConstMacro(name) with `Self::name`"
829 # define itkStaticConstMacro(name, type, value) static constexpr type name = value
831 # define itkGetStaticConstMacro(name) (Self::name)
835 #define itkSetInputMacro(name, type) \
836 virtual void Set##name(const type * _arg) \
838 itkDebugMacro("setting input " #name " to " << _arg); \
839 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
841 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
845 ITK_MACROEND_NOOP_STATEMENT
849 #define itkGetInputMacro(name, type) \
850 virtual const type * Get##name() const \
852 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
853 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
855 ITK_MACROEND_NOOP_STATEMENT
860 #define itkSetDecoratedInputMacro(name, type) \
861 virtual void Set##name##Input(const SimpleDataObjectDecorator<type> * _arg) \
863 itkDebugMacro("setting input " #name " to " << _arg); \
864 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
866 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
870 virtual void Set##name(const SimpleDataObjectDecorator<type> * _arg) { this->Set##name##Input(_arg); } \
871 virtual void Set##name(const type & _arg) \
873 using DecoratorType = SimpleDataObjectDecorator<type>; \
874 itkDebugMacro("setting input " #name " to " << _arg); \
875 const DecoratorType * oldInput = \
876 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
878 CLANG_SUPPRESS_Wfloat_equal \
879 if (oldInput && oldInput->Get() == _arg) \
884 auto newInput = DecoratorType::New(); \
885 newInput->Set(_arg); \
886 this->Set##name##Input(newInput); \
888 ITK_MACROEND_NOOP_STATEMENT
893 #define itkGetDecoratedInputMacro(name, type) \
894 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
896 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
897 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
899 virtual const type & Get##name() const \
901 itkDebugMacro("Getting input " #name); \
902 using DecoratorType = SimpleDataObjectDecorator<type>; \
903 const DecoratorType * input = \
904 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
905 if (input == nullptr) \
907 itkExceptionMacro("input" #name " is not set"); \
909 return input->Get(); \
911 ITK_MACROEND_NOOP_STATEMENT
916 #define itkSetGetDecoratedInputMacro(name, type) \
917 itkSetDecoratedInputMacro(name, type); \
918 itkGetDecoratedInputMacro(name, type)
924 #define itkSetDecoratedObjectInputMacro(name, type) \
925 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
927 itkDebugMacro("setting input " #name " to " << _arg); \
928 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
930 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
934 virtual void Set##name(const type * _arg) \
936 using DecoratorType = DataObjectDecorator<type>; \
937 itkDebugMacro("setting input " #name " to " << _arg); \
938 const DecoratorType * oldInput = \
939 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
940 if (oldInput && oldInput->Get() == _arg) \
944 auto newInput = DecoratorType::New(); \
945 newInput->Set(_arg); \
946 this->Set##name##Input(newInput); \
948 ITK_MACROEND_NOOP_STATEMENT
955 #define itkGetDecoratedObjectInputMacro(name, type) \
956 virtual const DataObjectDecorator<type> * Get##name##Input() const \
958 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
959 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
961 virtual const type * Get##name() const \
963 itkDebugMacro("Getting input " #name); \
964 using DecoratorType = DataObjectDecorator<type>; \
965 const DecoratorType * input = \
966 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
967 if (input == nullptr) \
971 return input->Get(); \
973 ITK_MACROEND_NOOP_STATEMENT
978 #define itkSetGetDecoratedObjectInputMacro(name, type) \
979 itkSetDecoratedObjectInputMacro(name, type); \
980 itkGetDecoratedObjectInputMacro(name, type)
984 #define itkSetMacro(name, type) \
985 virtual void Set##name(type _arg) \
987 itkDebugMacro("setting " #name " to " << _arg); \
989 CLANG_SUPPRESS_Wfloat_equal \
990 if (this->m_##name != _arg) \
992 this->m_##name = std::move(_arg); \
997 ITK_MACROEND_NOOP_STATEMENT
1001 #define itkGetMacro(name, type) \
1002 virtual type Get##name() { return this->m_##name; } \
1003 ITK_MACROEND_NOOP_STATEMENT
1009 #define itkGetConstMacro(name, type) \
1010 virtual type Get##name() const { return this->m_##name; } \
1011 ITK_MACROEND_NOOP_STATEMENT
1018 #define itkGetConstReferenceMacro(name, type) \
1019 virtual const type & Get##name() const { return this->m_##name; } \
1020 ITK_MACROEND_NOOP_STATEMENT
1027 #define itkSetEnumMacro(name, type) \
1028 virtual void Set##name(const type _arg) \
1030 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1031 if (this->m_##name != _arg) \
1033 this->m_##name = _arg; \
1037 ITK_MACROEND_NOOP_STATEMENT
1044 #define itkGetEnumMacro(name, type) \
1045 virtual type Get##name() const { return this->m_##name; } \
1046 ITK_MACROEND_NOOP_STATEMENT
1052 #define itkSetStringMacro(name) \
1053 virtual void Set##name(const char * _arg) \
1055 if (_arg && (_arg == this->m_##name)) \
1061 this->m_##name = _arg; \
1065 this->m_##name = ""; \
1069 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1070 ITK_MACROEND_NOOP_STATEMENT
1077 #define itkGetStringMacro(name) \
1078 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1079 ITK_MACROEND_NOOP_STATEMENT
1085 #define itkSetClampMacro(name, type, min, max) \
1086 virtual void Set##name(type _arg) \
1088 const type temp_extrema = (_arg <= min ? min : (_arg >= max ? max : _arg)); \
1089 itkDebugMacro("setting " << #name " to " << _arg); \
1091 CLANG_SUPPRESS_Wfloat_equal \
1092 if (this->m_##name != temp_extrema) \
1094 this->m_##name = temp_extrema; \
1099 ITK_MACROEND_NOOP_STATEMENT
1107 #define itkSetObjectMacro(name, type) \
1108 virtual void Set##name(type * _arg) \
1110 itkDebugMacro("setting " << #name " to " << _arg); \
1111 if (this->m_##name != _arg) \
1113 this->m_##name = _arg; \
1117 ITK_MACROEND_NOOP_STATEMENT
1146 #define itkGetConstObjectMacro(name, type) \
1147 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1148 ITK_MACROEND_NOOP_STATEMENT
1151 #if defined(ITK_FUTURE_LEGACY_REMOVE)
1157 # define itkGetObjectMacro(name, type) \
1158 virtual type * Get##name() \
1160 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1163 # define itkGetModifiableObjectMacro(name, type) \
1164 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1165 itkGetConstObjectMacro(name, type)
1167 #else // defined ( ITK_FUTURE_LEGACY_REMOVE )
1170 # define itkGetObjectMacro(name, type) \
1171 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1172 ITK_MACROEND_NOOP_STATEMENT
1173 # define itkGetModifiableObjectMacro(name, type) \
1174 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1175 itkGetConstObjectMacro(name, type); \
1176 itkGetObjectMacro(name, type)
1177 #endif // defined ( ITK_FUTURE_LEGACY_REMOVE )
1186 #define itkGetConstReferenceObjectMacro(name, type) \
1187 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1188 ITK_MACROEND_NOOP_STATEMENT
1193 #define itkSetConstObjectMacro(name, type) \
1194 virtual void Set##name(const type * _arg) \
1196 itkDebugMacro("setting " << #name " to " << _arg); \
1197 if (this->m_##name != _arg) \
1199 this->m_##name = _arg; \
1203 ITK_MACROEND_NOOP_STATEMENT
1208 #define itkBooleanMacro(name) \
1209 virtual void name##On() { this->Set##name(true); } \
1210 virtual void name##Off() { this->Set##name(false); }
1217 #define itkSetVectorMacro(name, type, count) \
1218 virtual void Set##name(type data[]) \
1221 for (i = 0; i < count; ++i) \
1224 CLANG_SUPPRESS_Wfloat_equal \
1225 if (data[i] != this->m_##name[i]) \
1234 for (i = 0; i < count; ++i) \
1236 this->m_##name[i] = data[i]; \
1240 ITK_MACROEND_NOOP_STATEMENT
1246 #define itkGetVectorMacro(name, type, count) \
1247 virtual type * Get##name() const { return this->m_##name; } \
1248 ITK_MACROEND_NOOP_STATEMENT
1254 #define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1261 #define itkGPUKernelMacro(kernel) \
1265 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1266 kernel() = delete; \
1267 ~kernel() = delete; \
1268 static const char * GetOpenCLSource(); \
1272 #define itkGetOpenCLSourceFromKernelMacro(kernel) \
1273 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); }
1277 #define itkPrintSelfObjectMacro(name) \
1278 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1280 os << indent << #name << ": (null)" << std::endl; \
1284 os << indent << #name << ": " << std::endl; \
1285 this->m_##name->Print(os, indent.GetNextIndent()); \
1287 ITK_MACROEND_NOOP_STATEMENT
1291 #define itkSetDecoratedOutputMacro(name, type) \
1292 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1294 itkDebugMacro("setting output " #name " to " << _arg); \
1295 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1297 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1301 virtual void Set##name(const type & _arg) \
1303 using DecoratorType = SimpleDataObjectDecorator<type>; \
1304 itkDebugMacro("setting output " #name " to " << _arg); \
1305 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1308 if (output->Get() == _arg) \
1314 output->Set(_arg); \
1319 auto newOutput = DecoratorType::New(); \
1320 newOutput->Set(_arg); \
1321 this->Set##name##Output(newOutput); \
1324 ITK_MACROEND_NOOP_STATEMENT
1328 #define itkGetDecoratedOutputMacro(name, type) \
1329 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1331 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1332 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1334 virtual const type & Get##name() const \
1336 itkDebugMacro("Getting output " #name); \
1337 using DecoratorType = SimpleDataObjectDecorator<type>; \
1338 const DecoratorType * output = \
1339 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1340 if (output == nullptr) \
1342 itkExceptionMacro("output" #name " is not set"); \
1344 return output->Get(); \
1346 ITK_MACROEND_NOOP_STATEMENT
1359 #if defined(ITKV4_COMPATIBILITY)
1360 # define ITK_ITERATOR_VIRTUAL virtual
1361 # define ITK_ITERATOR_OVERRIDE override
1362 # define ITK_ITERATOR_FINAL
1363 #elif !defined(ITK_LEGACY_REMOVE)
1364 # define ITK_ITERATOR_VIRTUAL virtual
1365 # define ITK_ITERATOR_OVERRIDE override
1366 # define ITK_ITERATOR_FINAL final
1368 # define ITK_ITERATOR_VIRTUAL
1369 # define ITK_ITERATOR_OVERRIDE
1370 # define ITK_ITERATOR_FINAL
1373 #if defined(ITKV4_COMPATIBILITY)
1375 # define ITKv5_CONST
1378 # define ITKv5_CONST const
1381 #define itkExceptionObject_h
1383 #undef itkExceptionObject_h
1392 template <
typename TTarget,
typename TSource>
1394 itkDynamicCastInDebugMode(TSource x)
1401 TTarget rval = dynamic_cast<TTarget>(x);
1402 if (rval ==
nullptr)
1404 itkGenericExceptionMacro(
"Failed dynamic cast to " <<
typeid(TTarget).name()
1405 <<
" object type = " << x->GetNameOfClass());
1409 return static_cast<TTarget>(x);
1414 #ifdef ITK_LEGACY_REMOVE
1415 # if __cplusplus >= 202002L
1416 # define ITK_NODISCARD(message) [[nodiscard(message)]]
1418 # define ITK_NODISCARD(message) [[nodiscard]]
1421 # define ITK_NODISCARD(message)
1425 #define ITK_ALIGNAS(X) alignas(X)
1426 #define ITK_ALIGNOF(X) alignof(X)
1427 #define ITK_DEPRECATED [[deprecated]]
1428 #define ITK_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
1429 #define ITK_CONSTEXPR constexpr
1430 #define ITK_DELETED_FUNCTION = delete
1431 #define ITK_EXTERN_TEMPLATE extern
1432 #define ITK_FINAL final
1433 #define ITK_NOEXCEPT noexcept
1434 #define ITK_NOEXCEPT_EXPR(X) noexcept(X)
1435 #define ITK_NULLPTR nullptr
1436 #define ITK_OVERRIDE override
1437 #define ITK_STATIC_ASSERT(X) static_assert(X, #X)
1438 #define ITK_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
1439 #define ITK_THREAD_LOCAL thread_local
1441 #endif // end of itkMacro.h