From 4b400752f9e986cdab877af354ec0b13392abaf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Mon, 7 Aug 2023 20:26:25 -0400 Subject: [PATCH] ENH: Add boolean macro to `TransformFileWriterTemplate::m_AppendMode` Add the boolean macro to the `itk::RegistrationParameterScalesEstimator::m_AppendMode` ivar. Use the setter and getter macros for the ivar. Deprecate the old API of the ivar. Check the expected values in the test using the appropriate testing macros. --- .../TransformBase/include/itkTransformFileWriter.h | 13 +++++++++---- .../src/itkTransformFileWriterSpecializations.cxx | 10 ++-------- .../test/itkTransformFileWriterTemplateTest.cxx | 13 +++++++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Modules/IO/TransformBase/include/itkTransformFileWriter.h b/Modules/IO/TransformBase/include/itkTransformFileWriter.h index 4302e6f0723..a507ed3a334 100644 --- a/Modules/IO/TransformBase/include/itkTransformFileWriter.h +++ b/Modules/IO/TransformBase/include/itkTransformFileWriter.h @@ -67,18 +67,23 @@ class ITKIOTransformBase_TEMPLATE_EXPORT TransformFileWriterTemplate : public Li /** Get the filename */ itkGetStringMacro(FileName); - /** Set/Get the write mode (append/overwrite) for the Filter */ +#if !defined(ITK_FUTURE_LEGACY_REMOVE) + /** Set/Get the write mode (append/overwrite) for the Filter. + * Deprecated. */ void SetAppendOff(); void SetAppendOn(); - void - SetAppendMode(bool mode); - bool GetAppendMode(); +#endif + + /** Set/Get the write mode (append/overwrite) for the filter. */ + itkSetMacro(AppendMode, bool); + itkGetConstMacro(AppendMode, bool); + itkBooleanMacro(AppendMode); /** Set/Get a boolean to use the compression or not. */ itkSetMacro(UseCompression, bool); diff --git a/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx b/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx index e69171576c9..8817908c9b2 100644 --- a/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx +++ b/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx @@ -37,6 +37,7 @@ TransformFileWriterTemplate::TransformFileWriterTemplate() template TransformFileWriterTemplate::~TransformFileWriterTemplate() = default; +#if !defined(ITK_FUTURE_LEGACY_REMOVE) /** Set the writer to append to the specified file */ template void @@ -54,14 +55,6 @@ TransformFileWriterTemplate::SetAppendOff() this->SetAppendMode(false); } -/** Set the writer mode (append/overwrite). */ -template -void -TransformFileWriterTemplate::SetAppendMode(bool mode) -{ - this->m_AppendMode = mode; -} - /** Get the writer mode. */ template bool @@ -69,6 +62,7 @@ TransformFileWriterTemplate::GetAppendMode() { return (this->m_AppendMode); } +#endif template <> void diff --git a/Modules/IO/TransformBase/test/itkTransformFileWriterTemplateTest.cxx b/Modules/IO/TransformBase/test/itkTransformFileWriterTemplateTest.cxx index 6f8c1b22158..2ce9513e195 100644 --- a/Modules/IO/TransformBase/test/itkTransformFileWriterTemplateTest.cxx +++ b/Modules/IO/TransformBase/test/itkTransformFileWriterTemplateTest.cxx @@ -32,6 +32,19 @@ itkTransformFileWriterTemplateTest(int, char *[]) auto useCompression = false; ITK_SET_GET_BOOLEAN(transformWriter, UseCompression, useCompression); + auto appendMode = false; + ITK_SET_GET_BOOLEAN(transformWriter, AppendMode, appendMode); + +#if !defined(ITK_FUTURE_LEGACY_REMOVE) + transformWriter->SetAppendOn(); + auto nonConstAppendMode = transformWriter->GetAppendMode(); + ITK_TEST_EXPECT_TRUE(nonConstAppendMode); + + transformWriter->SetAppendOff(); + nonConstAppendMode = transformWriter->GetAppendMode(); + ITK_TEST_EXPECT_TRUE(!nonConstAppendMode); +#endif + // trigger empty write exception ITK_TRY_EXPECT_EXCEPTION(transformWriter->Update());