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