<div class="gmail_quote">On Fri, Jan 8, 2010 at 3:41 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Fri, Jan 8, 2010 at 1:38 PM, David Doria <<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>> wrote:<br>
> On Fri, Jan 8, 2010 at 3:33 PM, Karthik Krishnan<br>
> <<a href="mailto:karthik.krishnan@kitware.com">karthik.krishnan@kitware.com</a>> wrote:<br>
>> Or have these as typdefs and/or factory methods in a VTK class, as is<br>
>> done in ITK (that would be internally handled via macros in the<br>
>> class), so that usage syntax looks like.<br>
>><br>
>> vtkPoints::SmartPointer = vtkPoints::SmartNew();<br>
>> or<br>
>> vtkPoints::SmartPointer instance(1);<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> On Fri, Jan 8, 2010 at 3:26 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br>
>>> On Fri, Jan 8, 2010 at 1:15 PM, David Doria <<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>> wrote:<br>
>>>> I've seen the use of something like this:<br>
>>>><br>
>>>> #define SPNEW(instance, type) \<br>
>>>> vtkSmartPointer<type> instance = vtkSmartPointer<type>::New();<br>
>>>><br>
>>>> in many of the tests and elsewhere. It seems like a reasonable savings<br>
>>>> of a whole bunch of characters that appears many many times in most<br>
>>>> functions. Could we standardize something like this so it can be used<br>
>>>> universally without having to see this little #define in every file it<br>
>>>> is used in?<br>
>>>><br>
>>>> Thoughts?<br>
>>><br>
>>> Doesn't VTK have enough macros already? ;)<br>
>>><br>
>>> There are other ways to reduce the repetition, without using macros:<br>
>>><br>
>>> 1) Add a new constructor argument for smart pointers:<br>
>>><br>
>>> vtkSmartPointer<type> instance(1); // create an smart pointer and<br>
>>> allocate an object at the same time<br>
>>> vtkSmartPointer<type> instance(0); // create a smart pointer with<br>
>>> "null" as the initial pointer<br>
>>><br>
>>> 2) Add a non-static "New" method for smart pointers:<br>
>>><br>
>>> vtkSmartPointer<type> instance;<br>
>>> instance.InstantiateNew();<br>
>>><br>
>>> etc.<br>
>>><br>
>>> David<br>
><br>
><br>
> Sure, I hate macros :)<br>
><br>
> So how do we turn these good suggestions into a final conclusion and<br>
> course of action?<br>
><br>
> My choice/thought after seeing these initial comments is that it would<br>
> be nice if ITK and VTK shared a similar style (the ::SmartPointer).<br>
><br>
> Bill - there is plenty of mystery even with the additional typing :)<br>
><br>
> David D.<br>
<br>
</div></div>Actually, I'll give a "+1" to Bill's comment because I do like code to<br>
be as explicit as possible.<br>
<br>
David G<br>
<div><div></div><div class="h5"><br></div></div></blockquote><div><br></div><div>Me too. +1.</div><div><br></div><div>Which sort of means eliminating all the existing SPNEW macros from test files, doesn't it...? :-)</div>
<div><br></div><div><br></div><div>David C.</div><div><br></div><div> </div></div>