Skip to content

Commit

Permalink
STYLE: Finalize ITKv5 const function API change
Browse files Browse the repository at this point in the history
The non-const API variants are no longer supported
at compiletime.

Replace 'ITKv5_CONST' with 'const'.
  • Loading branch information
hjmjohnson committed May 31, 2024
1 parent 303c73e commit 7bfecf3
Show file tree
Hide file tree
Showing 59 changed files with 74 additions and 67 deletions.
8 changes: 8 additions & 0 deletions Documentation/docs/migration_guides/itk_6_migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ re-flagged as `ITK_LEGACY_REMOVE`. There have been some other
deprecations and API changes. The new behavior is activated by setting
`ITK_LEGACY_REMOVE` to `ON`. By default, compatibility with v5 is retained
(`ITK_LEGACY_REMOVE=OFF`).


Require modern C++ language feature use
---------------------------------------

Many backward compatible/ forward enabling compiler features are now required to be used.

Replace `ITKv5_CONST` with `const`
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ImageSink
{}

void
VerifyInputInformation() ITKv5_CONST override;
VerifyInputInformation() const override;

void
BeforeStreamedGenerateData() override
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageSink.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ ImageSink<TInputImage>::GenerateNthInputRequestedRegion(unsigned int inputReques

template <typename TInputImage>
void
ImageSink<TInputImage>::VerifyInputInformation() ITKv5_CONST
ImageSink<TInputImage>::VerifyInputInformation() const
{
using ImageBaseType = const ImageBase<InputImageDimension>;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageToImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class ITK_TEMPLATE_EXPORT ImageToImageFilter
* \sa ProcessObject::VerifyInputInformation
*/
void
VerifyInputInformation() ITKv5_CONST override;
VerifyInputInformation() const override;

/** What is the input requested region that is required to produce
* the output requested region? The base assumption for image
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageToImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ ImageToImageFilter<TInputImage, TOutputImage>::PrintSelf(std::ostream & os, Inde

template <typename TInputImage, typename TOutputImage>
void
ImageToImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() ITKv5_CONST
ImageToImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() const
{

using ImageBaseType = const ImageBase<InputImageDimension>;
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -1373,11 +1373,11 @@ compilers.
# define ITK_ITERATOR_FINAL
#endif
#if defined(ITKV4_COMPATIBILITY)
// A macro for methods which are const in ITKv5, but not in ITKv4
# define ITKv5_CONST
#if defined(ITK_LEGACY_REMOVE)
// A macro for methods which are const in ITKv5 and ITKv6 require const for functions
# define ITKv5_CONST static_assert(false, "ERROR: ITKv5_CONST must be replaced with 'const'")
#else
// A macro for methods which are const in ITKv5, but not in ITKv4
// A macro for methods which are const in after ITKv4
# define ITKv5_CONST const
#endif
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkProcessObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ class ITKCommon_EXPORT ProcessObject : public Object
*
*/
virtual void
VerifyPreconditions() ITKv5_CONST;
VerifyPreconditions() const;

/** \brief Verifies that the inputs meta-data is consistent and valid
* for continued execution of the pipeline, throws an exception if
Expand All @@ -801,7 +801,7 @@ class ITKCommon_EXPORT ProcessObject : public Object
*
*/
virtual void
VerifyInputInformation() ITKv5_CONST;
VerifyInputInformation() const;

/** What is the input requested region that is required to produce the
* output requested region? By default, the largest possible region is
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/src/itkProcessObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ ProcessObject::PropagateResetPipeline()


void
ProcessObject::VerifyPreconditions() ITKv5_CONST
ProcessObject::VerifyPreconditions() const
{
/**
* Make sure that all the required named inputs are there and non null
Expand Down Expand Up @@ -1356,7 +1356,7 @@ ProcessObject::VerifyPreconditions() ITKv5_CONST


void
ProcessObject::VerifyInputInformation() ITKv5_CONST
ProcessObject::VerifyInputInformation() const
{}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ITK_TEMPLATE_EXPORT ComparisonImageFilter : public ImageToImageFilter<TInp
AfterThreadedGenerateData() override;

void
VerifyInputInformation() ITKv5_CONST override;
VerifyInputInformation() const override;

OutputPixelType m_DifferenceThreshold{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ ComparisonImageFilter<TInputImage, TOutputImage>::AfterThreadedGenerateData()

template <typename TInputImage, typename TOutputImage>
void
ComparisonImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() ITKv5_CONST
ComparisonImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() const
{
if (m_VerifyInputInformation)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class ITK_TEMPLATE_EXPORT TransformGeometryImageFilter : public InPlaceImageFilt
GenerateOutputInformation() override;

void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;

void
GenerateData() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TransformGeometryImageFilter<TInputImage, TOutputImage>::TransformGeometryImageF

template <typename TInputImage, typename TOutputImage>
void
TransformGeometryImageFilter<TInputImage, TOutputImage>::VerifyPreconditions() ITKv5_CONST
TransformGeometryImageFilter<TInputImage, TOutputImage>::VerifyPreconditions() const
{
Superclass::VerifyPreconditions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ITK_TEMPLATE_EXPORT ConvolutionImageFilterBase : public ImageToImageFilter
/** Default superclass implementation ensures that input images
* occupy same physical space. This is not needed for this filter. */
void
VerifyInputInformation() ITKv5_CONST override{};
VerifyInputInformation() const override{};

private:
bool m_Normalize{ false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class ITK_TEMPLATE_EXPORT MaskedFFTNormalizedCorrelationImageFilter

/** Overlap the VerifyInputInformation method */
void
VerifyInputInformation() ITKv5_CONST override;
VerifyInputInformation() const override;

/** Standard pipeline method.*/
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ MaskedFFTNormalizedCorrelationImageFilter<TInputImage, TOutputImage, TMaskImage>

template <typename TInputImage, typename TOutputImage, typename TMaskImage>
void
MaskedFFTNormalizedCorrelationImageFilter<TInputImage, TOutputImage, TMaskImage>::VerifyInputInformation() ITKv5_CONST
MaskedFFTNormalizedCorrelationImageFilter<TInputImage, TOutputImage, TMaskImage>::VerifyInputInformation() const
{
// Call the superclass' implementation of this method.
Superclass::VerifyInputInformation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class ITK_TEMPLATE_EXPORT DiffusionTensor3DReconstructionImageFilter
DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;

void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;

/** Enables backwards compatibility for enum values */
using GradientImageTypeEnumeration = DiffusionTensor3DReconstructionImageFilterEnums::GradientImageFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void
DiffusionTensor3DReconstructionImageFilter<TReferenceImagePixelType,
TGradientImagePixelType,
TTensorPixelType,
TMaskImageType>::VerifyPreconditions() ITKv5_CONST
TMaskImageType>::VerifyPreconditions() const
{
Superclass::VerifyPreconditions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class ITK_TEMPLATE_EXPORT FastMarchingUpwindGradientImageFilter : public FastMar
PrintSelf(std::ostream & os, Indent indent) const override;

virtual void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;

void
Initialize(LevelSetImageType *) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ FastMarchingUpwindGradientImageFilter<TLevelSet, TSpeedImage>::PrintSelf(std::os

template <typename TLevelSet, typename TSpeedImage>
void
FastMarchingUpwindGradientImageFilter<TLevelSet, TSpeedImage>::VerifyPreconditions() ITKv5_CONST
FastMarchingUpwindGradientImageFilter<TLevelSet, TSpeedImage>::VerifyPreconditions() const
{
Superclass::VerifyPreconditions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ITK_TEMPLATE_EXPORT JoinSeriesImageFilter : public ImageToImageFilter<TInp
* \sa ProcessObject::VerifyInputInformation
*/
void
VerifyInputInformation() ITKv5_CONST override;
VerifyInputInformation() const override;

/** Overrides GenerateOutputInformation() in order to produce
* an image which has a different information than the first input.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ JoinSeriesImageFilter<TInputImage, TOutputImage>::JoinSeriesImageFilter()

template <typename TInputImage, typename TOutputImage>
void
JoinSeriesImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() ITKv5_CONST
JoinSeriesImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() const
{

Superclass::VerifyInputInformation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ITK_TEMPLATE_EXPORT HessianToObjectnessMeasureImageFilter : public ImageTo
PrintSelf(std::ostream & os, Indent indent) const override;

void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;

void
DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ HessianToObjectnessMeasureImageFilter<TInputImage, TOutputImage>::HessianToObjec

template <typename TInputImage, typename TOutputImage>
void
HessianToObjectnessMeasureImageFilter<TInputImage, TOutputImage>::VerifyPreconditions() ITKv5_CONST
HessianToObjectnessMeasureImageFilter<TInputImage, TOutputImage>::VerifyPreconditions() const
{
Superclass::VerifyPreconditions();
if (m_ObjectDimension >= ImageDimension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ITK_TEMPLATE_EXPORT HoughTransform2DCirclesImageFilter

/** Verifies the preconditions of this filter. */
void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;

/** Method for evaluating the implicit function over the image. */
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ HoughTransform2DCirclesImageFilter<TInputPixelType, TOutputPixelType, TRadiusPix

template <typename TInputPixelType, typename TOutputPixelType, typename TRadiusPixelType>
void
HoughTransform2DCirclesImageFilter<TInputPixelType, TOutputPixelType, TRadiusPixelType>::VerifyPreconditions()
ITKv5_CONST
HoughTransform2DCirclesImageFilter<TInputPixelType, TOutputPixelType, TRadiusPixelType>::VerifyPreconditions() const
{
Superclass::VerifyPreconditions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class ITK_TEMPLATE_EXPORT UnsharpMaskImageFilter : public ImageToImageFilter<TIn
GenerateInputRequestedRegion() override;

void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;
void
GenerateData() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ UnsharpMaskImageFilter<TInputImage, TOutputImage, TInternalPrecision>::GenerateI

template <typename TInputImage, typename TOutputImage, typename TInternalPrecision>
void
UnsharpMaskImageFilter<TInputImage, TOutputImage, TInternalPrecision>::VerifyPreconditions() ITKv5_CONST
UnsharpMaskImageFilter<TInputImage, TOutputImage, TInternalPrecision>::VerifyPreconditions() const
{
Superclass::VerifyPreconditions();
if (m_Threshold < 0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ITK_TEMPLATE_EXPORT FrequencyBandImageFilter : public UnaryFrequencyDomain

/* Checks the logic of FrequencyThresholds. */
void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;

/* This is the box functor, which implements the filter's behavior. */
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ FrequencyBandImageFilter<TImageType, TFrequencyIterator>::SetFrequencyThresholds

template <typename TImageType, typename TFrequencyIterator>
void
FrequencyBandImageFilter<TImageType, TFrequencyIterator>::VerifyPreconditions() ITKv5_CONST
FrequencyBandImageFilter<TImageType, TFrequencyIterator>::VerifyPreconditions() const
{
this->Superclass::VerifyPreconditions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class ITK_TEMPLATE_EXPORT ChangeInformationImageFilter : public ImageToImageFilt
* \sa ProcessObject::VerifyInputInformation
*/
void
VerifyInputInformation() ITKv5_CONST override
VerifyInputInformation() const override
{}

private:
Expand Down
2 changes: 1 addition & 1 deletion Modules/Filtering/ImageGrid/include/itkCropImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ITK_TEMPLATE_EXPORT CropImageFilter : public ExtractImageFilter<TInputImag
GenerateOutputInformation() override;

void
VerifyInputInformation() ITKv5_CONST override;
VerifyInputInformation() const override;

private:
SizeType m_UpperBoundaryCropSize{};
Expand Down
2 changes: 1 addition & 1 deletion Modules/Filtering/ImageGrid/include/itkCropImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CropImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()

template <typename TInputImage, typename TOutputImage>
void
CropImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() ITKv5_CONST
CropImageFilter<TInputImage, TOutputImage>::VerifyInputInformation() const
{
Superclass::VerifyInputInformation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class ITK_TEMPLATE_EXPORT InterpolateImagePointsFilter : public ImageToImageFilt
* \sa ProcessObject::VerifyInputInformation
*/
void
VerifyInputInformation() ITKv5_CONST override
VerifyInputInformation() const override
{}

private:
Expand Down
4 changes: 2 additions & 2 deletions Modules/Filtering/ImageGrid/include/itkPasteImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ class ITK_TEMPLATE_EXPORT PasteImageFilter : public InPlaceImageFilter<TInputIma
* \sa ProcessObject::VerifyInputInformation
*/
void
VerifyInputInformation() ITKv5_CONST override
VerifyInputInformation() const override
{}

void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;

bool
CanRunInPlace() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ PasteImageFilter<TInputImage, TSourceImage, TOutputImage>::GenerateInputRequeste

template <typename TInputImage, typename TSourceImage, typename TOutputImage>
void
PasteImageFilter<TInputImage, TSourceImage, TOutputImage>::VerifyPreconditions() ITKv5_CONST
PasteImageFilter<TInputImage, TSourceImage, TOutputImage>::VerifyPreconditions() const
{
Superclass::VerifyPreconditions();

Expand Down
4 changes: 2 additions & 2 deletions Modules/Filtering/ImageGrid/include/itkResampleImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class ITK_TEMPLATE_EXPORT ResampleImageFilter : public ImageToImageFilter<TInput
/* See superclass for doxygen. This method adds the additional check
* that the output space is set */
void
VerifyPreconditions() ITKv5_CONST override;
VerifyPreconditions() const override;

/** Get/Set the coordinate transformation.
* Set the coordinate transform to use for resampling. Note that this must
Expand Down Expand Up @@ -288,7 +288,7 @@ class ITK_TEMPLATE_EXPORT ResampleImageFilter : public ImageToImageFilter<TInput
* \sa ProcessObject::VerifyInputInformation
*/
void
VerifyInputInformation() ITKv5_CONST override
VerifyInputInformation() const override
{}

/** ResampleImageFilter produces an image which is a different size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ template <typename TInputImage,
typename TTransformPrecisionType>
void
ResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType, TTransformPrecisionType>::
VerifyPreconditions() ITKv5_CONST
VerifyPreconditions() const
{
this->Superclass::VerifyPreconditions();
const ReferenceImageBaseType * const referenceImage = this->GetReferenceImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class ITK_TEMPLATE_EXPORT SliceBySliceImageFilter : public ImageToImageFilter<TI
~SliceBySliceImageFilter() override = default;

void
VerifyInputInformation() ITKv5_CONST override;
VerifyInputInformation() const override;

void
GenerateData() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SliceBySliceImageFilter<TInputImage,
TInputFilter,
TOutputFilter,
TInternalInputImageType,
TInternalOutputImageType>::VerifyInputInformation() ITKv5_CONST
TInternalOutputImageType>::VerifyInputInformation() const
{

Superclass::VerifyInputInformation();
Expand Down
Loading

0 comments on commit 7bfecf3

Please sign in to comment.