[ITK Community] [Insight-users] no itkSetOutputMacro?
Luis Ibanez
luis.ibanez at kitware.com
Sat Jan 11 10:55:51 EST 2014
Joel,
There is indeed some asymmetry between the management of Inputs and Outputs.
The itkSetInputMacro() is enabling us to use the expression:
myFilter->SetRadius( 5.0 );
through (itkMacro.h: line 719)
719 /** Set an input. This defines the Set"name"() method */
720 #define itkSetInputMacro(name, type)
\
721 virtual void Set##name(const type *_arg)
\
722 {
\
723 itkDebugMacro("setting input " #name " to " << _arg);
\
724 if ( _arg != static_cast< type * >(
this->ProcessObject::GetInput(#name) ) ) \
725 {
\
726 this->ProcessObject::SetInput( #name, const_cast< type * >( _arg
) ); \
727 this->Modified();
\
728 }
\
729 }
so that we don't have to write the more verbose:
myFilter->SetInput( "Radius", 5.0
);
That is, the macro is there, to generate expressions that
are equivalent of what we used to have before named inputs.
For the outputs, on the other hand, ITK has:
https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/include/itkProcessObject.h#L527
526 /** Return an output */
527 DataObject * GetOutput(const DataObjectIdentifierType & key);
528 const DataObject * GetOutput(const DataObjectIdentifierType & key)
const;
So, if a filter has a named output called "Transform", we can call
DataObject * myFilter->GetOutput("Transform");
Note that the output type has to be the generic DataObject * , because
it must match any potential output type.
While the original method GetTransform() has a different (and more
specific) return type, such as:
TransformType * myFilter->GetTransform();
If we were to add a
itkGetOutputMacro()
It would convert:
DataObject * myFilter->GetOutput("Transform");
into
DataObject * myFilter->GetTransform();
but
Given that in C++, the return type is not part of the signature of a
function,
we couldn't have two methods with the same name and input parameters
but with different return types.
Namely:
DataObject * myFilter->GetTransform();
TransformType * myFilter->GetTransform();
Regards,
Luis
On Fri, Jan 10, 2014 at 9:50 AM, Joël Schaerer <joel.schaerer at gmail.com>wrote:
> Dear all,
>
> The addition of named inputs and outputs for ProcessObjects in ITK 4 has
> resulted in the addition of a few macros such as itkSetInputMacro which are
> responsible for exposing the new protected methods such as GetInput(name).
>
> I have found no similar macros for outputs. Why is that?
>
> Thanks!
>
> joel
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140111/e8676563/attachment-0002.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users
More information about the Community
mailing list