[Insight-developers] Small modification to ImportImageContainer

Tom Vercauteren tom.vercauteren at m4x.org
Tue Mar 31 09:18:26 EDT 2009


Hi Luis,

> After looking closer at this two methods I see now why they can
> both be const:  They do not affect member variables (at least in
> an obvious direct manner). This is still a bit deceptive, because
> when DeallocateElements() is called, we pass a member variable as
> its argument..., something that is also strange.... why is that
> we simply not have the method without arguments, and internally
> we access in it the member variable ?

We could do that, I just thought that passing the pointer as an
argument was more generic.


> It seems however that the argument of DeallocateElements can
> be made non-const, and in that way you won't need to cast const
> away.

I chose to make it const since it was standard compliant and seemed
more appropriate. The fact that we need the const-cast for vs6 makes
it however much less elegant...


> Do you need this pointer argument to be const in the context
> in which you will use this method in the derived class that you
> are developing ?

I should try without it, but I don't think it will really matter for
my application.


> I guess that we may understand better if you post the derived
> class that you are implementing.

It's a bit complex to post my Image subclass here as it uses some
internal non-ITK code.
It basically uses std::allocator<TElement> instead of calling new and delete.

If you find it useful, I could try to modify TestImportImageContainer
in itkFactoryTestLib so as to use such a custom allocator:
http://www.itk.org/cgi-bin/viewcvs.cgi/Testing/Code/Common/itkFactoryTestLib.cxx?root=Insight&sortby=date&view=markup


> The ImportImageContainer class is at the very heart of ITK so we
> should be very careful with any changes we made to it.   :-/

I most certainly understand that care should be taken for this class!
This is why I asked for feedback.

Tom


More information about the Insight-developers mailing list