Skip to content

Commit

Permalink
STYLE: Remove this->MakeOutput(0) calls from constructors
Browse files Browse the repository at this point in the history
Analogue to ITK pull request InsightSoftwareConsortium/ITK#4654

Following C++ Core Guidelines, February 15, 2024, "Don’t call virtual functions in constructors and destructors", https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-ctor-virtual
  • Loading branch information
N-Dekker committed May 10, 2024
1 parent b207c56 commit 637cf02
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions Common/ImageSamplers/itkImageSamplerBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,8 @@ template <class TInputImage>
ImageSamplerBase<TInputImage>::ImageSamplerBase()
{
this->ProcessObject::SetNumberOfRequiredInputs(1);

OutputVectorContainerPointer output = dynamic_cast<OutputVectorContainerType *>(this->MakeOutput(0).GetPointer());

this->ProcessObject::SetNumberOfRequiredOutputs(1);
this->ProcessObject::SetNthOutput(0, output.GetPointer());
this->ProcessObject::SetNthOutput(0, OutputVectorContainerType::New().GetPointer());

} // end Constructor

Expand Down
6 changes: 1 addition & 5 deletions Common/ImageSamplers/itkVectorContainerSource.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ namespace itk
template <class TOutputVectorContainer>
VectorContainerSource<TOutputVectorContainer>::VectorContainerSource()
{
// Create the output. We use static_cast<> here because we know the default
// output must be of type TOutputVectorContainer
OutputVectorContainerPointer output = static_cast<TOutputVectorContainer *>(this->MakeOutput(0).GetPointer());

this->ProcessObject::SetNumberOfRequiredOutputs(1);
this->ProcessObject::SetNthOutput(0, output.GetPointer());
this->ProcessObject::SetNthOutput(0, TOutputVectorContainer::New().GetPointer());

this->m_GenerateDataRegion = 0;
this->m_GenerateDataNumberOfRegions = 0;
Expand Down
4 changes: 1 addition & 3 deletions Common/itkMultiResolutionImageRegistrationMethod2.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ MultiResolutionImageRegistrationMethod2<TFixedImage, TMovingImage>::MultiResolut
this->m_InitialTransformParametersOfNextLevel.Fill(0.0f);
this->m_LastTransformParameters.Fill(0.0f);

TransformOutputPointer transformDecorator = static_cast<TransformOutputType *>(this->MakeOutput(0).GetPointer());

this->ProcessObject::SetNthOutput(0, transformDecorator.GetPointer());
this->ProcessObject::SetNthOutput(0, TransformOutputType::New().GetPointer());

} // end Constructor

Expand Down

0 comments on commit 637cf02

Please sign in to comment.