Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Use auto for declaration of variables initialized by New() #2826

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Examples/IO/XML/itkParticleSwarmOptimizerDOMReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ParticleSwarmOptimizerDOMReader::GenerateData(const DOMNodeType * inputdom,
if (output == nullptr)
{
logger->Info("creating the output PSO object ...\n");
OutputType::Pointer object = OutputType::New();
auto object = OutputType::New();
output = (OutputType *)object;
this->SetOutput(output);
}
Expand Down
6 changes: 3 additions & 3 deletions Examples/IO/XML/itkParticleSwarmOptimizerDOMWriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ ParticleSwarmOptimizerDOMWriter::GenerateData(DOMNodeType * outputdom,
}
// generate and insert the DOM node for the lower bound of the parameters
logger->Info("writing LowerBound ...\n");
DOMNode::Pointer nodelb = DOMNode::New();
auto nodelb = DOMNode::New();
nodelb->SetName("bound");
nodelb->SetAttribute("id", "lower");
nodelb->SetAttribute("value", s << ClearContent << lbound);
outputdom->AddChildAtEnd(nodelb);
// generate and insert the DOM node for the upper bound of the parameters
logger->Info("writing UpperBound ...\n");
DOMNode::Pointer nodeub = DOMNode::New();
auto nodeub = DOMNode::New();
nodeub->SetName("bound");
nodeub->SetAttribute("id", "upper");
nodeub->SetAttribute("value", s << ClearContent << ubound);
outputdom->AddChildAtEnd(nodeub);

logger->Info("writing ParametersConvergenceTolerance ...\n");
DOMNode::Pointer nodeptols = DOMNode::New();
auto nodeptols = DOMNode::New();
nodeptols->SetName("ParametersConvergenceTolerance");
outputdom->AddChildAtEnd(nodeptols);
s << ClearContent
Expand Down
6 changes: 3 additions & 3 deletions Modules/Bridge/NumPy/include/itkPyBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ PyBuffer<TImage>::_GetImageViewFromArray(PyObject * arr, PyObject * shape, PyObj

using InternalPixelType = typename TImage::InternalPixelType;
using ImporterType = ImportImageContainer<SizeValueType, InternalPixelType>;
typename ImporterType::Pointer importer = ImporterType::New();
constexpr bool importImageFilterWillOwnTheBuffer = false;
InternalPixelType * data = (InternalPixelType *)buffer;
auto importer = ImporterType::New();
constexpr bool importImageFilterWillOwnTheBuffer = false;
InternalPixelType * data = (InternalPixelType *)buffer;
importer->SetImportPointer(data, numberOfPixels, importImageFilterWillOwnTheBuffer);

OutputImagePointer output = TImage::New();
Expand Down
4 changes: 2 additions & 2 deletions Modules/Bridge/NumPy/include/itkPyVectorContainer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ PyVectorContainer<TElementIdentifier, TElement>::_vector_container_from_array(Py
PyBuffer_Release(&pyBuffer);
return nullptr;
}
DataType * data = (DataType *)buffer;
typename VectorContainerType::Pointer output = VectorContainerType::New();
DataType * data = (DataType *)buffer;
auto output = VectorContainerType::New();
output->resize(numberOfElements);
for (size_t ii = 0; ii < numberOfElements; ++ii)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ itkImageToVTKImageFilterRGBTest(int argc, char * argv[])
using ImageType = itk::Image<PixelType, Dimension>;

using ReaderType = itk::ImageFileReader<ImageType>;
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
reader->SetFileName(inputFileName);

using ConnectorType = itk::ImageToVTKImageFilter<ImageType>;
ConnectorType::Pointer connector = ConnectorType::New();
auto connector = ConnectorType::New();
connector->SetInput(reader->GetOutput());

connector->UpdateLargestPossibleRegion();
Expand Down
4 changes: 2 additions & 2 deletions Modules/Bridge/VtkGlue/test/itkImageToVTKImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ itkImageToVTKImageFilterTest(int, char *[])
size[0] = 40;
size[1] = 10;
size[2] = 20;
SourceType::Pointer source = SourceType::New();
auto source = SourceType::New();
source->SetSize(size);

SpacingType spacing;
Expand All @@ -61,7 +61,7 @@ itkImageToVTKImageFilterTest(int, char *[])
auto input = source->GetOutput();
input->Print(std::cout);

ConnectorType::Pointer connector = ConnectorType::New();
auto connector = ConnectorType::New();
connector->SetInput(input);
connector->UpdateLargestPossibleRegion();
connector->Update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ itkVTKImageToImageFilterTest(int, char *[])
#endif
input->Print(std::cout);

ConnectorType::Pointer connector = ConnectorType::New();
auto connector = ConnectorType::New();
connector->SetInput(input);
connector->Update();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ itkVtkConnectedComponentImageFilterTest(int argc, char * argv[])

using ReaderType = itk::ImageFileReader<InputImageType>;

ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
reader->SetFileName(argv[1]);

QuickView viewer;
Expand Down Expand Up @@ -111,10 +111,10 @@ itkVtkConnectedComponentImageFilterTest(int argc, char * argv[])
(*it).second->SetInput(reader->GetOutput());
(*it).second->Update();

ConnectedComponentImageFilterType::Pointer connected = ConnectedComponentImageFilterType::New();
auto connected = ConnectedComponentImageFilterType::New();
connected->SetInput((*it).second->GetOutput());

RGBFilterType::Pointer rgbFilter = RGBFilterType::New();
auto rgbFilter = RGBFilterType::New();
rgbFilter->SetInput(connected->GetOutput());
std::stringstream desc;
desc << (*it).first << " threshold = " << (*it).second->GetThreshold();
Expand Down
6 changes: 3 additions & 3 deletions Modules/Bridge/VtkGlue/test/itkVtkMedianFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ itkVtkMedianFilterTest(int argc, char * argv[])
using SubtractType = itk::SubtractImageFilter<ImageType>;

// Create and setup a reader
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
reader->SetFileName(inputFilename);

// Create and setup a median filter
FilterType::Pointer medianFilter = FilterType::New();
auto medianFilter = FilterType::New();
FilterType::InputSizeType radius;
radius.Fill(2);
if (argc > 2)
Expand All @@ -60,7 +60,7 @@ itkVtkMedianFilterTest(int argc, char * argv[])
medianFilter->SetRadius(radius);
medianFilter->SetInput(reader->GetOutput());

SubtractType::Pointer diff = SubtractType::New();
auto diff = SubtractType::New();
diff->SetInput1(reader->GetOutput());
diff->SetInput2(medianFilter->GetOutput());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ TreeIteratorBase<TTreeType>::Add(ValueType element)
return false;
}

typename TreeNodeType::Pointer node = TreeNodeType::New();
auto node = TreeNodeType::New();
node->Set(element);
m_Position->AddChild(node);
m_Tree->Modified();
Expand All @@ -133,7 +133,7 @@ TreeIteratorBase<TTreeType>::Add(int itkNotUsed(childPosition), ValueType elemen
{
if (m_Position)
{
typename TreeNodeType::Pointer node = TreeNodeType::New();
auto node = TreeNodeType::New();
node->Set(element);
m_Position->AddChild(node);
m_Tree->Modified();
Expand Down Expand Up @@ -210,7 +210,7 @@ template <typename TTreeType>
TTreeType *
TreeIteratorBase<TTreeType>::GetSubTree() const
{
typename TTreeType::Pointer tree = TTreeType::New();
auto tree = TTreeType::New();
tree->SetRoot(m_Position);
tree->SetSubtree(true);
return tree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ itkTreeContainerTest(int, char *[])
{
using NodeType = int;
using TreeType = itk::TreeContainer<NodeType>;
TreeType::Pointer tree = TreeType::New();
auto tree = TreeType::New();
tree->SetRoot(0);
tree->Add(1, 0);
tree->Add(2, 0);
Expand Down
10 changes: 5 additions & 5 deletions Modules/Compatibility/Deprecated/test/itkTreeContainerTest2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ CreateTree_1(NodeListType & internalList)
{
std::cout << "create tree" << std::endl;

TreeType::Pointer tree = TreeType::New();
auto tree = TreeType::New();


TreeChangeListener::Pointer treeChangeListener = TreeChangeListener::New();
auto treeChangeListener = TreeChangeListener::New();
itk::TreeAddEvent<TreeType> ev;
unsigned long tag = tree->AddObserver(ev, treeChangeListener);

Expand Down Expand Up @@ -265,8 +265,8 @@ CreateTree_2(NodeListType & internalList)
{
std::cout << "create tree 2" << std::endl;

TreeType::Pointer tree = TreeType::New();
auto * newNode = new TestData(9);
auto tree = TreeType::New();
auto * newNode = new TestData(9);
internalList.push_back(newNode);
tree->SetRoot(newNode);
itk::PostOrderTreeIterator<TreeType> it(tree);
Expand Down Expand Up @@ -399,7 +399,7 @@ itkTreeContainerTest2(int, char *[])
result = IteratorTest(preOrderIt_Tree_1_2);
testCounter += PrintResult(result, 3761);

TreeChangeListener::Pointer treeChangeListener = TreeChangeListener::New();
auto treeChangeListener = TreeChangeListener::New();
itk::TreeChangeEvent<TreeType> ev;
unsigned long tag = tree->AddObserver(ev, treeChangeListener);
tree->Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ itkVectorCentralDifferenceImageFunctionTest(int, char *[])
using PixelType = itk::Vector<short, VectorDimension>;
using ImageType = itk::Image<PixelType, ImageDimension>;

ImageType::Pointer image = ImageType::New();
auto image = ImageType::New();
ImageType::SizeType size;
size.Fill(16);
ImageType::RegionType region(size);
Expand All @@ -50,7 +50,7 @@ itkVectorCentralDifferenceImageFunctionTest(int, char *[])
// set up central difference calculator
using CoordRepType = float;
using FunctionType = itk::VectorCentralDifferenceImageFunction<ImageType, CoordRepType>;
FunctionType::Pointer function = FunctionType::New();
auto function = FunctionType::New();

function->SetInputImage(image);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ itkVectorResampleImageFilterTest(int argc, char * argv[])

using FilterType = itk::VectorResampleImageFilter<ImageType, ImageType>;

FilterType::Pointer filter = FilterType::New();
auto filter = FilterType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, VectorResampleImageFilter, ImageToImageFilter);

itk::SimpleFilterWatcher watcher(filter);

using InterpolatorType = itk::VectorLinearInterpolateImageFunction<ImageType, double>;

InterpolatorType::Pointer interpolator = InterpolatorType::New();
auto interpolator = InterpolatorType::New();

filter->SetInterpolator(interpolator);
ITK_TEST_SET_GET_VALUE(interpolator, filter->GetInterpolator());

using TransformType = itk::IdentityTransform<double, Dimension>;
TransformType::Pointer transform = TransformType::New();
auto transform = TransformType::New();

filter->SetTransform(transform);
ITK_TEST_SET_GET_VALUE(transform, filter->GetTransform());
Expand All @@ -79,7 +79,7 @@ itkVectorResampleImageFilterTest(int argc, char * argv[])
region.SetSize(size);
region.SetIndex(start);

ImageType::Pointer image = ImageType::New();
auto image = ImageType::New();

image->SetOrigin(origin);
image->SetSpacing(spacing);
Expand Down Expand Up @@ -145,7 +145,7 @@ itkVectorResampleImageFilterTest(int argc, char * argv[])

// Write an image for regression testing
using WriterType = itk::ImageFileWriter<ImageType>;
WriterType::Pointer writer = WriterType::New();
auto writer = WriterType::New();
writer->SetInput(filter->GetOutput());
writer->SetFileName(argv[1]);

Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkAnnulusOperator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ AnnulusOperator<TPixel, TDimension, TAllocator>::GenerateCoefficients() -> Coeff

// Use a couple of sphere spatial functions...
using SphereType = SphereSpatialFunction<TDimension>;
typename SphereType::Pointer innerS = SphereType::New();
typename SphereType::Pointer outerS = SphereType::New();
auto innerS = SphereType::New();
auto outerS = SphereType::New();

innerS->SetRadius(m_InnerRadius);
outerS->SetRadius(m_InnerRadius + m_Thickness);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageDuplicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace itk
medianFilter->Update();
ImageType::Pointer image = medianFilter->GetOutput();
using DuplicatorType = itk::ImageDuplicator< ImageType >;
DuplicatorType::Pointer duplicator = DuplicatorType::New();
auto duplicator = DuplicatorType::New();
duplicator->SetInputImage(image);
duplicator->Update();
ImageType::Pointer clonedImage = duplicator->GetOutput();
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class ITK_TEMPLATE_EXPORT ImageSource
\code
// Setup the mini-pipeline to process the input to this filter
// The input is not connected to the pipeline.
typename InputImageType::Pointer input = InputImageType::New();
auto input = InputImageType::New();
input->Graft( const_cast< InputImageType * >( this->GetInput() );
firstFilterInMiniPipeline->SetInput( input );

Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ compilers.
return; \
} \
CLANG_PRAGMA_POP \
typename DecoratorType::Pointer newInput = DecoratorType::New(); \
auto newInput = DecoratorType::New(); \
newInput->Set(_arg); \
this->Set##name##Input(newInput); \
} \
Expand Down Expand Up @@ -915,7 +915,7 @@ compilers.
{ \
return; \
} \
typename DecoratorType::Pointer newInput = DecoratorType::New(); \
auto newInput = DecoratorType::New(); \
newInput->Set(_arg); \
this->Set##name##Input(newInput); \
} \
Expand Down Expand Up @@ -1280,7 +1280,7 @@ compilers.
} \
else \
{ \
typename DecoratorType::Pointer newOutput = DecoratorType::New(); \
auto newOutput = DecoratorType::New(); \
newOutput->Set(_arg); \
this->Set##name##Output(newOutput); \
} \
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkOctree.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Octree<TPixel, ColorTableSize, MappingFunctionType>::GetImage() -> ImageTypePoin
typename ImageType::RegionType region;
region.SetSize(imageSize);
region.SetIndex(imageIndex);
typename ImageType::Pointer img = ImageType::New();
auto img = ImageType::New();
img->SetLargestPossibleRegion(region);
img->SetBufferedRegion(region);
img->SetRequestedRegion(region);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkPointSetToImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ PointSetToImageFilter<TInputPointSet, TOutputImage>::GenerateData()
InputPointSetDimension,
typename InputPointSetType::CoordRepType,
typename InputPointSetType::PointsContainer>;
typename BoundingBoxType::Pointer bb = BoundingBoxType::New();
auto bb = BoundingBoxType::New();
bb->SetPoints(InputPointSet->GetPoints());
bb->ComputeBoundingBox();

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkSimpleFilterWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace itk
* Example of use:
*
* using FilterType = itk::BinaryThresholdImageFilter<ImageType>;
* FilterType::Pointer thresholdFilter = FilterType::New();
* auto thresholdFilter = FilterType::New();
*
* SimpleFilterWatcher watcher(thresholdFilter, "Threshold");
*
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/src/itkLoggerManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace itk
LoggerManager::LoggerPointer
LoggerManager::CreateLogger(const NameType & name, PriorityLevelEnum level, PriorityLevelEnum levelForFlushing)
{
Logger::Pointer logger = Logger::New();
auto logger = Logger::New();

logger->SetName(name.c_str());
logger->SetPriorityLevel(level);
Expand All @@ -36,7 +36,7 @@ LoggerManager::CreateLogger(const NameType & name, PriorityLevelEnum level, Prio
LoggerManager::ThreadLoggerPointer
LoggerManager::CreateThreadLogger(const NameType & name, PriorityLevelEnum level, PriorityLevelEnum levelForFlushing)
{
ThreadLogger::Pointer logger = ThreadLogger::New();
auto logger = ThreadLogger::New();

logger->SetName(name.c_str());
logger->SetPriorityLevel(level);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/src/itkObjectFactoryBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ NameIsSharedLibrary(const char * name)
void
ObjectFactoryBase::LoadLibrariesInPath(const char * path)
{
Directory::Pointer dir = Directory::New();
auto dir = Directory::New();

if (!dir->Load(path))
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/test/itkAbortProcessObjectTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ itkAbortProcessObjectTest(int, char *[])
{
// type alias to simplify the syntax
using ShortImage = itk::Image<short, 2>;
ShortImage::Pointer img = ShortImage::New();
auto img = ShortImage::New();

// fill in an image
const ShortImage::IndexType index = { { 0, 0 } };
Expand Down
Loading