From 4d14a4bf95f9f5d48a4cc37f48c4bbffc7066bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sat, 4 Feb 2023 12:03:26 -0500 Subject: [PATCH] ENH: Use a macro to print numeric traits values of objects Use a macro to print numeric traits values of objects. Avoids boilerplate code. Printed instances found using the regex: ``` os << indent << "(.*): " << static_cast::PrintType>(m_(.*)) << std::endl; ``` and substituted using itkPrintSelfNumericTraitsMacro\($3\, \$2\);. --- Modules/Core/Common/include/itkMacro.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Modules/Core/Common/include/itkMacro.h b/Modules/Core/Common/include/itkMacro.h index a2d3b7aefd2..549215fe882 100644 --- a/Modules/Core/Common/include/itkMacro.h +++ b/Modules/Core/Common/include/itkMacro.h @@ -1271,6 +1271,14 @@ compilers. ITK_MACROEND_NOOP_STATEMENT +// A useful macro in the PrintSelf method for printing member variables +// that require to be casted to the corresponding numeric value so that +// their numeric value gets printed. +#define itkPrintSelfNumericTraitsMacro(name, type) \ + os << indent << #name << ": " << static_cast::PrintType>(this->m_##name) << std::endl; \ + ITK_MACROEND_NOOP_STATEMENT + + /** Set a decorated output. This defines the Set"name"() and a Set"name"Output() method */ #define itkSetDecoratedOutputMacro(name, type) \ virtual void Set##name##Output(const SimpleDataObjectDecorator * _arg) \