ITK  5.2.0
Insight Toolkit
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  * http://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  *=========================================================================*/
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 
59 namespace itk
60 {
61 // end namespace itk - this is here for documentation purposes
62 }
63 
66 #define itkNotUsed(x)
67 
68 // clang-format off
69 
79 # define ITK_NOOP_STATEMENT static_assert(true, "")
80 
81 
82 #if defined(ITK_FUTURE_LEGACY_REMOVE)
83 
84 # define ITK_MACROEND_NOOP_STATEMENT ITK_NOOP_STATEMENT
85 #else
86  /* NOTE: The ITK_MACROEND_NOOP_STATEMENT must be defined to nothing
87  * in order to maintain backwards compatibility with earlier macro
88  * uses that may or may not have ';' after the macro is used. */
89  /* Purposefully empty */
90 # define ITK_MACROEND_NOOP_STATEMENT
91 #endif
92 // clang-format on
93 
94 // Define ITK_PRAGMA macro.
95 //
96 // It sets "#pragma" preprocessor directives without expecting the arguments
97 // to be quoted.
98 #define ITK_PRAGMA(x) _Pragma(#x)
99 
100 // The clang compiler has many useful non-default compiler warnings
101 // that tend to have a high false positive rate.
102 // The following set of defines allows us to suppress false positives
103 // and still track down suspicious code
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")
109 # else
110 # define CLANG_SUPPRESS_Wfloat_equal
111 # endif
112 # if __has_warning("-Wc++14-extensions")
113 # define CLANG_SUPPRESS_Wc__14_extensions ITK_PRAGMA(clang diagnostic ignored "-Wc++14-extensions")
114 # else
115 # define CLANG_SUPPRESS_Wc__14_extensions
116 # endif
117 #else
118 # define CLANG_PRAGMA_PUSH
119 # define CLANG_PRAGMA_POP
120 # define CLANG_SUPPRESS_Wfloat_equal
121 # define CLANG_SUPPRESS_Wc__14_extensions
122 #endif
123 
124 // Intel compiler convenience macros
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)
129 #else
130 # define INTEL_PRAGMA_WARN_PUSH
131 # define INTEL_PRAGMA_WARN_POP
132 # define INTEL_SUPPRESS_warning_1292
133 #endif
134 
135 // Define ITK_GCC_PRAGMA_DIAG(param1 [param2 [...]]) macro.
136 //
137 // This macro sets a pragma diagnostic
138 //
139 // Define ITK_GCC_PRAGMA_DIAG_(PUSH|POP) macros.
140 //
141 // These macros respectively push and pop the diagnostic context
142 //
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)
147 #else
148 # define ITK_GCC_PRAGMA_DIAG(x)
149 # define ITK_GCC_PRAGMA_DIAG_PUSH()
150 # define ITK_GCC_PRAGMA_DIAG_POP()
151 #endif
152 
153 /*
154  * ITK only supports MSVC++ 14.0 and greater
155  * MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015 version 14.0)
156  * MSVC++ 14.1 _MSC_VER == 1910 (Visual Studio 2017 version 15.0)
157  * MSVC++ 14.11 _MSC_VER == 1911 (Visual Studio 2017 version 15.3)
158  * MSVC++ 14.12 _MSC_VER == 1912 (Visual Studio 2017 version 15.5)
159  * MSVC++ 14.13 _MSC_VER == 1913 (Visual Studio 2017 version 15.6)
160  * MSVC++ 14.14 _MSC_VER == 1914 (Visual Studio 2017 version 15.7)
161  * MSVC++ 14.15 _MSC_VER == 1915 (Visual Studio 2017 version 15.8)
162  * MSVC++ 14.16 _MSC_VER == 1916 (Visual Studio 2017 version 15.9)
163  * MSVC++ 14.2 _MSC_VER == 1920 (Visual Studio 2019 Version 16.0)
164  */
165 #if defined(_MSC_VER) && (_MSC_VER < 1900)
166 # error "Visual Studio < 2015 is not supported under ITKv5"
167 #endif
168 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
169 # error "SUNPro C++ < 5.14.0 is not supported under ITKv5 and above"
170 #endif
171 #if defined(__CYGWIN__)
172 # error "The Cygwin compiler is not supported in ITKv4 and above"
173 #endif
174 #if defined(__BORLANDC__)
175 # error "The Borland C compiler is not supported in ITKv4 and above"
176 #endif
177 #if defined(__MWERKS__)
178 # error "The MetroWerks compiler is not supported in ITKv4 and above"
179 #endif
180 #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && \
181  ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 8)))
182 # error "GCC < 4.8 is not supported under ITKv5"
183 #endif
184 #if defined(__sgi)
185 // This is true for IRIX 6.5.18m with MIPSPro 7.3.1.3m.
186 // TODO: At some future point, it may be necessary to
187 // define a minimum __sgi version that will work.
188 # error "The SGI compiler is not supported under ITKv4 and above"
189 #endif
190 #if defined(__APPLE__)
191 # if defined(__clang__) && (__cplusplus < 201103L)
192 # error "Apple LLVM < 5.0 (clang < 3.3) is not supported under ITKv5"
193 # endif
194 #elif defined(__clang__) && ((__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3)))
195 # error "Clang < 3.3 is not supported under ITKv5"
196 #endif
197 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1504)
198 # error "Intel C++ < 15.0.4 is not supported under ITKv5"
199 #endif
200 
201 // Setup symbol exports
202 #if defined(_WIN32) || defined(WIN32)
203 # define ITK_ABI_IMPORT __declspec(dllimport)
204 # define ITK_ABI_EXPORT __declspec(dllexport)
205 # define ITK_ABI_HIDDEN
206 #else
207 # if __GNUC__ >= 4
208 # define ITK_ABI_IMPORT __attribute__((visibility("default")))
209 # define ITK_ABI_EXPORT __attribute__((visibility("default")))
210 # define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
211 # else
212 # define ITK_ABI_IMPORT
213 # define ITK_ABI_EXPORT
214 # define ITK_ABI_HIDDEN
215 # endif
216 #endif
217 
218 // Setup symbol exports
219 #ifndef ITK_TEMPLATE_EXPORT
220 # ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
221 # define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
222 # else
223 # define ITK_TEMPLATE_EXPORT
224 # endif
225 #endif
226 
227 // Setup symbol exports
228 #ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
229 # define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
230 #else
231 # define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
232 #endif
233 
234 #ifndef ITK_FORWARD_EXPORT
235 // If build with shared libraries, on MacOS, if USE_COMPILER_HIDDEN_VISIBILITY is ON
236 # if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
237  defined(USE_COMPILER_HIDDEN_VISIBILITY)
238 # define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
239 # else
240 # define ITK_FORWARD_EXPORT
241 # endif
242 #endif
243 
244 
245 //-*-*-*
246 // The following deprecations should be removed in ITKV6 and later
247 // NOTE DEPRECATED should be ITK_NOEXCEPT
248 #define ITK_NOEXCEPT_OR_THROW error "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT"
249 // NOTE DEPRECATED! should be ITK_COMPILER_CXX_STATIC_ASSERT
250 #if !defined(ITK_LEGACY_REMOVE)
251 # define ITK_DELETE_FUNCTION = delete
252 #else
253 # define ITK_DELETE_FUNCTION error "Replace ITK_DELETE_FUNCTION with = delete"
254 #endif
255 //-*-*-*
256 
257 // DEPRECATED: These macros are left here for compatibility with remote modules.
258 // Once they have been removed from all known remote modules, this code should
259 // be removed.
260 #if defined(ITK_FUTURE_LEGACY_REMOVE)
261 # define ITK_CONSTEXPR_FUNC "Replace ITK_CONSTEXPR_FUNC with constexpr"
262 # define ITK_CONSTEXPR_VAR "Replace ITK_CONSTEXPR_VAR with constexpr"
263 
264 # define itkExposeEnumValue(name) static_cast<int>(name)
265 // Future remove# define itkExposeEnumValue(name) "Replace type of " # name " with proper enumeration instead of
266 // integer."
267 #else
268 # define ITK_CONSTEXPR_FUNC constexpr
269 # define ITK_CONSTEXPR_VAR constexpr
270 
272 # define itkExposeEnumValue(name) static_cast<int>(name)
273 #endif
274 
275 // Use "ITK_FALLTHROUGH;" to annotate deliberate fall-through in switches,
276 // use it analogously to "break;". The trailing semi-colon is required.
277 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
278 # if (__GNUC__ >= 7)
279 # define ITK_FALLTHROUGH __attribute__((fallthrough))
280 # endif
281 #elif defined(__has_warning)
282 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
283 # define ITK_FALLTHROUGH [[clang::fallthrough]]
284 # endif
285 #endif
286 
287 #ifndef ITK_FALLTHROUGH
288 # define ITK_FALLTHROUGH ((void)0)
289 #endif
290 
311 #define itkNewMacro(x) \
312  itkSimpleNewMacro(x); \
313  itkCreateAnotherMacro(x); \
314  itkCloneMacro(x); \
315  ITK_MACROEND_NOOP_STATEMENT
316 
317 
318 #define itkSimpleNewMacro(x) \
319  static Pointer New() \
320  { \
321  Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
322  if (smartPtr == nullptr) \
323  { \
324  smartPtr = new x; \
325  } \
326  smartPtr->UnRegister(); \
327  return smartPtr; \
328  } \
329  ITK_MACROEND_NOOP_STATEMENT
330 
331 #define itkCreateAnotherMacro(x) \
332  ::itk::LightObject::Pointer CreateAnother() const override \
333  { \
334  ::itk::LightObject::Pointer smartPtr; \
335  smartPtr = x::New().GetPointer(); \
336  return smartPtr; \
337  } \
338  ITK_MACROEND_NOOP_STATEMENT
339 
340 #define itkCloneMacro(x) \
341  Pointer Clone() const \
342  { \
343  Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
344  return rval; \
345  } \
346  ITK_MACROEND_NOOP_STATEMENT
347 
360 #define itkFactorylessNewMacro(x) \
361  static Pointer New() \
362  { \
363  Pointer smartPtr; \
364  x * rawPtr = new x; \
365  smartPtr = rawPtr; \
366  rawPtr->UnRegister(); \
367  return smartPtr; \
368  } \
369  ::itk::LightObject::Pointer CreateAnother() const override \
370  { \
371  ::itk::LightObject::Pointer smartPtr; \
372  smartPtr = x::New().GetPointer(); \
373  return smartPtr; \
374  } \
375  ITK_MACROEND_NOOP_STATEMENT
376 
377 
378 //
379 // A macro to disallow the copy constructor, copy assignment,
380 // move constructor, and move assignment functions.
381 // This should be used in the public: declarations for a class
382 //
383 // ITK's paradigm for smart pointer and pipeline consistency
384 // prohibits the use of copy/move construction and copy/move assignment
385 // functions.
386 //
387 #define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
388  TypeName(const TypeName &) = delete; \
389  TypeName & operator=(const TypeName &) = delete; \
390  TypeName(TypeName &&) = delete; \
391  TypeName & operator=(TypeName &&) = delete
392 
393 #if !defined(ITK_FUTURE_LEGACY_REMOVE)
394 # define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
395 #endif
396 
399 #define itkTypeMacro(thisClass, superclass) \
400  const char * GetNameOfClass() const override { return #thisClass; } \
401  ITK_MACROEND_NOOP_STATEMENT
402 
403 #define itkTypeMacroNoParent(thisClass) \
404  virtual const char * GetNameOfClass() const { return #thisClass; } \
405  ITK_MACROEND_NOOP_STATEMENT
406 
407 namespace itk
408 {
415 extern ITKCommon_EXPORT void
416 OutputWindowDisplayText(const char *);
418 
419 extern ITKCommon_EXPORT void
420 OutputWindowDisplayErrorText(const char *);
421 
422 extern ITKCommon_EXPORT void
423 OutputWindowDisplayWarningText(const char *);
424 
425 extern ITKCommon_EXPORT void
426 OutputWindowDisplayGenericOutputText(const char *);
427 
428 extern ITKCommon_EXPORT void
429 OutputWindowDisplayDebugText(const char *);
430 } // end namespace itk
431 
432 // The itkDebugStatement is to be used to protect code that is only used in the itkDebugMacro
436 #if defined(NDEBUG)
437 # define itkDebugMacro(x) ITK_NOOP_STATEMENT
438 # define itkDebugStatement(x) ITK_NOOP_STATEMENT
439 #else
440 # define itkDebugMacro(x) \
441  do \
442  { \
443  if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
444  { \
445  std::ostringstream itkmsg; \
446  itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
447  << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
448  ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
449  } \
450  } while (0)
451 
452 
453 // The itkDebugStatement is to be used to protect code that is only
454 // used in the itkDebugMacro
455 # define itkDebugStatement(x) x
456 #endif
457 
461 #define itkWarningMacro(x) \
462  do \
463  { \
464  if (::itk::Object::GetGlobalWarningDisplay()) \
465  { \
466  std::ostringstream itkmsg; \
467  itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
468  << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
469  ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
470  } \
471  } while (0)
472 
473 
474 #define itkWarningStatement(x) x
475 
476 #if defined(ITK_CPP_FUNCTION)
477 # if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
478 # define ITK_LOCATION __FUNCSIG__
479 # elif defined(__GNUC__)
480 # define ITK_LOCATION __PRETTY_FUNCTION__
481 # else
482 # define ITK_LOCATION __FUNCTION__
483 # endif
484 #else
485 # define ITK_LOCATION "unknown"
486 #endif
487 
488 #define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
489  namespace itk \
490  { \
491  class newexcp : public parentexcp \
492  { \
493  public: \
494  /* default message provides backward compatibility for a given exception type */ \
495  static constexpr const char * const default_exception_message = whatmessage; \
496  explicit newexcp(const char * file, \
497  unsigned int lineNumber = 0, \
498  const char * desc = "None", \
499  const char * loc = "Unknown") \
500  : parentexcp(std::string{ file }, lineNumber, std::string{ desc }, std::string{ loc }) \
501  {} \
502  explicit newexcp(std::string file, \
503  unsigned int lineNumber = 0, \
504  std::string desc = std::string{ "None" }, \
505  std::string loc = std::string{ "Unknown" }) \
506  : parentexcp(std::move(file), lineNumber, std::move(desc), std::move(loc)) \
507  {} \
508  itkTypeMacro(newexcp, parentexcp); \
509  }; \
510  } \
511  ITK_MACROEND_NOOP_STATEMENT
512 
513 
514 #define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
515  { \
516  std::ostringstream message; \
517  message << "itk::ERROR: " x; \
518  throw ::itk::ExceptionType( \
519  std::string{ __FILE__ }, __LINE__, std::string{ message.str() }, std::string{ ITK_LOCATION }); \
520  } \
521  ITK_MACROEND_NOOP_STATEMENT
522 
523 #define itkSpecializedExceptionMacro(ExceptionType) \
524  { \
525  itkSpecializedMessageExceptionMacro(ExceptionType, \
526  "itk::ERROR: " << ::itk::ExceptionType::default_exception_message); \
527  } \
528  ITK_MACROEND_NOOP_STATEMENT
529 
533 #define itkExceptionMacro(x) \
534  { \
535  itkSpecializedMessageExceptionMacro(ExceptionObject, \
536  "itk::ERROR: " << this->GetNameOfClass() << "(" << this << "): " x); \
537  } \
538  ITK_MACROEND_NOOP_STATEMENT
539 
540 
541 #define itkGenericExceptionMacro(x) \
542  { \
543  itkSpecializedMessageExceptionMacro(ExceptionObject, x); \
544  } \
545  ITK_MACROEND_NOOP_STATEMENT
546 
547 #define itkGenericOutputMacro(x) \
548  { \
549  if (::itk::Object::GetGlobalWarningDisplay()) \
550  { \
551  std::ostringstream itkmsg; \
552  itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" x << "\n\n"; \
553  ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str()); \
554  } \
555  } \
556  ITK_MACROEND_NOOP_STATEMENT
557 
558 //----------------------------------------------------------------------------
559 // Macros for simplifying the use of logging
560 //
561 #define itkLogMacro(x, y) \
562  { \
563  if (this->GetLogger()) \
564  { \
565  this->GetLogger()->Write(::itk::LoggerBase::x, y); \
566  } \
567  } \
568  ITK_MACROEND_NOOP_STATEMENT
569 
570 #define itkLogMacroStatic(obj, x, y) \
571  { \
572  if (obj->GetLogger()) \
573  { \
574  obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
575  } \
576  } \
577  ITK_MACROEND_NOOP_STATEMENT
578 
579 //----------------------------------------------------------------------------
580 // Setup legacy code policy.
581 //
582 // CMake options:
583 // - When ITK_LEGACY_REMOVE:BOOL=ON, legacy code is hidden, thus causing compiler errors for code that depends on it
584 // - When ITK_LEGACY_REMOVE:BOOL=OFF, and ITK_LEGACY_SILENT:BOOL=ON, use
585 // of legacy code will not produce compiler warnings.
586 // - When ITK_LEGACY_REMOVE:BOOL=OFF, and ITK_LEGACY_SILENT:BOOL=OFF, use
587 // of legacy code will produce compiler warnings
588 //
589 // ITK_LEGACY_SILENT silently use legacy code. The default is to warn about legacy code use.
590 //
591 // Source files that test the legacy code may define ITK_LEGACY_TEST
592 // like this:
593 //
594 // #define ITK_LEGACY_TEST
595 // #include "itkClassWithDeprecatedMethod.h"
596 //
597 // in order to silence the warnings for calling deprecated methods.
598 // No other source files in ITK should call the methods since they are
599 // provided only for compatibility with older user code.
600 
601 // Define itkLegacyMacro to mark legacy methods where they are
602 // declared in their class. Example usage:
603 //
604 // // \deprecated Replaced by MyOtherMethod() as of ITK 2.0.
605 // itkLegacyMacro(void MyMethod());
606 //
607 // See below for what to do for the method definition.
608 #if defined(ITK_LEGACY_REMOVE)
609 # define itkLegacyMacro(method) /* no ';' */
610 #else
611 # if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
612 // Provide legacy methods with no warnings.
613 # define itkLegacyMacro(method) method
614 # else
615 // Setup compile-time warnings for uses of deprecated methods if
616 // possible on this compiler.
617 # if defined(__GNUC__) && !defined(__INTEL_COMPILER)
618 # define itkLegacyMacro(method) method __attribute__((deprecated))
619 # elif defined(_MSC_VER)
620 # define itkLegacyMacro(method) __declspec(deprecated) method
621 # else
622 # define itkLegacyMacro(method) method
623 # endif
624 # endif
625 #endif
626 
627 // Macros to create runtime deprecation warning messages in function
628 // bodies. Example usage:
629 //
630 // #if !defined( ITK_LEGACY_REMOVE )
631 // void itkMyClass::MyOldMethod()
632 // {
633 // itkLegacyBodyMacro(itkMyClass::MyOldMethod, 2.0);
634 // }
635 //
636 // void itkMyClass::MyMethod()
637 // {
638 // itkLegacyReplaceBodyMacro(itkMyClass::MyMethod, 2.0,
639 // itkMyClass::MyOtherMethod);
640 // }
641 // #endif
642 //
643 // NOTE: These 4 macros itkLegacyBodyMacro, itkLegacyReplaceBodyMacro,
644 // itkGenericLegacyBodyMacro, and itkGenericLegacyReplaceBodyMacro
645 // are purposefully not defined when ITK_LEGACY_REMOVE is on,
646 // because these macros are only relevant inside code segments
647 // that are conditionally compiled only when ITK_LEGACY_REMOVE
648 // is off.
649 #if defined(ITK_LEGACY_SILENT)
650 # define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
651 # define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
652 # define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
653 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
654 #else
655 # define itkLegacyBodyMacro(method, version) \
656  itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
657 # define itkLegacyReplaceBodyMacro(method, version, replace) \
658  itkWarningMacro(#method " was deprecated for ITK " #version \
659  " and will be removed in a future version. Use " #replace " instead.")
660 # define itkGenericLegacyBodyMacro(method, version) \
661  itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
662 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
663  itkGenericOutputMacro(#method " was deprecated for ITK " #version \
664  " and will be removed in a future version. Use " #replace " instead.")
665 #endif
666 
667 // Most modern x86 CPUs have 64 byte aligned blocks which are used for
668 // the cache lines. By aligning multi-threaded structures with the
669 // cache lines, false shared can be reduced, and performance
670 // increased.
671 #define ITK_CACHE_LINE_ALIGNMENT 64
672 
673 //
674 // itkPadStruct will add padding to a structure to ensure a minimum size
675 // for ensuring that adjacent structures do not share CACHE lines.
676 // Each struct will take up some multiple of cacheline sizes.
677 // This is particularly useful for arrays of thread private variables.
678 //
679 #define itkPadStruct(mincachesize, oldtype, newtype) \
680  struct newtype : public oldtype \
681  { \
682  char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
683  };
684 
685 //
686 // itkAlignedTypedef is a macro which creates a new type to make a
687 // data structure aligned.
688 //
689 #if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
690 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
691 #elif defined(_MSC_VER)
692 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
693 #else
694 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
695 #endif
696 
697 #if defined(ITK_FUTURE_LEGACY_REMOVE)
698 //=============================================================================
699 /*
700 NOTE: DEPRECATED - This macro is not longer needed to support modern
701 compilers.
702 
703  Define a common way of declaring a templated function as a friend inside a class.
704  - ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENTS(T)
705 
706  The following templated function
707 
708  template <T>
709  T add(const T & a, const T & b);
710 
711  is declared as friend with
712 
713  class A
714  {
715  public:
716  friend Self add<>( const Self & a, const Self & b );
717  }
718 
719 */
720 # define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
721 #else // LEGACY_REMOVE
722 # define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
723 #endif
724 
725 //--------------------------------------------------------------------------------
726 // Helper macros for Template Meta-Programming techniques of for-loops
727 // unrolling
728 //--------------------------------------------------------------------------------
729 
730 //--------------------------------------------------------------------------------
731 // Macro that generates an unrolled for loop for assigning elements of one array
732 // to elements of another array The array are assumed to be of same length
733 // (dimension), and this is also assumed to be the value of NumberOfIterations.
734 // No verification of size is performed. Casting is performed as part of the
735 // assignment, by using the DestinationElementType as the casting type.
736 // Source and destination array types must have defined operator[] in their
737 // API.
738 #define itkForLoopAssignmentMacro( \
739  DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
740  for (unsigned int i = 0; i < NumberOfIterations; ++i) \
741  { \
742  DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
743  }
744 
745 //--------------------------------------------------------------------------------
746 // Macro that generates an unrolled for loop for rounding and assigning
747 // elements of one array to elements of another array The array are assumed to
748 // be of same length (dimension), and this is also assumed to be the value of
749 // NumberOfIterations. No verification of size is performed. Casting is
750 // performed as part of the assignment, by using the DestinationElementType as
751 // the casting type.
752 // Source and destination array types must have defined operator[] in their
753 // API.
754 #define itkForLoopRoundingAndAssignmentMacro( \
755  DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
756  for (unsigned int i = 0; i < NumberOfIterations; ++i) \
757  { \
758  DestinationArray[i] = itk::Math::Round<DestinationElementType>(SourceArray[i]); \
759  }
760 
761 // end of Template Meta Programming helper macros
762 
763 #ifndef NDEBUG
764 
765 # ifdef _POSIX_SOURCE
766 # define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
767 # else
768 # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
769 # endif
770 
771 #else
772 # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
773 #endif
774 
775 #define itkAssertOrThrowMacro(test, message) \
776  if (!(test)) \
777  { \
778  std::ostringstream msgstr; \
779  msgstr << message; \
780  itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
781  } \
782  ITK_MACROEND_NOOP_STATEMENT
783 
784 #ifndef NDEBUG
785 # define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
786 #else
787 # define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
788 #endif
789 
790 
791 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
792 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
793 // !! The ITK Get/Set Macros for various types !!
794 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
795 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
810 #define itkStaticConstMacro(name, type, value) static constexpr type name = value
811 
812 #define itkGetStaticConstMacro(name) (Self::name)
813 
815 #define itkSetInputMacro(name, type) \
816  virtual void Set##name(const type * _arg) \
817  { \
818  itkDebugMacro("setting input " #name " to " << _arg); \
819  if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
820  { \
821  this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
822  this->Modified(); \
823  } \
824  } \
825  ITK_MACROEND_NOOP_STATEMENT
826 
827 
829 #define itkGetInputMacro(name, type) \
830  virtual const type * Get##name() const \
831  { \
832  itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
833  return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
834  } \
835  ITK_MACROEND_NOOP_STATEMENT
836 
837 
838 // clang-format off
840 #define itkSetDecoratedInputMacro(name, type) \
841  virtual void Set##name##Input(const SimpleDataObjectDecorator<type> * _arg) \
842  { \
843  itkDebugMacro("setting input " #name " to " << _arg); \
844  if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
845  { \
846  this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
847  this->Modified(); \
848  } \
849  } \
850  virtual void Set##name(const SimpleDataObjectDecorator<type> * _arg) { this->Set##name##Input(_arg); } \
851  virtual void Set##name(const type & _arg) \
852  { \
853  using DecoratorType = SimpleDataObjectDecorator<type>; \
854  itkDebugMacro("setting input " #name " to " << _arg); \
855  const DecoratorType * oldInput = \
856  itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
857  CLANG_PRAGMA_PUSH \
858  CLANG_SUPPRESS_Wfloat_equal \
859  if (oldInput && oldInput->Get() == _arg) \
860  { \
861  return; \
862  } \
863  CLANG_PRAGMA_POP \
864  typename DecoratorType::Pointer newInput = DecoratorType::New(); \
865  newInput->Set(_arg); \
866  this->Set##name##Input(newInput); \
867  } \
868  ITK_MACROEND_NOOP_STATEMENT
869 // clang-format on
871 
873 #define itkGetDecoratedInputMacro(name, type) \
874  virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
875  { \
876  itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
877  return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
878  } \
879  virtual const type & Get##name() const \
880  { \
881  itkDebugMacro("Getting input " #name); \
882  using DecoratorType = SimpleDataObjectDecorator<type>; \
883  const DecoratorType * input = \
884  itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
885  if (input == nullptr) \
886  { \
887  itkExceptionMacro(<< "input" #name " is not set"); \
888  } \
889  return input->Get(); \
890  } \
891  ITK_MACROEND_NOOP_STATEMENT
892 
893 
896 #define itkSetGetDecoratedInputMacro(name, type) \
897  itkSetDecoratedInputMacro(name, type); \
898  itkGetDecoratedInputMacro(name, type)
899 
904 #define itkSetDecoratedObjectInputMacro(name, type) \
905  virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
906  { \
907  itkDebugMacro("setting input " #name " to " << _arg); \
908  if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
909  { \
910  this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
911  this->Modified(); \
912  } \
913  } \
914  virtual void Set##name(const type * _arg) \
915  { \
916  using DecoratorType = DataObjectDecorator<type>; \
917  itkDebugMacro("setting input " #name " to " << _arg); \
918  const DecoratorType * oldInput = \
919  itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
920  if (oldInput && oldInput->Get() == _arg) \
921  { \
922  return; \
923  } \
924  typename DecoratorType::Pointer newInput = DecoratorType::New(); \
925  newInput->Set(_arg); \
926  this->Set##name##Input(newInput); \
927  } \
928  ITK_MACROEND_NOOP_STATEMENT
929 
930 
935 #define itkGetDecoratedObjectInputMacro(name, type) \
936  virtual const DataObjectDecorator<type> * Get##name##Input() const \
937  { \
938  itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
939  return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
940  } \
941  virtual const type * Get##name() const \
942  { \
943  itkDebugMacro("Getting input " #name); \
944  using DecoratorType = DataObjectDecorator<type>; \
945  const DecoratorType * input = \
946  itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
947  if (input == nullptr) \
948  { \
949  return nullptr; \
950  } \
951  return input->Get(); \
952  } \
953  ITK_MACROEND_NOOP_STATEMENT
954 
955 
958 #define itkSetGetDecoratedObjectInputMacro(name, type) \
959  itkSetDecoratedObjectInputMacro(name, type); \
960  itkGetDecoratedObjectInputMacro(name, type)
961 
963 // clang-format off
964 #define itkSetMacro(name, type) \
965  virtual void Set##name(const type _arg) \
966  { \
967  itkDebugMacro("setting " #name " to " << _arg); \
968  CLANG_PRAGMA_PUSH \
969  CLANG_SUPPRESS_Wfloat_equal \
970  if (this->m_##name != _arg) \
971  { \
972  this->m_##name = _arg; \
973  this->Modified(); \
974  } \
975  CLANG_PRAGMA_POP \
976  } \
977  ITK_MACROEND_NOOP_STATEMENT
978 // clang-format on
979 
981 #define itkGetMacro(name, type) \
982  virtual type Get##name() { return this->m_##name; } \
983  ITK_MACROEND_NOOP_STATEMENT
984 
985 
989 #define itkGetConstMacro(name, type) \
990  virtual type Get##name() const { return this->m_##name; } \
991  ITK_MACROEND_NOOP_STATEMENT
992 
993 
998 #define itkGetConstReferenceMacro(name, type) \
999  virtual const type & Get##name() const { return this->m_##name; } \
1000  ITK_MACROEND_NOOP_STATEMENT
1001 
1002 
1007 #define itkSetEnumMacro(name, type) \
1008  virtual void Set##name(const type _arg) \
1009  { \
1010  itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1011  if (this->m_##name != _arg) \
1012  { \
1013  this->m_##name = _arg; \
1014  this->Modified(); \
1015  } \
1016  } \
1017  ITK_MACROEND_NOOP_STATEMENT
1018 
1019 
1024 #define itkGetEnumMacro(name, type) \
1025  virtual type Get##name() const { return this->m_##name; } \
1026  ITK_MACROEND_NOOP_STATEMENT
1027 
1028 
1032 #define itkSetStringMacro(name) \
1033  virtual void Set##name(const char * _arg) \
1034  { \
1035  if (_arg && (_arg == this->m_##name)) \
1036  { \
1037  return; \
1038  } \
1039  if (_arg) \
1040  { \
1041  this->m_##name = _arg; \
1042  } \
1043  else \
1044  { \
1045  this->m_##name = ""; \
1046  } \
1047  this->Modified(); \
1048  } \
1049  virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1050  ITK_MACROEND_NOOP_STATEMENT
1051 
1052 
1053 
1057 #define itkGetStringMacro(name) \
1058  virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1059  ITK_MACROEND_NOOP_STATEMENT
1060 
1061 // clang-format off
1065 #define itkSetClampMacro(name, type, min, max) \
1066  virtual void Set##name(type _arg) \
1067  { \
1068  const type temp_extrema = (_arg < min ? min : (_arg > max ? max : _arg)); \
1069  itkDebugMacro("setting " << #name " to " << _arg); \
1070  CLANG_PRAGMA_PUSH \
1071  CLANG_SUPPRESS_Wfloat_equal \
1072  if (this->m_##name != temp_extrema) \
1073  { \
1074  this->m_##name = temp_extrema; \
1075  this->Modified(); \
1076  } \
1077  CLANG_PRAGMA_POP \
1078  } \
1079  ITK_MACROEND_NOOP_STATEMENT
1080 // clang-format on
1082 
1083 // clang-format off
1084 // NOTE: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
1089 #define itkSetObjectMacro(name, type) \
1090  virtual void Set##name(type * _arg) \
1091  { \
1092  itkDebugMacro("setting " << #name " to " << _arg); \
1093  CLANG_PRAGMA_PUSH \
1094  CLANG_SUPPRESS_Wfloat_equal \
1095  if (this->m_##name != _arg) \
1096  { \
1097  this->m_##name = _arg; \
1098  this->Modified(); \
1099  } \
1100  CLANG_PRAGMA_POP \
1101  } \
1102  ITK_MACROEND_NOOP_STATEMENT
1103 // clang-format on
1105 
1114 // NOTE: A class can use either itkGetModifiableObjectMacro
1115 // or itkGetObjectMacro, but not both.
1116 // A class can use either itkGetModifiableObjectMacro
1117 // or itkGetConstObjectMacro, but not both.
1118 // If the desired behavior is to only provide const
1119 // access to the itkObject ivar, then use itkGetConstObjectMacro,
1120 // else use itkGetModifiableObjectMacro for read/write access to
1121 // the ivar.
1122 // It is permissible to use both itkGetObjectMacro and itkGetConstObjectMacro
1123 // for backwards compatibility.
1124 // If the ITK_LEGACY_REMOVE=FALSE, then it is
1125 // permissible to use itkGetObjectMacro which
1126 // defines both signatures itk::GetXXX() and
1127 // itk::GetModifiableXXX()
1128 
1131 #define itkGetConstObjectMacro(name, type) \
1132  virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1133  ITK_MACROEND_NOOP_STATEMENT
1134 
1135 
1136 #if defined(ITK_FUTURE_LEGACY_REMOVE)
1137 // In the future, the itkGetObjectMacro will be deprecated with the ITK_LEGACY_REMOVE
1138 // flag. For now, this very advanced feature is only available
1139 // through manual setting of a compiler define -DITK_FUTURE_LEGACY_REMOVE
1140 // ("/DITK_FUTURE_LEGACY_REMOVE /EHsc" with Visual Studio)
1141 // to ease the transition from the historical GetObjectMacro to the GetModifiableObjectMacro
1142 # define itkGetObjectMacro(name, type) \
1143  virtual type * Get##name() \
1144  { \
1145  purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1146  }
1147 
1148 # define itkGetModifiableObjectMacro(name, type) \
1149  virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1150  itkGetConstObjectMacro(name, type)
1151 
1152 #else // defined ( ITK_FUTURE_LEGACY_REMOVE )
1153 
1155 # define itkGetObjectMacro(name, type) \
1156  virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1157  ITK_MACROEND_NOOP_STATEMENT
1158 # define itkGetModifiableObjectMacro(name, type) \
1159  virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1160  itkGetConstObjectMacro(name, type); \
1161  itkGetObjectMacro(name, type)
1162 #endif // defined ( ITK_FUTURE_LEGACY_REMOVE )
1163 
1164 
1165 // For backwards compatibility define ITK_EXPORT to nothing
1166 #define ITK_EXPORT
1167 
1168 
1171 #define itkGetConstReferenceObjectMacro(name, type) \
1172  virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1173  ITK_MACROEND_NOOP_STATEMENT
1174 
1179 #define itkSetConstObjectMacro(name, type) \
1180  virtual void Set##name(const type * _arg) \
1181  { \
1182  itkDebugMacro("setting " << #name " to " << _arg); \
1183  if (this->m_##name != _arg) \
1184  { \
1185  this->m_##name = _arg; \
1186  this->Modified(); \
1187  } \
1188  } \
1189  ITK_MACROEND_NOOP_STATEMENT
1190 
1191 
1194 #define itkBooleanMacro(name) \
1195  virtual void name##On() { this->Set##name(true); } \
1196  virtual void name##Off() { this->Set##name(false); }
1197 
1198 
1199 // clang-format off
1203 #define itkSetVectorMacro(name, type, count) \
1204  virtual void Set##name(type data[]) \
1205  { \
1206  unsigned int i; \
1207  for (i = 0; i < count; i++) \
1208  { \
1209  CLANG_PRAGMA_PUSH \
1210  CLANG_SUPPRESS_Wfloat_equal \
1211  if (data[i] != this->m_##name[i]) \
1212  { \
1213  break; \
1214  } \
1215  CLANG_PRAGMA_POP \
1216  } \
1217  if (i < count) \
1218  { \
1219  this->Modified(); \
1220  for (i = 0; i < count; i++) \
1221  { \
1222  this->m_##name[i] = data[i]; \
1223  } \
1224  } \
1225  } \
1226  ITK_MACROEND_NOOP_STATEMENT
1227 // clang-format on
1229 
1232 #define itkGetVectorMacro(name, type, count) \
1233  virtual type * Get##name() const { return this->m_##name; } \
1234  ITK_MACROEND_NOOP_STATEMENT
1235 
1240 #define itkGPUKernelClassMacro(kernel) \
1241  kernel \
1242  { \
1243  public: \
1244  static const char * GetOpenCLSource(); \
1245  \
1246  private: \
1247  kernel(); \
1248  virtual ~kernel(); \
1249  kernel(const kernel &); \
1250  void operator=(const kernel &); \
1251  };
1252 
1253 
1254 #define itkGetOpenCLSourceFromKernelMacro(kernel) \
1255  static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); }
1256 
1257 // A useful macro in the PrintSelf method for printing member variables
1258 // which are pointers to object based on the LightObject class.
1259 #define itkPrintSelfObjectMacro(name) \
1260  if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1261  { \
1262  os << indent << #name << ": (null)" << std::endl; \
1263  } \
1264  else \
1265  { \
1266  os << indent << #name << ": " << std::endl; \
1267  this->m_##name->Print(os, indent.GetNextIndent()); \
1268  } \
1269  ITK_MACROEND_NOOP_STATEMENT
1270 
1271 
1273 #define itkSetDecoratedOutputMacro(name, type) \
1274  virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1275  { \
1276  itkDebugMacro("setting output " #name " to " << _arg); \
1277  if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1278  { \
1279  this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1280  this->Modified(); \
1281  } \
1282  } \
1283  virtual void Set##name(const type & _arg) \
1284  { \
1285  using DecoratorType = SimpleDataObjectDecorator<type>; \
1286  itkDebugMacro("setting output " #name " to " << _arg); \
1287  DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1288  if (output) \
1289  { \
1290  if (output->Get() == _arg) \
1291  { \
1292  return; \
1293  } \
1294  else \
1295  { \
1296  output->Set(_arg); \
1297  } \
1298  } \
1299  else \
1300  { \
1301  typename DecoratorType::Pointer newOutput = DecoratorType::New(); \
1302  newOutput->Set(_arg); \
1303  this->Set##name##Output(newOutput); \
1304  } \
1305  } \
1306  ITK_MACROEND_NOOP_STATEMENT
1307 
1308 
1310 #define itkGetDecoratedOutputMacro(name, type) \
1311  virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1312  { \
1313  itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1314  return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1315  } \
1316  virtual const type & Get##name() const \
1317  { \
1318  itkDebugMacro("Getting output " #name); \
1319  using DecoratorType = SimpleDataObjectDecorator<type>; \
1320  const DecoratorType * output = \
1321  itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1322  if (output == nullptr) \
1323  { \
1324  itkExceptionMacro(<< "output" #name " is not set"); \
1325  } \
1326  return output->Get(); \
1327  } \
1328  ITK_MACROEND_NOOP_STATEMENT
1329 
1330 
1331 
1341 #if defined(ITKV4_COMPATIBILITY)
1342 # define ITK_ITERATOR_VIRTUAL virtual
1343 # define ITK_ITERATOR_OVERRIDE override
1344 # define ITK_ITERATOR_FINAL
1345 #elif !defined(ITK_LEGACY_REMOVE)
1346 # define ITK_ITERATOR_VIRTUAL virtual
1347 # define ITK_ITERATOR_OVERRIDE override
1348 # define ITK_ITERATOR_FINAL final
1349 #else
1350 # define ITK_ITERATOR_VIRTUAL
1351 # define ITK_ITERATOR_OVERRIDE
1352 # define ITK_ITERATOR_FINAL
1353 #endif
1354 
1355 #if defined(ITKV4_COMPATIBILITY)
1356 // A macro for methods which are const in ITKv5, but not in ITKv4
1357 # define ITKv5_CONST
1358 #else
1359 // A macro for methods which are const in ITKv5, but not in ITKv4
1360 # define ITKv5_CONST const
1361 #endif
1362 
1363 #define itkExceptionObject_h
1364 #include "itkExceptionObject.h"
1365 #undef itkExceptionObject_h
1366 
itkExceptionObject.h
itkWin32Header.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24