<div class="gmail_quote">On Thu, Sep 13, 2012 at 9:53 AM, Kyle Lutz <span dir="ltr"><<a href="mailto:kyle.lutz@kitware.com" target="_blank">kyle.lutz@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, Sep 13, 2012 at 6:48 AM, Aashish Chaudhary<br>
<<a href="mailto:aashish.chaudhary@kitware.com">aashish.chaudhary@kitware.com</a>> wrote:<br>
> +1, can we add virtual keyword in front of the ~className()?<br>
><br>
> Or are you going to rely on the fact that the parent class has defined its<br>
> destructor virtual (like vtkObject?)<br>
<br>
</div>The macro is only intended for classes deriving from vtkObject (really<br>
vtkObjectBase) so declaring the destructor as virtual would be<br>
redundant.<br></blockquote><div><br></div><div>Yes, but in general IMO, it is not a good practice to leave virtual keyword out just because base class has declared virtual destructor.  Also implicit something is not good unless properly documented. Since we are talking about a macro, I don't think its too bad to have virtual keyword in front of the desctructor. </div>
<div><br></div><div>I am OK with not having it, but would prefer other way. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
><br>
> Thanks!<br>
><br>
><br>
> On Thu, Sep 13, 2012 at 9:36 AM, Kyle Lutz <<a href="mailto:kyle.lutz@kitware.com">kyle.lutz@kitware.com</a>> wrote:<br>
>><br>
>> I'd like to propose a new macro to ease the development of new<br>
>> vtkObject derived classes. When implementing new<br>
>> filters/algorithms/etc. a lot of boiler plate code is required and<br>
>> most often just copy-pasted from other similar classes. I've<br>
>> implemented a new macro named vtkObjectMacro() which reduces this<br>
>> boilerplate to a single line of code to be included in the class's<br>
>> declaration. This was inspired by the similar Q_OBJECT macro in Qt.<br>
>><br>
>> Here is the documentation for the macro:<br>
>><br>
>> // Description:<br>
>> // Declares a vtkObject subclass.<br>
>> //<br>
>> // Notably, performs the following actions:<br>
>> //   - invokes the vtkTypeMacro()<br>
>> //   - declares its constructor and destructor as protected<br>
>> //   - disables its copy constructor and assignment operator<br>
>> //   - declares its static *New() method<br>
>> //   - declares its PrintSelf() method<br>
>> #define vtkObjectMacro(className, parentClassName)<br>
>><br>
>> For example, here is how it would be used when creating a new<br>
>> poly-data algorithm named MyFilter:<br>
>><br>
>> // in myfilter.h<br>
>> class MyFilter : public vtkPolyDataAlgorithm<br>
>> {<br>
>> public:<br>
>>   vtkObjectMacro(MyFilter, vtkPolyDataAlgorithm)<br>
>> };<br>
>><br>
>> // in myfilter.cxx<br>
>> vtkStandardNewMacro(MyFilter)<br>
>> MyFilter::MyFilter() { /* ... */ }<br>
>> MyFilter::~MyFilter() { /* ... */ }<br>
>> void MyFilter::PrintSelf(ostream &o, vtkIndent indent) { /* ... */ }<br>
>><br>
>> I've pushed a topic to gerrit with the implementation:<br>
>> <a href="http://review.source.kitware.com/#/t/1276/" target="_blank">http://review.source.kitware.com/#/t/1276/</a><br>
>><br>
>> Thoughts? Comments? Concerns?<br>
>><br>
>> Thanks,<br>
>> Kyle<br>
>> _______________________________________________<br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>><br>
>> Visit other Kitware open-source projects at<br>
>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>><br>
>> Follow this link to subscribe/unsubscribe:<br>
>> <a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> | Aashish Chaudhary<br>
> | R&D Engineer<br>
> | Kitware Inc.<br>
> | <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>| Aashish Chaudhary <br>| R&D Engineer         <br>| Kitware Inc.            <br>| <a href="http://www.kitware.com">www.kitware.com</a>    <br>