Skip to content

Commit

Permalink
ENH: Add boolean macro to TransformFileWriterTemplate::m_AppendMode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhlegarreta authored and dzenanz committed Nov 21, 2023
1 parent b48c999 commit 4b40075
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
13 changes: 9 additions & 4 deletions Modules/IO/TransformBase/include/itkTransformFileWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ TransformFileWriterTemplate<TParametersValueType>::TransformFileWriterTemplate()
template <typename TParametersValueType>
TransformFileWriterTemplate<TParametersValueType>::~TransformFileWriterTemplate() = default;

#if !defined(ITK_FUTURE_LEGACY_REMOVE)
/** Set the writer to append to the specified file */
template <typename TParametersValueType>
void
Expand All @@ -54,21 +55,14 @@ TransformFileWriterTemplate<TParametersValueType>::SetAppendOff()
this->SetAppendMode(false);
}

/** Set the writer mode (append/overwrite). */
template <typename TParametersValueType>
void
TransformFileWriterTemplate<TParametersValueType>::SetAppendMode(bool mode)
{
this->m_AppendMode = mode;
}

/** Get the writer mode. */
template <typename TParametersValueType>
bool
TransformFileWriterTemplate<TParametersValueType>::GetAppendMode()
{
return (this->m_AppendMode);
}
#endif

template <>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 4b40075

Please sign in to comment.