[Insight-developers] SmartPointer and Get/Set Input/Output

Luis Ibanez ibanez at cs.unc.edu
Wed Sep 6 09:31:12 EDT 2000


Hi,

I'm still confused about the use of  Normal vs Smart pointers.

This time with the methods SetInput() , and GetOutput() for
the filters.

Currently they are defined like

TImageOutput   *   GetOutput();


Shouldn't  they be:              TImageOutput::Pointer
GetOutput();   ?
or maybe:                   const TImageOutput::Pointer & GetOutput();
?

------

And the SetInput() method it is currently:

void SetInput(  TImageInput * );

shouldn't it be:    void SetInput(             TImageInput::Pointer
);   ?
or maybe :            void SetInput(  const TImageInput::Pointer &  );
?

--------------------------

With the current code, in order to connect
images to filters we have to do :

1  typedef   itk::Image< double, 3 >   myImageType;
2  myImageType::Pointer  theImage = myImgeType::New();
3  myFilterType  theFilter = myFilterType::New();
4  theFilter.SetInput (   theImage.GetPointer()  );
5  myImageType::Pointer theOutput = theFilter.GetOutput();

----------------------------

Passing SmartPointers, lines 4 and 5 become:

4  theFilter.SetInput (   theImage  );
5  myImageType::Pointer theOutput = theFilter.GetOutput().GetPointer();

------------------------------

The points are:

1) Do we want to pass images to filters as normal pointers or as
smartpointers ?
2) If we want SmartPointers, should they be passed by copy or by
reference ?



Thanks


Luis







More information about the Insight-developers mailing list