[Insight-developers] Re: FW: New macro with parameter
Luis Ibanez
luis.ibanez at kitware.com
Sun Oct 9 18:45:29 EDT 2005
Hi Sohan,
Please take a look at the code that the New() macro expands.
A quick look at that code will help to explain why it is
undesirable to pass parameters to the New() method.
As you will see, the New macro invokes the Factories, and
there is fair amount of things that happen before the actual
constructor of the class is invoked.
I would suggest that you rather produce a reasonable default
initialization for the member of your new class, and also
provide a "Set" method for modifying the member, once your
class has been constructed with the normal New() macro.
If you find that this approach is not reasonable, you may
have to post your code and provide a more detailed description
of the problem that you are addressing. Chances are that there
are other Design Patterns in ITK that may help to address your
problem.
Please let us know,
Thanks
Luis
------------------------------
Ranjan, Sohan (Research) wrote:
> Hi Luis.
>
> I had send this email to insight-developers, which is still not answered.
> Can you please help?
>
>
> Sohan
>
> _____________________________________________
> Sohan R Ranjan
> Imaging Technologies
> John F. Welch Technology Centre
> Plot# 122, EPIP, Phase-II, Hoodi Village,
> Whitefield Rd., Bangalore 560066, INDIA
> Tel.: +91 80 2503 3224
> Fax: +91 80 2841 2111
> Email: sohan.ranjan at ge.com
> _____________________________________________
>
>
>
>> -----Original Message-----
>>From: Ranjan, Sohan (Research)
>>Sent: Monday, October 03, 2005 4:48 PM
>>To: 'insight-developers at itk.org'
>>Subject: New macro with parameter
>>
>>I have derived a class from another ITK class, which itself is derived from ITK Light Object.
>>Therefore I have to use a itkNewMacro to create instances of my class. I have now the
>>following problem:
>>I have a variable inside the class, which needs to be initialised through passing a parameter.
>>This part is crucial, so naturally, I want this to include in the New method itself. However
>>the itkNewMacro has no provision for a parameter.
>>Is there a solution to my problem?
>>
>>
>>Sohan Ranjan
>>
>>
>>
>
>
>
More information about the Insight-developers
mailing list