ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkMacro.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18/*=========================================================================
19 *
20 * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21 *
22 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23 *
24 * For complete copyright, license and disclaimer of warranty information
25 * please refer to the NOTICE file at the top of the ITK source tree.
26 *
27 *=========================================================================*/
37
38#ifndef itkMacro_h
39#define itkMacro_h
40
41#include "itkWin32Header.h"
42#include "itkConfigure.h"
43#include "ITKCommonExport.h"
44
45#include <typeinfo>
46
47#include <string>
48#include <cstdlib>
49#ifndef NDEBUG
50# include <cassert>
51#endif
52
53#include <sstream>
54#include <type_traits> // For is_same, remove_const, and remove_reference.
55
56// Two levels: # does not expand its operand, so the inner macro receives the expanded token.
57#define ITK_STRINGIFY_HELPER(x) #x
58#define ITK_STRINGIFY(x) ITK_STRINGIFY_HELPER(x)
59
64namespace itk
65{
66// end namespace itk - this is here for documentation purposes
67}
68
72#define itkNotUsed(x)
73
74// clang-format off
85#define ITK_NOOP_STATEMENT static_assert(true, "")
86
87/* NOTE: The ITK_MACROEND_NOOP_STATEMENT is used at the end
88 * of ITK supported macros to ensure that when the macro
89 * is used in the code base that the line must have ';' after
90 * the macro is used. This makes formatting visually similar
91 * to functions, and greatly improves the clang-format
92 * behaviors for indentation. This also assists
93 * modern IDE's and removes 1000's of warnings about
94 * unused statements or unnecessary ';' when macros are
95 * used. */
96#define ITK_MACROEND_NOOP_STATEMENT ITK_NOOP_STATEMENT
97// clang-format on
98
99// Define ITK_PRAGMA macro.
100//
101// It sets "#pragma" preprocessor directives without expecting the arguments
102// to be quoted.
103#define ITK_PRAGMA(x) _Pragma(#x)
104
105// The GCC/Clang compilers have many useful non-default compiler warnings
106// that tend to have a high false positive rate or are otherwise not always appropriate.
107// The following set of defines allows us to suppress instances of said warnings.
108
109// For GCC and Clang (Clang also identifies itself as GCC, and supports these pragmas):
110#if defined(__GNUC__)
111# define ITK_GCC_PRAGMA_PUSH ITK_PRAGMA(GCC diagnostic push)
112# define ITK_GCC_PRAGMA_POP ITK_PRAGMA(GCC diagnostic pop)
113# define ITK_GCC_SUPPRESS_Wfloat_equal ITK_PRAGMA(GCC diagnostic ignored "-Wfloat-equal")
114# define ITK_GCC_SUPPRESS_Wformat_nonliteral ITK_PRAGMA(GCC diagnostic ignored "-Wformat-nonliteral")
115# define ITK_GCC_SUPPRESS_Warray_bounds ITK_PRAGMA(GCC diagnostic ignored "-Warray-bounds")
116#else
117# define ITK_GCC_PRAGMA_PUSH
118# define ITK_GCC_PRAGMA_POP
119# define ITK_GCC_SUPPRESS_Wfloat_equal
120# define ITK_GCC_SUPPRESS_Wformat_nonliteral
121# define ITK_GCC_SUPPRESS_Warray_bounds
122#endif
123
124// -Wmaybe-uninitialized is a real-GCC-only warning name; Apple Clang emits
125// -Wunknown-warning-option for it (which ITK's dashboard treats as fatal).
126#if defined(__GNUC__) && !defined(__clang__)
127# define ITK_GCC_SUPPRESS_Wmaybe_uninitialized ITK_PRAGMA(GCC diagnostic ignored "-Wmaybe-uninitialized")
128#else
129# define ITK_GCC_SUPPRESS_Wmaybe_uninitialized
130#endif
131
132// For Clang only (and not GCC):
133#if defined(__clang__) && defined(__has_warning)
134# define ITK_CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
135# define ITK_CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
136# if __has_warning("-Wzero-as-null-pointer-constant")
137# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant \
138 ITK_PRAGMA(clang diagnostic ignored "-Wzero-as-null-pointer-constant")
139# else
140# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
141# endif
142# if __has_warning("-Wduplicate-enum")
143# define ITK_CLANG_SUPPRESS_Wduplicate_enum ITK_PRAGMA(clang diagnostic ignored "-Wduplicate-enum")
144# else
145# define ITK_CLANG_SUPPRESS_Wduplicate_enum
146# endif
147#else
148# define ITK_CLANG_PRAGMA_PUSH
149# define ITK_CLANG_PRAGMA_POP
150# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
151# define ITK_CLANG_SUPPRESS_Wduplicate_enum
152#endif
153
154// These were not intended as public API, but some code was nevertheless using them.
155// Support the pre ITK 5.4 spelling for compatibility.
156#define CLANG_PRAGMA_PUSH ITK_CLANG_PRAGMA_PUSH
157#define CLANG_PRAGMA_POP ITK_CLANG_PRAGMA_POP
158#define CLANG_SUPPRESS_Wfloat_equal ITK_GCC_SUPPRESS_Wfloat_equal
159
160// For GCC/Clang, to decorate printf-like functions allowing for compiler checks of format strings.
161#if defined(__GNUC__)
162# define ITK_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b)))
163#else
164# define ITK_FORMAT_PRINTF(a, b)
165#endif
166
167#if !defined(ITK_LEGACY_REMOVE)
168// Issue warning if deprecated preprocessor flag is used.
169# define CLANG_SUPPRESS_Wcpp14_extensions \
170 [[deprecated("Remove deprecated CLANG_SUPPRESS_Wcpp14_extensions c++14 warning suppression")]] void * \
171 CLANG_SUPPRESS_Wcpp14_extensions = nullptr;
172#endif
173
174// Define ITK_GCC_PRAGMA_DIAG(param1 [param2 [...]]) macro.
175//
176// This macro sets a pragma diagnostic
177//
178// Define ITK_GCC_PRAGMA_DIAG_(PUSH|POP) macros.
179//
180// These macros respectively push and pop the diagnostic context
181//
182#if defined(__GNUC__)
183# define ITK_GCC_PRAGMA_DIAG(x) ITK_PRAGMA(GCC diagnostic x)
184# define ITK_GCC_PRAGMA_DIAG_PUSH() ITK_GCC_PRAGMA_DIAG(push)
185# define ITK_GCC_PRAGMA_DIAG_POP() ITK_GCC_PRAGMA_DIAG(pop)
186#else
187# define ITK_GCC_PRAGMA_DIAG(x)
188# define ITK_GCC_PRAGMA_DIAG_PUSH()
189# define ITK_GCC_PRAGMA_DIAG_POP()
190#endif
191
192/*
193 * ITK only supports MSVC++ 14.22 and greater
194 * MSVC++ 14.22 _MSC_VER == 1922 (Visual Studio 2019 Version 16.2)
195 */
196#if defined(_MSC_VER) && (_MSC_VER < 1922)
197# error "MSVC versions before Visual Studio 2019 16.2 are not supported"
198#endif
199#if defined(__CYGWIN__)
200# error "The Cygwin compiler is not supported"
201#endif
202#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 7)
203# error "GCC < 7 is not supported"
204#endif
205#if defined(__apple_build_version__) && (__apple_build_version__ < 12000032)
206# error "AppleClang < Xcode 12.4 is not supported"
207#elif defined(__clang__) && (__clang_major__ < 5)
208# error "Clang < 5 is not supported"
209#endif
210
211// Setup symbol exports
212#if defined(_WIN32) || defined(WIN32)
213# define ITK_ABI_IMPORT __declspec(dllimport)
214# define ITK_ABI_EXPORT __declspec(dllexport)
215# define ITK_ABI_HIDDEN
216#else
217# ifdef __GNUC__
218# define ITK_ABI_IMPORT __attribute__((visibility("default")))
219# define ITK_ABI_EXPORT __attribute__((visibility("default")))
220# define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
221# else
222# define ITK_ABI_IMPORT
223# define ITK_ABI_EXPORT
224# define ITK_ABI_HIDDEN
225# endif
226#endif
227
228// Setup symbol exports
229#ifndef ITK_TEMPLATE_EXPORT
230# ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
231# define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
232# else
233# define ITK_TEMPLATE_EXPORT
234# endif
235#endif
236
237// Setup symbol exports
238#ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
239# define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
240#else
241# define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
242#endif
243
244#ifndef ITK_FORWARD_EXPORT
245// If build with shared libraries, on MacOS, if USE_COMPILER_HIDDEN_VISIBILITY is ON
246# if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
247 defined(USE_COMPILER_HIDDEN_VISIBILITY)
248# define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
249# else
250# define ITK_FORWARD_EXPORT
251# endif
252#endif
253
254
276#define itkNewMacro(x) \
277 itkSimpleNewMacro(x); \
278 itkCreateAnotherMacro(x); \
279 itkCloneMacro(x); \
280 ITK_MACROEND_NOOP_STATEMENT
282#define itkSimpleNewMacro(x) \
283 static Pointer New() \
284 { \
285 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
286 if (smartPtr == nullptr) \
287 { \
288 smartPtr = new x(); \
289 } \
290 smartPtr->UnRegister(); \
291 return smartPtr; \
292 } \
293 ITK_MACROEND_NOOP_STATEMENT
294
295#define itkCreateAnotherMacro(x) \
296 ::itk::LightObject::Pointer CreateAnother() const override { return x::New().GetPointer(); } \
297 ITK_MACROEND_NOOP_STATEMENT
298
299#define itkCloneMacro(x) \
300 Pointer Clone() const \
301 { \
302 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
303 return rval; \
304 } \
305 ITK_MACROEND_NOOP_STATEMENT
306
311#define itkFactoryOnlyNewMacro(x) \
312 itkSimpleFactoryOnlyNewMacro(x); \
313 itkCreateAnotherMacro(x); \
314 itkCloneMacro(x); \
315 ITK_MACROEND_NOOP_STATEMENT
317#define itkSimpleFactoryOnlyNewMacro(x) \
318 static auto New() -> Pointer \
319 { \
320 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
321 if (smartPtr == nullptr) \
322 { \
323 itkSpecializedMessageExceptionMacro(ExceptionObject, \
324 "Object factory failed to instantiate " << typeid(x).name()); \
325 } \
326 smartPtr->UnRegister(); \
327 return smartPtr; \
328 } \
329 ITK_MACROEND_NOOP_STATEMENT
330
344#define itkFactorylessNewMacro(x) \
345 static Pointer New() \
346 { \
347 auto * rawPtr = new x(); \
348 Pointer smartPtr = rawPtr; \
349 rawPtr->UnRegister(); \
350 return smartPtr; \
351 } \
352 itkCreateAnotherMacro(x); \
353 ITK_MACROEND_NOOP_STATEMENT
355//
356// A macro to disallow the copy constructor, copy assignment,
357// move constructor, and move assignment functions.
358// This should be used in the public: declarations for a class
359//
360// ITK's paradigm for smart pointer and pipeline consistency
361// prohibits the use of copy/move construction and copy/move assignment
362// functions.
363//
364#define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
365 TypeName(const TypeName &) = delete; \
366 TypeName & operator=(const TypeName &) = delete; \
367 TypeName(TypeName &&) = delete; \
368 TypeName & operator=(TypeName &&) = delete
369
370#if !defined(ITK_LEGACY_REMOVE)
371# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
372#else
373# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
374 static_assert(false, "Replace deprecated ITK_DISALLOW_COPY_AND_ASSIGN with modern ITK_DISALLOW_COPY_AND_MOVE")
375#endif
376
377
386#define ITK_DEFAULT_COPY_AND_MOVE(TypeName) \
387 TypeName(const TypeName &) = default; \
388 TypeName & operator=(const TypeName &) = default; \
389 TypeName(TypeName &&) = default; \
390 TypeName & operator=(TypeName &&) = default
392
393// ITK_ALPHA_FEATURE_* (itkConfigure.h) are unsupported opt-ins; without them every standard gets the C++17 form.
394
395// When ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR is defined, ITK uses
396// the ability for operator!= to be rewritten automatically in terms of
397// operator==, as introduced with C++20. This macro is experimental. It may be
398// modified, renamed, or removed without backward compatibility support.
399#if defined(ITK_ALPHA_FEATURE_CXX20)
400# define ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
401#endif
402
403// Note: The following macro, ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName),
404// is only for internal use within the implementation of ITK. It may be
405// modified, renamed, or removed without backward compatibility support.
406#ifdef ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
407// With C++20, operator!= is automatically rewritten in terms of the
408// corresponding operator==.
409# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) ITK_MACROEND_NOOP_STATEMENT
410#else
411// For C++14 and C++17, this macro defines an operator!= member function that
412// just calls the corresponding operator== member function.
413# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) \
414 bool operator!=(const TypeName & other) const { return !(this->operator==(other)); } \
415 ITK_MACROEND_NOOP_STATEMENT
416#endif
417
418
419// Internal macro (not part of the public ITK API), used to implement `GetNameOfClass()` member functions.
420#define itkInternalGetNameOfClassImplementationMacro(thisClass) \
421 { \
422 static_assert(std::is_same_v<thisClass, std::remove_const_t<std::remove_reference_t<decltype(*this)>>>, \
423 "The macro argument `" #thisClass \
424 "` appears incorrect! It should correspond with the name of this class!"); \
425 return #thisClass; \
426 } \
427 ITK_MACROEND_NOOP_STATEMENT
428
429
433#define itkVirtualGetNameOfClassMacro(thisClass) \
434 virtual const char * GetNameOfClass() const itkInternalGetNameOfClassImplementationMacro(thisClass)
435
436#define itkOverrideGetNameOfClassMacro(thisClass) \
437 const char * GetNameOfClass() const override itkInternalGetNameOfClassImplementationMacro(thisClass)
438
439#ifdef ITK_FUTURE_LEGACY_REMOVE
440# define itkTypeMacro(thisClass, superclass) \
441 static_assert(false, \
442 "In a future revision of ITK, the macro `itkTypeMacro(thisClass, superclass)` will be removed. " \
443 "Please call `itkOverrideGetNameOfClassMacro(thisClass)` instead!")
444# define itkTypeMacroNoParent(thisClass) \
445 static_assert(false, \
446 "In a future revision of ITK, the macro `itkTypeMacroNoParent(thisClass)` will be removed. " \
447 "Please call `itkVirtualGetNameOfClassMacro(thisClass)` instead!")
448#else
453# define itkTypeMacro(thisClass, superclass) itkOverrideGetNameOfClassMacro(thisClass)
454# define itkTypeMacroNoParent(thisClass) itkVirtualGetNameOfClassMacro(thisClass)
455#endif
456
457
458namespace itk
459{
467#ifndef ITK_FUTURE_LEGACY_REMOVE
468extern ITKCommon_EXPORT void
469OutputWindowDisplayText(const char *);
470
471extern ITKCommon_EXPORT void
472OutputWindowDisplayErrorText(const char *);
473
474extern ITKCommon_EXPORT void
475OutputWindowDisplayWarningText(const char *);
476
477extern ITKCommon_EXPORT void
478OutputWindowDisplayGenericOutputText(const char *);
479
480extern ITKCommon_EXPORT void
481OutputWindowDisplayDebugText(const char *);
482#endif
483
484// New context-aware versions of output display functions
485extern ITKCommon_EXPORT void
486OutputWindowDisplayDebugText(const char * file,
487 unsigned int line,
488 const char * className,
489 const void * objectAddress,
490 const char * message);
491
492extern ITKCommon_EXPORT void
493OutputWindowDisplayWarningText(const char * file,
494 unsigned int line,
495 const char * className,
496 const void * objectAddress,
497 const char * message);
498
499extern ITKCommon_EXPORT void
500OutputWindowDisplayErrorText(const char * file,
501 unsigned int line,
502 const char * className,
503 const void * objectAddress,
504 const char * message);
505
506extern ITKCommon_EXPORT void
507OutputWindowDisplayGenericOutputText(const char * file, unsigned int line, const char * message);
509
510} // end namespace itk
511
512// The itkDebugStatement is to be used to protect code that is only used in the itkDebugMacro
518#if defined(NDEBUG)
519# define itkDebugMacro(x) ITK_NOOP_STATEMENT
520# define itkDebugStatement(x) ITK_NOOP_STATEMENT
521#else
522# define itkDebugMacro(x) \
523 { \
524 using namespace ::itk::print_helper; /* for ostream << std::vector<T> */ \
525 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
526 { \
527 std::ostringstream itkmsg; \
528 itkmsg << "" x; \
529 ::itk::OutputWindowDisplayDebugText(__FILE__, __LINE__, this->GetNameOfClass(), this, itkmsg.str().c_str()); \
530 } \
531 } \
532 ITK_MACROEND_NOOP_STATEMENT
533// The itkDebugStatement is to be used to protect code that is only
534// used in the itkDebugMacro
535# define itkDebugStatement(x) x
536#endif
541#define itkWarningMacro(x) \
542 { \
543 if (::itk::Object::GetGlobalWarningDisplay()) \
544 { \
545 std::ostringstream itkmsg; \
546 itkmsg << "" x; \
547 ::itk::OutputWindowDisplayWarningText(__FILE__, __LINE__, this->GetNameOfClass(), this, itkmsg.str().c_str()); \
548 } \
549 } \
550 ITK_MACROEND_NOOP_STATEMENT
551
552
553#define itkWarningStatement(x) x
554
555#if defined(ITK_CPP_FUNCTION)
556# if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
557# define ITK_LOCATION __FUNCSIG__
558# elif defined(__GNUC__)
559# define ITK_LOCATION __PRETTY_FUNCTION__
560# else
561# define ITK_LOCATION __FUNCTION__
562# endif
563#else
564# define ITK_LOCATION "unknown"
565#endif
566
567#define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
568 namespace itk \
569 { \
570 class newexcp : public parentexcp \
571 { \
572 public: \
573 /* default message provides backward compatibility for a given exception type */ \
574 static constexpr const char * const default_exception_message = whatmessage; \
575 /* Inherit the constructors from its base class. */ \
576 using parentexcp::parentexcp; \
577 itkOverrideGetNameOfClassMacro(newexcp); \
578 }; \
579 } \
580 ITK_MACROEND_NOOP_STATEMENT
581
582
583#define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
584 { \
585 std::ostringstream exceptionDescriptionOutputStringStream; \
586 exceptionDescriptionOutputStringStream << "" x; \
587 throw ::itk::ExceptionType( \
588 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
589 } \
590 ITK_MACROEND_NOOP_STATEMENT
591
592#define itkSpecializedExceptionMacro(ExceptionType) \
593 throw ::itk::ExceptionType( \
594 std::string{ __FILE__ }, __LINE__, ::itk::ExceptionType::default_exception_message, std::string{ ITK_LOCATION });
595
596
600#define itkExceptionMacro(x) \
601 { \
602 std::ostringstream exceptionDescriptionOutputStringStream; \
603 exceptionDescriptionOutputStringStream << "" x; \
604 throw ::itk::ExceptionObject(std::string{ __FILE__ }, \
605 __LINE__, \
606 exceptionDescriptionOutputStringStream.str(), \
607 std::string{ ITK_LOCATION }, \
608 this); \
609 } \
610 ITK_MACROEND_NOOP_STATEMENT
611
612#define itkExceptionStringMacro(x) \
613 { \
614 throw ::itk::ExceptionObject( \
615 std::string{ __FILE__ }, __LINE__, std::string{ x }, std::string{ ITK_LOCATION }, this); \
616 } \
617 ITK_MACROEND_NOOP_STATEMENT
618
619#define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
620
621#define itkGenericOutputMacro(x) \
622 { \
623 if (::itk::Object::GetGlobalWarningDisplay()) \
624 { \
625 std::ostringstream itkmsg; \
626 itkmsg << "" x; \
627 ::itk::OutputWindowDisplayGenericOutputText(__FILE__, __LINE__, itkmsg.str().c_str()); \
628 } \
629 } \
630 ITK_MACROEND_NOOP_STATEMENT
631
632//----------------------------------------------------------------------------
633// Macros for simplifying the use of logging
634//
635#define itkLogMacro(x, y) \
636 { \
637 if (this->GetLogger()) \
638 { \
639 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
640 } \
641 } \
642 ITK_MACROEND_NOOP_STATEMENT
643
644#define itkLogMacroStatic(obj, x, y) \
645 { \
646 if (obj->GetLogger()) \
647 { \
648 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
649 } \
650 } \
651 ITK_MACROEND_NOOP_STATEMENT
652
653//----------------------------------------------------------------------------
654// Setup legacy code policy.
655//
656// CMake options:
657// - When ITK_LEGACY_REMOVE:BOOL=ON, legacy code is hidden, thus causing compiler errors for code that depends on it
658// - When ITK_LEGACY_REMOVE:BOOL=OFF, and ITK_LEGACY_SILENT:BOOL=ON, use
659// of legacy code will not produce compiler warnings.
660// - When ITK_LEGACY_REMOVE:BOOL=OFF, and ITK_LEGACY_SILENT:BOOL=OFF, use
661// of legacy code will produce compiler warnings
662//
663// ITK_LEGACY_SILENT silently use legacy code. The default is to warn about legacy code use.
664//
665// Source files that test the legacy code may define ITK_LEGACY_TEST
666// like this:
667//
668// #define ITK_LEGACY_TEST
669// #include "itkClassWithDeprecatedMethod.h"
670//
671// in order to silence the warnings for calling deprecated methods.
672// No other source files in ITK should call the methods since they are
673// provided only for compatibility with older user code.
674
675// Define itkLegacyMacro to mark legacy methods where they are
676// declared in their class. Example usage:
677//
678// // \deprecated Replaced by MyOtherMethod() as of ITK 2.0.
679// itkLegacyMacro(void MyMethod();)
680//
681// See below for what to do for the method definition.
682#if defined(ITK_LEGACY_REMOVE)
683# define itkLegacyMacro(method) /* no ';' */
684#else
685# if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
686// Provide legacy methods with no warnings.
687# define itkLegacyMacro(method) method /* no ';' */
688# else
689// Request compile-time warnings for uses of deprecated methods.
690# define itkLegacyMacro(method) [[deprecated]] method /* no ';' */
691# endif
692#endif
693
694// Macros to create runtime deprecation warning messages in function
695// bodies. Example usage:
696//
697// #if !defined( ITK_LEGACY_REMOVE )
698// void itkMyClass::MyOldMethod()
699// {
700// itkLegacyBodyMacro(itkMyClass::MyOldMethod, 2.0);
701// }
702//
703// void itkMyClass::MyMethod()
704// {
705// itkLegacyReplaceBodyMacro(itkMyClass::MyMethod, 2.0,
706// itkMyClass::MyOtherMethod);
707// }
708// #endif
709//
710// NOTE: These 4 macros itkLegacyBodyMacro, itkLegacyReplaceBodyMacro,
711// itkGenericLegacyBodyMacro, and itkGenericLegacyReplaceBodyMacro
712// are purposefully not defined when ITK_LEGACY_REMOVE is on,
713// because these macros are only relevant inside code segments
714// that are conditionally compiled only when ITK_LEGACY_REMOVE
715// is off.
716#if defined(ITK_LEGACY_SILENT)
717# define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
718# define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
719# define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
720# define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
721#else
722# define itkLegacyBodyMacro(method, version) \
723 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
724# define itkLegacyReplaceBodyMacro(method, version, replace) \
725 itkWarningMacro(#method " was deprecated for ITK " #version \
726 " and will be removed in a future version. Use " #replace " instead.")
727# define itkGenericLegacyBodyMacro(method, version) \
728 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
729# define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
730 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
731 " and will be removed in a future version. Use " #replace " instead.")
732#endif
733
734// Most modern x86 CPUs have 64 byte aligned blocks which are used for
735// the cache lines. By aligning multi-threaded structures with the
736// cache lines, false shared can be reduced, and performance
737// increased.
738constexpr size_t ITK_CACHE_LINE_ALIGNMENT{ 64 };
739
740//
741// itkPadStruct will add padding to a structure to ensure a minimum size
742// for ensuring that adjacent structures do not share CACHE lines.
743// Each struct will take up some multiple of cacheline sizes.
744// This is particularly useful for arrays of thread private variables.
745//
746#define itkPadStruct(mincachesize, oldtype, newtype) \
747 struct newtype : public oldtype \
748 { \
749 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
750 }
751
752//
753// itkAlignedTypedef is a macro which creates a new type to make a
754// data structure aligned.
755//
756#if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
757# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
758#elif defined(_MSC_VER)
759# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
760#else
761# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
762#endif
763
764#if defined(ITK_FUTURE_LEGACY_REMOVE)
765//=============================================================================
766/*
767NOTE: DEPRECATED - This macro is not longer needed to support modern
768compilers.
769
770 Define a common way of declaring a templated function as a friend inside a class.
771 - ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENTS(T)
772
773 The following templated function
774
775 template <T>
776 T add(const T & a, const T & b);
777
778 is declared as friend with
779
780 class A
781 {
782 public:
783 friend Self add<>( const Self & a, const Self & b );
784 }
785
786*/
787# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
788#else // LEGACY_REMOVE
789# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
790#endif
791
792//--------------------------------------------------------------------------------
793// Helper macros for Template Meta-Programming techniques of for-loops
794// unrolling
795//--------------------------------------------------------------------------------
796
797//--------------------------------------------------------------------------------
798// Macro that generates an unrolled for loop for assigning elements of one array
799// to elements of another array The array are assumed to be of same length
800// (dimension), and this is also assumed to be the value of NumberOfIterations.
801// No verification of size is performed. Casting is performed as part of the
802// assignment, by using the DestinationElementType as the casting type.
803// Source and destination array types must have defined operator[] in their
804// API.
805#define itkForLoopAssignmentMacro( \
806 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
807 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
808 { \
809 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
810 } \
811 ITK_MACROEND_NOOP_STATEMENT
812
813//--------------------------------------------------------------------------------
814// Macro that generates an unrolled for loop for rounding and assigning
815// elements of one array to elements of another array The array are assumed to
816// be of same length (dimension), and this is also assumed to be the value of
817// NumberOfIterations. No verification of size is performed. Casting is
818// performed as part of the assignment, by using the DestinationElementType as
819// the casting type.
820// Source and destination array types must have defined operator[] in their
821// API.
822#define itkForLoopRoundingAndAssignmentMacro( \
823 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
824 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
825 { \
826 DestinationArray[i] = ::itk::Math::Round<DestinationElementType>(SourceArray[i]); \
827 } \
828 ITK_MACROEND_NOOP_STATEMENT
829
830// end of Template Meta Programming helper macros
831
832#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
833
834# ifdef __GLIBC__
835# define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
836# else
837# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
838# endif
839
840#else
841# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
842#endif
843
844#define itkAssertOrThrowMacro(test, message) \
845 if (!(test)) \
846 { \
847 std::ostringstream msgstr; \
848 msgstr << message; \
849 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
850 } \
851 ITK_MACROEND_NOOP_STATEMENT
852
853#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
854# define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
855#else
856# define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
857#endif
858
859
860// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
861// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
862// !! The ITK Get/Set Macros for various types !!
863// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
864// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
865
866#ifdef ITK_FUTURE_LEGACY_REMOVE
867# define itkStaticConstMacro(name, type, value) \
868 "Replace itkStaticConstMacro(name, type, value) with `static constexpr type name = value`"
869# define itkGetStaticConstMacro(name) "Replace itkGetStaticConstMacro(name) with `Self::name`"
870#else
885# define itkStaticConstMacro(name, type, value) static constexpr type name = value
886
887# define itkGetStaticConstMacro(name) (Self::name)
888#endif
889
890// Set an input. This defines the Set"name"() method. Implementation detail; use the public wrappers below.
891#define ITK_DETAIL_SetInputMacroImpl(virtualKeyword, finalKeyword, name, type) \
892 virtualKeyword void Set##name(const type * _arg) finalKeyword \
893 { \
894 itkDebugMacro("setting input " #name " to " << _arg); \
895 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
896 { \
897 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
898 this->Modified(); \
899 } \
900 } \
901 ITK_MACROEND_NOOP_STATEMENT
902
905#define itkVirtualSetInputMacro(name, type) ITK_DETAIL_SetInputMacroImpl(virtual, , name, type)
906#define itkFinalSetInputMacro(name, type) ITK_DETAIL_SetInputMacroImpl(, final, name, type)
907#define itkNonVirtualSetInputMacro(name, type) ITK_DETAIL_SetInputMacroImpl(, , name, type)
908#define itkSetInputMacro(name, type) ITK_DETAIL_SetInputMacroImpl(virtual, , name, type)
910
911// Get an input. This defines the Get"name"() method. Implementation detail; use the public wrappers below.
912#define ITK_DETAIL_GetInputMacroImpl(virtualKeyword, finalKeyword, name, type) \
913 virtualKeyword const type * Get##name() const finalKeyword \
914 { \
915 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
916 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
917 } \
918 ITK_MACROEND_NOOP_STATEMENT
919
922#define itkVirtualGetInputMacro(name, type) ITK_DETAIL_GetInputMacroImpl(virtual, , name, type)
923#define itkFinalGetInputMacro(name, type) ITK_DETAIL_GetInputMacroImpl(, final, name, type)
924#define itkNonVirtualGetInputMacro(name, type) ITK_DETAIL_GetInputMacroImpl(, , name, type)
925#define itkGetInputMacro(name, type) ITK_DETAIL_GetInputMacroImpl(virtual, , name, type)
927
928// clang-format off
929// Set a decorated input. Defines Set"name"Input(), Set"name"(decorator*) and Set"name"(value). Implementation detail; use the public wrappers below.
930#define ITK_DETAIL_SetDecoratedInputMacroImpl(virtualKeyword, finalKeyword, name, type) \
931 virtualKeyword void Set##name##Input(const SimpleDataObjectDecorator<type> * _arg) finalKeyword \
932 { \
933 itkDebugMacro("setting input " #name " to " << _arg); \
934 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
935 { \
936 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
937 this->Modified(); \
938 } \
939 } \
940 virtualKeyword void Set##name(const SimpleDataObjectDecorator<type> * _arg) finalKeyword \
941 { \
942 this->Set##name##Input(_arg); \
943 } \
944 virtualKeyword void Set##name(const type & _arg) finalKeyword \
945 { \
946 using DecoratorType = SimpleDataObjectDecorator<type>; \
947 itkDebugMacro("setting input " #name " to " << _arg); \
948 const DecoratorType * oldInput = \
949 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
950 ITK_GCC_PRAGMA_PUSH \
951 ITK_GCC_SUPPRESS_Wfloat_equal \
952 if (oldInput && oldInput->Get() == _arg) \
953 { \
954 return; \
955 } \
956 ITK_GCC_PRAGMA_POP \
957 auto newInput = DecoratorType::New(); \
958 newInput->Set(_arg); \
959 this->Set##name##Input(newInput); \
960 } \
961 ITK_MACROEND_NOOP_STATEMENT
962// clang-format on
963
966#define itkVirtualSetDecoratedInputMacro(name, type) ITK_DETAIL_SetDecoratedInputMacroImpl(virtual, , name, type)
967#define itkFinalSetDecoratedInputMacro(name, type) ITK_DETAIL_SetDecoratedInputMacroImpl(, final, name, type)
968#define itkNonVirtualSetDecoratedInputMacro(name, type) ITK_DETAIL_SetDecoratedInputMacroImpl(, , name, type)
969#define itkSetDecoratedInputMacro(name, type) ITK_DETAIL_SetDecoratedInputMacroImpl(virtual, , name, type)
971
972// Get a decorated input. Defines Get"name"Input() and Get"name"(). Implementation detail; use the public wrappers
973// below.
974#define ITK_DETAIL_GetDecoratedInputMacroImpl(virtualKeyword, finalKeyword, name, type) \
975 virtualKeyword const SimpleDataObjectDecorator<type> * Get##name##Input() const finalKeyword \
976 { \
977 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
978 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
979 } \
980 virtualKeyword const type & Get##name() const finalKeyword \
981 { \
982 itkDebugMacro("Getting input " #name); \
983 using DecoratorType = SimpleDataObjectDecorator<type>; \
984 const DecoratorType * input = \
985 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
986 if (input == nullptr) \
987 { \
988 itkExceptionStringMacro("input" #name " is not set"); \
989 } \
990 return input->Get(); \
991 } \
992 ITK_MACROEND_NOOP_STATEMENT
993
996#define itkVirtualGetDecoratedInputMacro(name, type) ITK_DETAIL_GetDecoratedInputMacroImpl(virtual, , name, type)
997#define itkFinalGetDecoratedInputMacro(name, type) ITK_DETAIL_GetDecoratedInputMacroImpl(, final, name, type)
998#define itkNonVirtualGetDecoratedInputMacro(name, type) ITK_DETAIL_GetDecoratedInputMacroImpl(, , name, type)
999#define itkGetDecoratedInputMacro(name, type) ITK_DETAIL_GetDecoratedInputMacroImpl(virtual, , name, type)
1001
1004#define itkVirtualSetGetDecoratedInputMacro(name, type) \
1005 itkVirtualSetDecoratedInputMacro(name, type); \
1006 itkVirtualGetDecoratedInputMacro(name, type)
1007#define itkFinalSetGetDecoratedInputMacro(name, type) \
1008 itkFinalSetDecoratedInputMacro(name, type); \
1009 itkFinalGetDecoratedInputMacro(name, type)
1010#define itkNonVirtualSetGetDecoratedInputMacro(name, type) \
1011 itkNonVirtualSetDecoratedInputMacro(name, type); \
1012 itkNonVirtualGetDecoratedInputMacro(name, type)
1013#define itkSetGetDecoratedInputMacro(name, type) \
1014 itkSetDecoratedInputMacro(name, type); \
1015 itkGetDecoratedInputMacro(name, type)
1017
1018// Set a decorated itk::Object-derived (non-DataObject) input. Defines Set"name"() and Set"name"Input().
1019// Implementation detail; use the public wrappers below.
1020#define ITK_DETAIL_SetDecoratedObjectInputMacroImpl(virtualKeyword, finalKeyword, name, type) \
1021 virtualKeyword void Set##name##Input(const DataObjectDecorator<type> * _arg) finalKeyword \
1022 { \
1023 itkDebugMacro("setting input " #name " to " << _arg); \
1024 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
1025 { \
1026 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
1027 this->Modified(); \
1028 } \
1029 } \
1030 virtualKeyword void Set##name(const type * _arg) finalKeyword \
1031 { \
1032 using DecoratorType = DataObjectDecorator<type>; \
1033 itkDebugMacro("setting input " #name " to " << _arg); \
1034 const DecoratorType * oldInput = \
1035 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
1036 if (oldInput && oldInput->Get() == _arg) \
1037 { \
1038 return; \
1039 } \
1040 auto newInput = DecoratorType::New(); \
1041 newInput->Set(_arg); \
1042 this->Set##name##Input(newInput); \
1043 } \
1044 ITK_MACROEND_NOOP_STATEMENT
1045
1049#define itkVirtualSetDecoratedObjectInputMacro(name, type) \
1050 ITK_DETAIL_SetDecoratedObjectInputMacroImpl(virtual, , name, type)
1051#define itkFinalSetDecoratedObjectInputMacro(name, type) \
1052 ITK_DETAIL_SetDecoratedObjectInputMacroImpl(, final, name, type)
1053#define itkNonVirtualSetDecoratedObjectInputMacro(name, type) \
1054 ITK_DETAIL_SetDecoratedObjectInputMacroImpl(, , name, type)
1055#define itkSetDecoratedObjectInputMacro(name, type) ITK_DETAIL_SetDecoratedObjectInputMacroImpl(virtual, , name, type)
1057
1058// Get a decorated itk::Object-derived (non-DataObject) input. Defines Get"name"() and Get"name"Input().
1059// Implementation detail; use the public wrappers below.
1060#define ITK_DETAIL_GetDecoratedObjectInputMacroImpl(virtualKeyword, finalKeyword, name, type) \
1061 virtualKeyword const DataObjectDecorator<type> * Get##name##Input() const finalKeyword \
1062 { \
1063 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
1064 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
1065 } \
1066 virtualKeyword const type * Get##name() const finalKeyword \
1067 { \
1068 itkDebugMacro("Getting input " #name); \
1069 using DecoratorType = DataObjectDecorator<type>; \
1070 const DecoratorType * input = \
1071 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
1072 if (input == nullptr) \
1073 { \
1074 return nullptr; \
1075 } \
1076 return input->Get(); \
1077 } \
1078 ITK_MACROEND_NOOP_STATEMENT
1079
1083#define itkVirtualGetDecoratedObjectInputMacro(name, type) \
1084 ITK_DETAIL_GetDecoratedObjectInputMacroImpl(virtual, , name, type)
1085#define itkFinalGetDecoratedObjectInputMacro(name, type) \
1086 ITK_DETAIL_GetDecoratedObjectInputMacroImpl(, final, name, type)
1087#define itkNonVirtualGetDecoratedObjectInputMacro(name, type) \
1088 ITK_DETAIL_GetDecoratedObjectInputMacroImpl(, , name, type)
1089#define itkGetDecoratedObjectInputMacro(name, type) ITK_DETAIL_GetDecoratedObjectInputMacroImpl(virtual, , name, type)
1091
1094#define itkVirtualSetGetDecoratedObjectInputMacro(name, type) \
1095 itkVirtualSetDecoratedObjectInputMacro(name, type); \
1096 itkVirtualGetDecoratedObjectInputMacro(name, type)
1097#define itkFinalSetGetDecoratedObjectInputMacro(name, type) \
1098 itkFinalSetDecoratedObjectInputMacro(name, type); \
1099 itkFinalGetDecoratedObjectInputMacro(name, type)
1100#define itkNonVirtualSetGetDecoratedObjectInputMacro(name, type) \
1101 itkNonVirtualSetDecoratedObjectInputMacro(name, type); \
1102 itkNonVirtualGetDecoratedObjectInputMacro(name, type)
1103#define itkSetGetDecoratedObjectInputMacro(name, type) \
1104 itkSetDecoratedObjectInputMacro(name, type); \
1105 itkGetDecoratedObjectInputMacro(name, type)
1107
1108// Internal Set/Get macro bodies parametrized by the C++ virtual-specifier
1109// (`virtual`) and the trailing virt-specifier (`final`); at most one of
1110// `virtualKeyword`/`finalKeyword` is non-empty. Public variants below:
1111// itkVirtual*, itkFinal*, itkNonVirtual*; legacy itk*Macro forms remain
1112// `virtual` for ABI-stability through ITK v7. No `itkOverride*` variants:
1113// inherit the base member, or write the function by hand when an override
1114// genuinely needs different behavior. Implementation detail; use the public
1115// wrappers below.
1116// clang-format off
1117// Do not invoke ITK_DETAIL_SetMacroImpl directly from user code; use the public wrappers below.
1118#define ITK_DETAIL_SetMacroImpl(virtualKeyword, finalKeyword, name, type) \
1119 virtualKeyword void Set##name(type _arg) finalKeyword \
1120 { \
1121 itkDebugMacro("setting " #name " to " << _arg); \
1122 ITK_GCC_PRAGMA_PUSH \
1123 ITK_GCC_SUPPRESS_Wfloat_equal \
1124 if (this->m_##name != _arg) \
1125 { \
1126 this->m_##name = std::move(_arg); \
1127 this->Modified(); \
1128 } \
1129 ITK_GCC_PRAGMA_POP \
1130 } \
1131 ITK_MACROEND_NOOP_STATEMENT
1132// clang-format on
1133
1134// Do not invoke ITK_DETAIL_GetMacroImpl directly from user code; use the public wrappers below.
1135#define ITK_DETAIL_GetMacroImpl(virtualKeyword, finalKeyword, name, type) \
1136 virtualKeyword type Get##name() finalKeyword { return this->m_##name; } \
1137 ITK_MACROEND_NOOP_STATEMENT
1138
1139// Do not invoke ITK_DETAIL_GetConstMacroImpl directly from user code; use the public wrappers below.
1140#define ITK_DETAIL_GetConstMacroImpl(virtualKeyword, finalKeyword, name, type) \
1141 virtualKeyword type Get##name() const finalKeyword { return this->m_##name; } \
1142 ITK_MACROEND_NOOP_STATEMENT
1143
1144// Do not invoke ITK_DETAIL_GetConstReferenceMacroImpl directly from user code; use the public wrappers below.
1145#define ITK_DETAIL_GetConstReferenceMacroImpl(virtualKeyword, finalKeyword, name, type) \
1146 virtualKeyword const type & Get##name() const finalKeyword { return this->m_##name; } \
1147 ITK_MACROEND_NOOP_STATEMENT
1148
1151#define itkVirtualSetMacro(name, type) ITK_DETAIL_SetMacroImpl(virtual, , name, type)
1152#define itkFinalSetMacro(name, type) ITK_DETAIL_SetMacroImpl(, final, name, type)
1153#define itkNonVirtualSetMacro(name, type) ITK_DETAIL_SetMacroImpl(, , name, type)
1154#define itkSetMacro(name, type) ITK_DETAIL_SetMacroImpl(virtual, , name, type)
1156
1159#define itkVirtualGetMacro(name, type) ITK_DETAIL_GetMacroImpl(virtual, , name, type)
1160#define itkFinalGetMacro(name, type) ITK_DETAIL_GetMacroImpl(, final, name, type)
1161#define itkNonVirtualGetMacro(name, type) ITK_DETAIL_GetMacroImpl(, , name, type)
1162#define itkGetMacro(name, type) ITK_DETAIL_GetMacroImpl(virtual, , name, type)
1164
1169#define itkVirtualGetConstMacro(name, type) ITK_DETAIL_GetConstMacroImpl(virtual, , name, type)
1170#define itkFinalGetConstMacro(name, type) ITK_DETAIL_GetConstMacroImpl(, final, name, type)
1171#define itkNonVirtualGetConstMacro(name, type) ITK_DETAIL_GetConstMacroImpl(, , name, type)
1172#define itkGetConstMacro(name, type) ITK_DETAIL_GetConstMacroImpl(virtual, , name, type)
1174
1180#define itkVirtualGetConstReferenceMacro(name, type) ITK_DETAIL_GetConstReferenceMacroImpl(virtual, , name, type)
1181#define itkFinalGetConstReferenceMacro(name, type) ITK_DETAIL_GetConstReferenceMacroImpl(, final, name, type)
1182#define itkNonVirtualGetConstReferenceMacro(name, type) ITK_DETAIL_GetConstReferenceMacroImpl(, , name, type)
1183#define itkGetConstReferenceMacro(name, type) ITK_DETAIL_GetConstReferenceMacroImpl(virtual, , name, type)
1185// Set an enum-typed member. Creates Set"name"(); avoids itkDebugMacro warnings
1186// on some compilers with non-specified enum types. Implementation detail; use the public wrappers below.
1187#define ITK_DETAIL_SetEnumMacroImpl(virtualKeyword, finalKeyword, name, type) \
1188 virtualKeyword void Set##name(const type _arg) finalKeyword \
1189 { \
1190 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1191 if (this->m_##name != _arg) \
1192 { \
1193 this->m_##name = _arg; \
1194 this->Modified(); \
1195 } \
1196 } \
1197 ITK_MACROEND_NOOP_STATEMENT
1198
1203#define itkVirtualSetEnumMacro(name, type) ITK_DETAIL_SetEnumMacroImpl(virtual, , name, type)
1204#define itkFinalSetEnumMacro(name, type) ITK_DETAIL_SetEnumMacroImpl(, final, name, type)
1205#define itkNonVirtualSetEnumMacro(name, type) ITK_DETAIL_SetEnumMacroImpl(, , name, type)
1206#define itkSetEnumMacro(name, type) ITK_DETAIL_SetEnumMacroImpl(virtual, , name, type)
1208
1209// Get an enum-typed member. Creates Get"name"(). Implementation detail; use the public wrappers below.
1210#define ITK_DETAIL_GetEnumMacroImpl(virtualKeyword, finalKeyword, name, type) \
1211 virtualKeyword type Get##name() const finalKeyword { return this->m_##name; } \
1212 ITK_MACROEND_NOOP_STATEMENT
1213
1217#define itkVirtualGetEnumMacro(name, type) ITK_DETAIL_GetEnumMacroImpl(virtual, , name, type)
1218#define itkFinalGetEnumMacro(name, type) ITK_DETAIL_GetEnumMacroImpl(, final, name, type)
1219#define itkNonVirtualGetEnumMacro(name, type) ITK_DETAIL_GetEnumMacroImpl(, , name, type)
1220#define itkGetEnumMacro(name, type) ITK_DETAIL_GetEnumMacroImpl(virtual, , name, type)
1222
1223// Set a std::string member from char*/std::string. Creates Set"name"(). Implementation detail; use the public wrappers
1224// below.
1225#define ITK_DETAIL_SetStringMacroImpl(virtualKeyword, finalKeyword, name) \
1226 virtualKeyword void Set##name(const char * _arg) finalKeyword \
1227 { \
1228 if (_arg && (_arg == this->m_##name)) \
1229 { \
1230 return; \
1231 } \
1232 if (_arg) \
1233 { \
1234 this->m_##name = _arg; \
1235 } \
1236 else \
1237 { \
1238 this->m_##name = ""; \
1239 } \
1240 this->Modified(); \
1241 } \
1242 virtualKeyword void Set##name(const std::string & _arg) finalKeyword { this->Set##name(_arg.c_str()); } \
1243 ITK_MACROEND_NOOP_STATEMENT
1244
1248#define itkVirtualSetStringMacro(name) ITK_DETAIL_SetStringMacroImpl(virtual, , name)
1249#define itkFinalSetStringMacro(name) ITK_DETAIL_SetStringMacroImpl(, final, name)
1250#define itkNonVirtualSetStringMacro(name) ITK_DETAIL_SetStringMacroImpl(, , name)
1251#define itkSetStringMacro(name) ITK_DETAIL_SetStringMacroImpl(virtual, , name)
1253
1254// Get a std::string member as const char*. Creates Get"name"(). Implementation detail; use the public wrappers below.
1255#define ITK_DETAIL_GetStringMacroImpl(virtualKeyword, finalKeyword, name) \
1256 virtualKeyword const char * Get##name() const finalKeyword { return this->m_##name.c_str(); } \
1257 ITK_MACROEND_NOOP_STATEMENT
1258
1262#define itkVirtualGetStringMacro(name) ITK_DETAIL_GetStringMacroImpl(virtual, , name)
1263#define itkFinalGetStringMacro(name) ITK_DETAIL_GetStringMacroImpl(, final, name)
1264#define itkNonVirtualGetStringMacro(name) ITK_DETAIL_GetStringMacroImpl(, , name)
1265#define itkGetStringMacro(name) ITK_DETAIL_GetStringMacroImpl(virtual, , name)
1267
1268// clang-format off
1269// Set a value constrained between min/max limits. Creates Set"name"(). Implementation detail; use the public wrappers below.
1270#define ITK_DETAIL_SetClampMacroImpl(virtualKeyword, finalKeyword, name, type, min, max) \
1271 virtualKeyword void Set##name(type _arg) finalKeyword \
1272 { \
1273 const type temp_extrema = (_arg <= min ? min : (_arg >= max ? max : _arg)); \
1274 itkDebugMacro("setting " << #name " to " << _arg); \
1275 ITK_GCC_PRAGMA_PUSH \
1276 ITK_GCC_SUPPRESS_Wfloat_equal \
1277 if (this->m_##name != temp_extrema) \
1278 { \
1279 this->m_##name = temp_extrema; \
1280 this->Modified(); \
1281 } \
1282 ITK_GCC_PRAGMA_POP \
1283 } \
1284 ITK_MACROEND_NOOP_STATEMENT
1285// clang-format on
1286
1290#define itkVirtualSetClampMacro(name, type, min, max) ITK_DETAIL_SetClampMacroImpl(virtual, , name, type, min, max)
1291#define itkFinalSetClampMacro(name, type, min, max) ITK_DETAIL_SetClampMacroImpl(, final, name, type, min, max)
1292#define itkNonVirtualSetClampMacro(name, type, min, max) ITK_DETAIL_SetClampMacroImpl(, , name, type, min, max)
1293#define itkSetClampMacro(name, type, min, max) ITK_DETAIL_SetClampMacroImpl(virtual, , name, type, min, max)
1295
1296// Set object pointer (Object reference-counted). Creates Set"name"(). Implementation detail; use the public wrappers
1297// below.
1298#define ITK_DETAIL_SetObjectMacroImpl(virtualKeyword, finalKeyword, name, type) \
1299 virtualKeyword void Set##name(type * _arg) finalKeyword \
1300 { \
1301 itkDebugMacro("setting " << #name " to " << _arg); \
1302 if (this->m_##name != _arg) \
1303 { \
1304 this->m_##name = _arg; \
1305 this->Modified(); \
1306 } \
1307 } \
1308 ITK_MACROEND_NOOP_STATEMENT
1309
1313#define itkVirtualSetObjectMacro(name, type) ITK_DETAIL_SetObjectMacroImpl(virtual, , name, type)
1314#define itkFinalSetObjectMacro(name, type) ITK_DETAIL_SetObjectMacroImpl(, final, name, type)
1315#define itkNonVirtualSetObjectMacro(name, type) ITK_DETAIL_SetObjectMacroImpl(, , name, type)
1316#define itkSetObjectMacro(name, type) ITK_DETAIL_SetObjectMacroImpl(virtual, , name, type)
1318// NOTE: A class can use either itkGetModifiableObjectMacro
1319// or itkGetObjectMacro, but not both.
1320// A class can use either itkGetModifiableObjectMacro
1321// or itkGetConstObjectMacro, but not both.
1322// If the desired behavior is to only provide const
1323// access to the itkObject ivar, then use itkGetConstObjectMacro,
1324// else use itkGetModifiableObjectMacro for read/write access to
1325// the ivar.
1326// It is permissible to use both itkGetObjectMacro and itkGetConstObjectMacro
1327// for backwards compatibility.
1328// If the ITK_LEGACY_REMOVE=FALSE, then it is
1329// permissible to use itkGetObjectMacro which
1330// defines both signatures itk::GetXXX() and
1331// itk::GetModifiableXXX()
1332
1333// Get a raw const pointer to an object. Creates Get"name"(). Implementation detail; use the public wrappers below.
1334#define ITK_DETAIL_GetConstObjectMacroImpl(virtualKeyword, finalKeyword, name, type) \
1335 virtualKeyword const type * Get##name() const finalKeyword { return this->m_##name.GetPointer(); } \
1336 ITK_MACROEND_NOOP_STATEMENT
1337
1341#define itkVirtualGetConstObjectMacro(name, type) ITK_DETAIL_GetConstObjectMacroImpl(virtual, , name, type)
1342#define itkFinalGetConstObjectMacro(name, type) ITK_DETAIL_GetConstObjectMacroImpl(, final, name, type)
1343#define itkNonVirtualGetConstObjectMacro(name, type) ITK_DETAIL_GetConstObjectMacroImpl(, , name, type)
1344#define itkGetConstObjectMacro(name, type) ITK_DETAIL_GetConstObjectMacroImpl(virtual, , name, type)
1346
1347// ITK_DETAIL_GetObjectMacroImpl / ITK_DETAIL_GetModifiableObjectMacroImpl are
1348// implementation details; use the public wrappers below.
1349#if defined(ITK_FUTURE_LEGACY_REMOVE)
1350// In the future, the itkGetObjectMacro will be deprecated with the ITK_LEGACY_REMOVE
1351// flag. For now, this very advanced feature is only available
1352// through manual setting of a compiler define -DITK_FUTURE_LEGACY_REMOVE
1353// ("/DITK_FUTURE_LEGACY_REMOVE /EHsc" with Visual Studio)
1354// to ease the transition from the historical GetObjectMacro to the GetModifiableObjectMacro
1355// Do not invoke ITK_DETAIL_GetObjectMacroImpl directly from user code; use the public wrappers below.
1356# define ITK_DETAIL_GetObjectMacroImpl(virtualKeyword, finalKeyword, name, type) \
1357 virtualKeyword type * Get##name() finalKeyword \
1358 { \
1359 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1360 } \
1361 ITK_MACROEND_NOOP_STATEMENT
1362
1363// Do not invoke ITK_DETAIL_GetModifiableObjectMacroImpl directly from user code; use the public wrappers below.
1364# define ITK_DETAIL_GetModifiableObjectMacroImpl(virtualKeyword, finalKeyword, name, type) \
1365 virtualKeyword type * GetModifiable##name() finalKeyword { return this->m_##name.GetPointer(); } \
1366 ITK_DETAIL_GetConstObjectMacroImpl(virtualKeyword, finalKeyword, name, type)
1367
1368#else // defined ( ITK_FUTURE_LEGACY_REMOVE )
1369// Get a raw pointer to an object. Creates Get"name"(). Implementation detail; use the public wrappers below.
1370# define ITK_DETAIL_GetObjectMacroImpl(virtualKeyword, finalKeyword, name, type) \
1371 virtualKeyword type * Get##name() finalKeyword { return this->m_##name.GetPointer(); } \
1372 ITK_MACROEND_NOOP_STATEMENT
1373
1374// Do not invoke ITK_DETAIL_GetModifiableObjectMacroImpl directly from user code; use the public wrappers below.
1375# define ITK_DETAIL_GetModifiableObjectMacroImpl(virtualKeyword, finalKeyword, name, type) \
1376 virtualKeyword type * GetModifiable##name() finalKeyword { return this->m_##name.GetPointer(); } \
1377 ITK_DETAIL_GetConstObjectMacroImpl(virtualKeyword, finalKeyword, name, type); \
1378 ITK_DETAIL_GetObjectMacroImpl(virtualKeyword, finalKeyword, name, type)
1379#endif // defined ( ITK_FUTURE_LEGACY_REMOVE )
1380
1386#define itkVirtualGetObjectMacro(name, type) ITK_DETAIL_GetObjectMacroImpl(virtual, , name, type)
1387#define itkFinalGetObjectMacro(name, type) ITK_DETAIL_GetObjectMacroImpl(, final, name, type)
1388#define itkNonVirtualGetObjectMacro(name, type) ITK_DETAIL_GetObjectMacroImpl(, , name, type)
1389#define itkGetObjectMacro(name, type) ITK_DETAIL_GetObjectMacroImpl(virtual, , name, type)
1390
1391#define itkVirtualGetModifiableObjectMacro(name, type) ITK_DETAIL_GetModifiableObjectMacroImpl(virtual, , name, type)
1392#define itkFinalGetModifiableObjectMacro(name, type) ITK_DETAIL_GetModifiableObjectMacroImpl(, final, name, type)
1393#define itkNonVirtualGetModifiableObjectMacro(name, type) ITK_DETAIL_GetModifiableObjectMacroImpl(, , name, type)
1394#define itkGetModifiableObjectMacro(name, type) ITK_DETAIL_GetModifiableObjectMacroImpl(virtual, , name, type)
1396
1397// For backwards compatibility define ITK_EXPORT to nothing
1398#define ITK_EXPORT
1399
1400
1401// Get a const reference to a smart pointer to an object. Creates Get"name"(). Implementation detail; use the public
1402// wrappers below.
1403#define ITK_DETAIL_GetConstReferenceObjectMacroImpl(virtualKeyword, finalKeyword, name, type) \
1404 virtualKeyword const typename type::Pointer & Get##name() const finalKeyword { return this->m_##name; } \
1405 ITK_MACROEND_NOOP_STATEMENT
1406
1410#define itkVirtualGetConstReferenceObjectMacro(name, type) \
1411 ITK_DETAIL_GetConstReferenceObjectMacroImpl(virtual, , name, type)
1412#define itkFinalGetConstReferenceObjectMacro(name, type) \
1413 ITK_DETAIL_GetConstReferenceObjectMacroImpl(, final, name, type)
1414#define itkNonVirtualGetConstReferenceObjectMacro(name, type) \
1415 ITK_DETAIL_GetConstReferenceObjectMacroImpl(, , name, type)
1416#define itkGetConstReferenceObjectMacro(name, type) ITK_DETAIL_GetConstReferenceObjectMacroImpl(virtual, , name, type)
1418
1419// Set a const object pointer (Object reference-counted). Creates Set"name"(). Implementation detail; use the public
1420// wrappers below.
1421#define ITK_DETAIL_SetConstObjectMacroImpl(virtualKeyword, finalKeyword, name, type) \
1422 virtualKeyword void Set##name(const type * _arg) finalKeyword \
1423 { \
1424 itkDebugMacro("setting " << #name " to " << _arg); \
1425 if (this->m_##name != _arg) \
1426 { \
1427 this->m_##name = _arg; \
1428 this->Modified(); \
1429 } \
1430 } \
1431 ITK_MACROEND_NOOP_STATEMENT
1432
1436#define itkVirtualSetConstObjectMacro(name, type) ITK_DETAIL_SetConstObjectMacroImpl(virtual, , name, type)
1437#define itkFinalSetConstObjectMacro(name, type) ITK_DETAIL_SetConstObjectMacroImpl(, final, name, type)
1438#define itkNonVirtualSetConstObjectMacro(name, type) ITK_DETAIL_SetConstObjectMacroImpl(, , name, type)
1439#define itkSetConstObjectMacro(name, type) ITK_DETAIL_SetConstObjectMacroImpl(virtual, , name, type)
1441// Create "name"On()/"name"Off(). Requires a Set method. Implementation detail; use the public wrappers below.
1442#define ITK_DETAIL_BooleanMacroImpl(virtualKeyword, finalKeyword, name) \
1443 virtualKeyword void name##On() finalKeyword { this->Set##name(true); } \
1444 virtualKeyword void name##Off() finalKeyword { this->Set##name(false); } \
1445 ITK_MACROEND_NOOP_STATEMENT
1446
1450#define itkVirtualBooleanMacro(name) ITK_DETAIL_BooleanMacroImpl(virtual, , name)
1451#define itkFinalBooleanMacro(name) ITK_DETAIL_BooleanMacroImpl(, final, name)
1452#define itkNonVirtualBooleanMacro(name) ITK_DETAIL_BooleanMacroImpl(, , name)
1453#define itkBooleanMacro(name) ITK_DETAIL_BooleanMacroImpl(virtual, , name)
1455
1464template <typename MemberContainerType, typename CopyFromValueType, typename LoopEndType>
1465bool
1466ContainerFillWithCheck(MemberContainerType & m, const CopyFromValueType & c, const LoopEndType N)
1467{
1468 bool value_updated = false;
1469 for (unsigned int i = 0; i < N; ++i)
1470 {
1471 ITK_GCC_PRAGMA_PUSH
1472 ITK_GCC_SUPPRESS_Wfloat_equal
1473 if (m[i] != c)
1474 {
1475 m[i] = c;
1476 value_updated = true;
1477 }
1478 ITK_GCC_PRAGMA_POP
1479 }
1480 return value_updated;
1481}
1482
1491template <typename MemberContainerType, typename CopyFromContainerType, typename LoopEndType>
1492bool
1493ContainerCopyWithCheck(MemberContainerType & m, const CopyFromContainerType & c, const LoopEndType N)
1494{
1495 bool value_updated = false;
1496 for (LoopEndType i = 0; i < N; ++i)
1497 {
1498 ITK_GCC_PRAGMA_PUSH
1499 ITK_GCC_SUPPRESS_Wfloat_equal
1500 if (m[i] != c[i])
1501 {
1502 m[i] = c[i];
1503 value_updated = true;
1504 }
1505 ITK_GCC_PRAGMA_POP
1506 }
1507 return value_updated;
1508}
1509
1510// clang-format off
1511// Copy `count` values into the object. Creates Set"name"(). Implementation detail; use the public wrappers below.
1512#define ITK_DETAIL_SetVectorMacroImpl(virtualKeyword, finalKeyword, name, type, count) \
1513 virtualKeyword void Set##name(type data[]) finalKeyword \
1514 { \
1515 if (ContainerCopyWithCheck(this->m_##name, data, count)) \
1516 { \
1517 this->Modified(); \
1518 } \
1519 } \
1520 ITK_MACROEND_NOOP_STATEMENT
1521// clang-format on
1522
1527#define itkVirtualSetVectorMacro(name, type, count) ITK_DETAIL_SetVectorMacroImpl(virtual, , name, type, count)
1528#define itkFinalSetVectorMacro(name, type, count) ITK_DETAIL_SetVectorMacroImpl(, final, name, type, count)
1529#define itkNonVirtualSetVectorMacro(name, type, count) ITK_DETAIL_SetVectorMacroImpl(, , name, type, count)
1530#define itkSetVectorMacro(name, type, count) ITK_DETAIL_SetVectorMacroImpl(virtual, , name, type, count)
1532
1533// Return pointer to type (array of type), for efficiency. Creates Get"name"(). Implementation detail; use the public
1534// wrappers below.
1535#define ITK_DETAIL_GetVectorMacroImpl(virtualKeyword, finalKeyword, name, type, count) \
1536 virtualKeyword type * Get##name() const finalKeyword { return this->m_##name; } \
1537 ITK_MACROEND_NOOP_STATEMENT
1538
1541#define itkVirtualGetVectorMacro(name, type, count) ITK_DETAIL_GetVectorMacroImpl(virtual, , name, type, count)
1542#define itkFinalGetVectorMacro(name, type, count) ITK_DETAIL_GetVectorMacroImpl(, final, name, type, count)
1543#define itkNonVirtualGetVectorMacro(name, type, count) ITK_DETAIL_GetVectorMacroImpl(, , name, type, count)
1544#define itkGetVectorMacro(name, type, count) ITK_DETAIL_GetVectorMacroImpl(virtual, , name, type, count)
1546
1551#define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1552
1559#define itkGPUKernelMacro(kernel) \
1560 kernel \
1561 { \
1562 public: \
1563 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1564 kernel() = delete; \
1565 ~kernel() = delete; \
1566 static const char * GetOpenCLSource(); \
1567 }
1569#define itkGetOpenCLSourceFromKernelMacro(kernel) \
1570 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); } \
1571 ITK_MACROEND_NOOP_STATEMENT
1572
1573// A useful macro in the PrintSelf method for printing member variables
1574// which are pointers to object based on the LightObject class.
1575#define itkPrintSelfObjectMacro(name) \
1576 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1577 { \
1578 os << indent << #name << ": (null)" << std::endl; \
1579 } \
1580 else \
1581 { \
1582 os << indent << #name << ": " << std::endl; \
1583 this->m_##name->Print(os, indent.GetNextIndent()); \
1584 } \
1585 ITK_MACROEND_NOOP_STATEMENT
1586
1587
1588// A useful macro in the PrintSelf method for printing boolean member
1589// variables.
1590#define itkPrintSelfBooleanMacro(name) \
1591 os << indent << #name << ": " << (this->m_##name ? "On" : "Off") << std::endl; \
1592 ITK_MACROEND_NOOP_STATEMENT
1593
1594
1595// Set a decorated output. Defines Set"name"Output() and Set"name"(value). Implementation detail; use the public
1596// wrappers below.
1597#define ITK_DETAIL_SetDecoratedOutputMacroImpl(virtualKeyword, finalKeyword, name, type) \
1598 virtualKeyword void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) finalKeyword \
1599 { \
1600 itkDebugMacro("setting output " #name " to " << _arg); \
1601 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1602 { \
1603 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1604 this->Modified(); \
1605 } \
1606 } \
1607 virtualKeyword void Set##name(const type & _arg) finalKeyword \
1608 { \
1609 using DecoratorType = SimpleDataObjectDecorator<type>; \
1610 itkDebugMacro("setting output " #name " to " << _arg); \
1611 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1612 if (output) \
1613 { \
1614 if (output->Get() == _arg) \
1615 { \
1616 return; \
1617 } \
1618 else \
1619 { \
1620 output->Set(_arg); \
1621 } \
1622 } \
1623 else \
1624 { \
1625 auto newOutput = DecoratorType::New(); \
1626 newOutput->Set(_arg); \
1627 this->Set##name##Output(newOutput); \
1628 } \
1629 } \
1630 ITK_MACROEND_NOOP_STATEMENT
1631
1634#define itkVirtualSetDecoratedOutputMacro(name, type) ITK_DETAIL_SetDecoratedOutputMacroImpl(virtual, , name, type)
1635#define itkFinalSetDecoratedOutputMacro(name, type) ITK_DETAIL_SetDecoratedOutputMacroImpl(, final, name, type)
1636#define itkNonVirtualSetDecoratedOutputMacro(name, type) ITK_DETAIL_SetDecoratedOutputMacroImpl(, , name, type)
1637#define itkSetDecoratedOutputMacro(name, type) ITK_DETAIL_SetDecoratedOutputMacroImpl(virtual, , name, type)
1639
1640// Get a decorated output. Defines Get"name"Output() and Get"name"(). Implementation detail; use the public wrappers
1641// below.
1642#define ITK_DETAIL_GetDecoratedOutputMacroImpl(virtualKeyword, finalKeyword, name, type) \
1643 virtualKeyword const SimpleDataObjectDecorator<type> * Get##name##Output() const finalKeyword \
1644 { \
1645 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1646 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1647 } \
1648 virtualKeyword const type & Get##name() const finalKeyword \
1649 { \
1650 itkDebugMacro("Getting output " #name); \
1651 using DecoratorType = SimpleDataObjectDecorator<type>; \
1652 const DecoratorType * output = \
1653 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1654 if (output == nullptr) \
1655 { \
1656 itkExceptionStringMacro("output" #name " is not set"); \
1657 } \
1658 return output->Get(); \
1659 } \
1660 ITK_MACROEND_NOOP_STATEMENT
1661
1664#define itkVirtualGetDecoratedOutputMacro(name, type) ITK_DETAIL_GetDecoratedOutputMacroImpl(virtual, , name, type)
1665#define itkFinalGetDecoratedOutputMacro(name, type) ITK_DETAIL_GetDecoratedOutputMacroImpl(, final, name, type)
1666#define itkNonVirtualGetDecoratedOutputMacro(name, type) ITK_DETAIL_GetDecoratedOutputMacroImpl(, , name, type)
1667#define itkGetDecoratedOutputMacro(name, type) ITK_DETAIL_GetDecoratedOutputMacroImpl(virtual, , name, type)
1669// ITK_FUTURE_DEPRECATED is only for internal use, within the implementation of ITK. It allows triggering "deprecated"
1670// warnings when legacy support is removed, which warn that a specific feature may be removed in the future.
1671#if defined(ITK_LEGACY_REMOVE) && !defined(ITK_LEGACY_SILENT)
1672# define ITK_FUTURE_DEPRECATED(message) [[deprecated(message)]]
1673#else
1674# define ITK_FUTURE_DEPRECATED(message)
1675#endif
1676
1677#if __cplusplus >= 202002L // ABI-neutral
1678# define ITK_NODISCARD(message) [[nodiscard(message)]]
1679#else
1680# define ITK_NODISCARD(message) [[nodiscard]]
1681#endif
1682
1683//-*-*-*
1684
1685#if defined(ITK_LEGACY_REMOVE)
1686# define itkExposeEnumValue(name) \
1687 static_assert(false, "ERROR: Replace static_cast<int>(name) with with proper enumeration instead of integer")
1688
1689# define ITK_NOEXCEPT_OR_THROW static_assert(false, "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT")
1690
1691# define ITK_DELETE_FUNCTION static_assert(false, "ERROR: ITK_DELETE_FUNCTION must be replaced with `= delete`"
1692# define ITK_CONSTEXPR_FUNC static_assert(false, "ERROR: ITK_CONSTEXPR_FUNC must be replaced with 'constexpr'")
1693# define ITK_CONSTEXPR_VAR static_assert(false, "ERROR: ITK_CONSTEXPR_VAR must be replaced with 'constexpr'")
1694
1695# define ITK_FALLTHROUGH static_assert(false, "ERROR: ITK_FALLTHROUGH must be replaced with '[[fallthrough]]'")
1696
1697// Defines which used to be in itk_compiler_detection.h
1698# define ITK_ALIGNAS static_assert(false, "ERROR: ITK_ALIGNAS must be replaced with 'alignas'")
1699# define ITK_ALIGNOF static_assert(false, "ERROR: ITK_ALIGNOF must be replaced with 'alignof'")
1700# define ITK_DEPRECATED static_assert(false, "ERROR: ITK_DEPRECATED must be replaced with '[[deprecated]]'")
1701# define ITK_DEPRECATED_MSG \
1702 static_assert(false, "ERROR: ITK_DEPRECATED_MSG must be replaced with '[[deprecated(MSG)]]'")
1703# define ITK_CONSTEXPR static_assert(false, "ERROR: ITK_CONSTEXPR must be replaced with 'constexpr'")
1704# define ITK_DELETED_FUNCTION static_assert(false, "ERROR: ITK_DELETED_FUNCTION must be replaced with '= delete'")
1705# define ITK_EXTERN_TEMPLATE static_assert(false, "ERROR: ITK_EXTERN_TEMPLATE must be replaced with 'extern'")
1706# define ITK_FINAL static_assert(false, "ERROR: ITK_FINAL must be replaced with 'final'")
1707# define ITK_NOEXCEPT static_assert(false, "ERROR: ITK_NOEXCEPT must be replaced with 'noexcept'")
1708# define ITK_NOEXCEPT_EXPR static_assert(false, "ERROR: ITK_NOEXCEPT_EXPR must be replaced with 'noexcept'")
1709# define ITK_NULLPTR static_assert(false, "ERROR: ITK_NULLPTR must be replaced with 'nullptr'")
1710# define ITK_OVERRIDE static_assert(false, "ERROR: ITK_OVERRIDE must be replaced with 'override'")
1711# define ITK_STATIC_ASSERT static_assert(false, "ERROR: ITK_STATIC_ASSERT must be replaced with 'static_assert'")
1712# define ITK_STATIC_ASSERT_MSG \
1713 static_assert(false, "ERROR: ITK_STATIC_ASSERT_MSG must be replaced with 'static_assert'")
1714# define ITK_THREAD_LOCAL static_assert(false, "ERROR: ITK_THREAD_LOCAL must be replaced with 'thread_local'")
1715
1716// A macro for methods which are const in ITKv5 and ITKv6 require const for functions
1717# define ITKv5_CONST static_assert(false, "ERROR: ITKv5_CONST must be replaced with 'const'")
1718
1719# define ITK_ITERATOR_VIRTUAL static_assert(false, "ERROR: ITK_ITERATOR_VIRTUAL must be removed'")
1720# define ITK_ITERATOR_OVERRIDE static_assert(false, "ERROR: ITK_ITERATOR_OVERRIDE must be removed")
1721# define ITK_ITERATOR_FINAL static_assert(false, "ERROR: ITK_ITERATOR_FINAL must be removed")
1722
1723#else
1724// DEPRECATED: These macros are left here for compatibility with remote modules.
1725// Once they have been removed from all known remote modules, this code should
1726// be removed.
1727
1728// Future remove `#define itkExposeEnumValue(name)`
1729// "Replace type of `name` with proper enumeration instead of integer.
1730# define itkExposeEnumValue(name) static_cast<int>(name)
1731
1732
1733# define ITK_NOEXCEPT_OR_THROW ITK_NOEXCEPT
1734
1735# define ITK_FALLTHROUGH [[fallthrough]]
1736
1737# define ITK_DELETE_FUNCTION = delete
1738
1739# define ITK_CONSTEXPR_FUNC constexpr
1740# define ITK_CONSTEXPR_VAR constexpr
1741
1742// Defines which used to be in itk_compiler_detection.h
1743# define ITK_ALIGNAS(X) alignas(X)
1744# define ITK_ALIGNOF(X) alignof(X)
1745# define ITK_DEPRECATED [[deprecated]]
1746# define ITK_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
1747# define ITK_CONSTEXPR constexpr
1748# define ITK_DELETED_FUNCTION = delete
1749# define ITK_EXTERN_TEMPLATE extern
1750# define ITK_FINAL final
1751# define ITK_NOEXCEPT noexcept
1752# define ITK_NOEXCEPT_EXPR(X) noexcept(X)
1753# define ITK_NULLPTR nullptr
1754# define ITK_OVERRIDE override
1755# define ITK_STATIC_ASSERT(X) static_assert(X, #X)
1756# define ITK_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
1757# define ITK_THREAD_LOCAL thread_local
1758
1759// A macro for methods which are const in after ITKv4
1760# define ITKv5_CONST const
1761
1762# define ITK_ITERATOR_VIRTUAL /*purposefully empty for ITKv6, iterators are not virtual for performance reasons*/
1763# define ITK_ITERATOR_OVERRIDE /*purposefully empty for ITKv6, iterators are not virtual for performance reasons*/
1764# define ITK_ITERATOR_FINAL /*purposefully empty for ITKv6, iterators are not virtual for performance reasons*/
1765#endif
1766
1767#define allow_inclusion_of_itkExceptionObject_h
1768// Must include itkExceptionObject.h at the end of the file
1769// because it depends on the macros defined above
1770#include "itkExceptionObject.h"
1771
1772
1773#undef allow_inclusion_of_itkExceptionObject_h
1774
1775
1776#include "itkPrintHelper.h"
1777#endif // itkMacro_h
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....