[vtk-developers] Proposing vtkObjectMacro

James Johnston JamesJ at motionview3d.com
Thu Sep 13 10:03:51 EDT 2012


> -----Original Message-----
> From: vtk-developers-bounces at vtk.org [mailto:vtk-developers-
> bounces at vtk.org] On Behalf Of Kyle Lutz
> Sent: Thursday, September 13, 2012 13:37
> To: VTK Developers
> Subject: [vtk-developers] Proposing vtkObjectMacro
> 
> I'd like to propose a new macro to ease the development of new vtkObject
> derived classes. When implementing new filters/algorithms/etc. a lot of
> boiler plate code is required and most often just copy-pasted from other
> similar classes. I've implemented a new macro named vtkObjectMacro()
> which reduces this boilerplate to a single line of code to be included in
the
> class's declaration. This was inspired by the similar Q_OBJECT macro in
Qt.
> 
> Here is the documentation for the macro:
> 
> // Description:
> // Declares a vtkObject subclass.
> //
> // Notably, performs the following actions:
> //   - invokes the vtkTypeMacro()
> //   - declares its constructor and destructor as protected
> //   - disables its copy constructor and assignment operator
> //   - declares its static *New() method
> //   - declares its PrintSelf() method
> #define vtkObjectMacro(className, parentClassName)

As just a normal VTK user, I like this idea.  It sounds like it means that
more VTK classes could be written correctly without gratuitous
copying/pasting, which is a good thing in my opinion.  The suggestion for an
abstract class macro also sounds good (which presumably does not declare
static *New).

The only thing I'm not too sure of would be the mandatory inclusion of
PrintSelf.  Some classes might not have member variables to print?




More information about the vtk-developers mailing list