Skip to content

Commit

Permalink
STYLE: Avoid repeating parent aliases in operator classes
Browse files Browse the repository at this point in the history
Avoid repeating parent aliases in `Common` operator classes whenever
possible.

Use the preferred `using typename Superclass::{TypeAlias}` aliasing
form for the relevant type.

Make the `CoefficientVector` type be public in `itk::NeighborhoodOperator`
so that child classes can have access to it.
  • Loading branch information
jhlegarreta authored and dzenanz committed Sep 21, 2021
1 parent a4693b5 commit babece9
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 34 deletions.
9 changes: 4 additions & 5 deletions Modules/Core/Common/include/itkAnnulusOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class ITK_TEMPLATE_EXPORT AnnulusOperator : public NeighborhoodOperator<TPixel,

/** Additional type aliases. */
using PixelType = TPixel;
using SizeType = typename Superclass::SizeType;
using OffsetType = typename Superclass::OffsetType;
using typename Superclass::SizeType;
using typename Superclass::OffsetType;
using SpacingType = Vector<double, TDimension>;

/** Run-time type information (and related methods). */
Expand Down Expand Up @@ -222,9 +222,8 @@ class ITK_TEMPLATE_EXPORT AnnulusOperator : public NeighborhoodOperator<TPixel,
}

protected:
/** Typedef support for coefficient vector type. Necessary to
* work around compiler bug on VC++. */
using CoefficientVector = typename Superclass::CoefficientVector;
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Calculates operator coefficients. */
CoefficientVector
Expand Down
7 changes: 4 additions & 3 deletions Modules/Core/Common/include/itkBackwardDifferenceOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ class ITK_TEMPLATE_EXPORT BackwardDifferenceOperator : public NeighborhoodOperat
/** Run-time type information (and related methods). */
itkTypeMacro(BackwardDifferenceOperator, NeighborhoodOperator);

using PixelType = typename Superclass::PixelType;
/** Type alias support for pixel type. */
using PixelType = TPixel;

protected:
/** Necessary to work around a compiler bug in VC++. */
using CoefficientVector = typename Superclass::CoefficientVector;
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Calculates operator coefficients. */
CoefficientVector
Expand Down
9 changes: 4 additions & 5 deletions Modules/Core/Common/include/itkDerivativeOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class ITK_TEMPLATE_EXPORT DerivativeOperator : public NeighborhoodOperator<TPixe
/** Run-time type information (and related methods). */
itkTypeMacro(DerivativeOperator, NeighborhoodOperator);

using PixelType = TPixel;
using PixelRealType = typename Superclass::PixelRealType;
/** Type alias support for pixel real type.*/
using typename Superclass::PixelRealType;

/** Sets the order of the derivative. */
void
Expand All @@ -102,9 +102,8 @@ class ITK_TEMPLATE_EXPORT DerivativeOperator : public NeighborhoodOperator<TPixe
}

protected:
/** Typedef support for coefficient vector type. Necessary to
* work around compiler bug on VC++. */
using CoefficientVector = typename Superclass::CoefficientVector;
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Calculates operator coefficients. */
CoefficientVector
Expand Down
7 changes: 4 additions & 3 deletions Modules/Core/Common/include/itkForwardDifferenceOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ class ITK_TEMPLATE_EXPORT ForwardDifferenceOperator : public NeighborhoodOperato
/** Run-time type information (and related methods). */
itkTypeMacro(ForwardDifferenceOperator, NeighborhoodOperator);

using PixelType = typename Superclass::PixelType;
/** Type alias support for pixel type. */
using PixelType = TPixel;

protected:
/** Necessary to work around VC++ compiler bug. */
using CoefficientVector = typename Superclass::CoefficientVector;
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Calculates operator coefficients. */
CoefficientVector
Expand Down
3 changes: 2 additions & 1 deletion Modules/Core/Common/include/itkGaussianDerivativeOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ class ITK_TEMPLATE_EXPORT GaussianDerivativeOperator : public NeighborhoodOperat
PrintSelf(std::ostream & os, Indent i) const override;

protected:
using CoefficientVector = typename Superclass::CoefficientVector;
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Returns the value of the modified Bessel function I0(x) at a point x >= 0.
*/
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/include/itkGaussianOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ class ITK_TEMPLATE_EXPORT GaussianOperator : public NeighborhoodOperator<TPixel,
Superclass::PrintSelf(os, i.GetNextIndent());
}

protected:
using CoefficientVector = typename Superclass::CoefficientVector;

public:
/** Returns the value of the modified Bessel function I0(x) at a point x >= 0.
*/
Expand All @@ -161,6 +158,9 @@ class ITK_TEMPLATE_EXPORT GaussianOperator : public NeighborhoodOperator<TPixel,
ModifiedBesselI(int, double);

protected:
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Calculates operator coefficients. */
CoefficientVector
GenerateCoefficients() override;
Expand Down
5 changes: 3 additions & 2 deletions Modules/Core/Common/include/itkImageKernelOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class ITK_TEMPLATE_EXPORT ImageKernelOperator : public NeighborhoodOperator<TPix
using Superclass = NeighborhoodOperator<TPixel, VDimension, TAllocator>;

using ImageType = Image<TPixel, VDimension>;
using SizeType = typename Superclass::SizeType;
using CoefficientVector = typename Superclass::CoefficientVector;

/** Run-time type information (and related methods). */
itkTypeMacro(ImageKernelOperator, NeighborhoodOperator);
Expand All @@ -79,6 +77,9 @@ class ITK_TEMPLATE_EXPORT ImageKernelOperator : public NeighborhoodOperator<TPix
}

protected:
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Calculates operator coefficients. */
CoefficientVector
GenerateCoefficients() override;
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/include/itkLaplacianOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class ITK_TEMPLATE_EXPORT LaplacianOperator : public NeighborhoodOperator<TPixel
/** Run-time type information (and related methods). */
itkTypeMacro(LaplacianOperator, NeighborhoodOperator);

using PixelType = TPixel;
using SizeType = typename Superclass::SizeType;

LaplacianOperator()
Expand Down Expand Up @@ -105,9 +104,8 @@ class ITK_TEMPLATE_EXPORT LaplacianOperator : public NeighborhoodOperator<TPixel
itkGetConstMacro(DerivativeScalings, const double *);

protected:
/** Alias support for coefficient vector type. Necessary to
* work around compiler bug on VC++. */
using CoefficientVector = typename Superclass::CoefficientVector;
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Calculates operator coefficients. */
CoefficientVector
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkNeighborhoodOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class ITK_TEMPLATE_EXPORT NeighborhoodOperator : public Neighborhood<TPixel, VDi
/** Slice iterator type alias support */
using SliceIteratorType = SliceIterator<TPixel, Self>;

using PixelRealType = typename NumericTraits<TPixel>::RealType;

/** Sets the dimensional direction of a directional operator. */
void
SetDirection(const unsigned long & direction)
Expand Down Expand Up @@ -135,16 +137,14 @@ class ITK_TEMPLATE_EXPORT NeighborhoodOperator : public Neighborhood<TPixel, VDi
Superclass::PrintSelf(os, i.GetNextIndent());
}

using PixelRealType = typename NumericTraits<TPixel>::RealType;

/** Multiplies all of the coefficients of the kernel by a single scalar value.
*/
void ScaleCoefficients(PixelRealType);

protected:
/** Typedef support for coefficient vector type. Necessary
/** Type alias support for coefficient vector type. Necessary
* to fix bug in the microsoft VC++ compiler. */
using CoefficientVector = std::vector<PixelRealType>;
using CoefficientVector = typename std::vector<PixelRealType>;

/** A subclass-specific algorithm that computes the coefficients
* of the operator. */
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Common/include/itkSobelOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ class ITK_TEMPLATE_EXPORT SobelOperator : public NeighborhoodOperator<TPixel, VD
}

protected:
/** Alias support for coefficient vector type. Necessary to
* work around compiler bug on VC++. */
using CoefficientVector = typename Superclass::CoefficientVector;
using PixelType = typename Superclass::PixelType;
/** Type alias support for coefficient vector type.*/
using typename Superclass::CoefficientVector;

/** Calculates operator coefficients. */
CoefficientVector
Expand Down

0 comments on commit babece9

Please sign in to comment.