[vtk-developers] Another 'major' change in vtkSetGet

Lisa S. Avila lisa.avila at kitware.com
Fri Feb 8 10:05:57 EST 2002


Hi Andy,

I think this is a good idea - but I don't like the names. I would think the
"implementation" macro would go in the cxx file not the header. Also, why 
do we need any macro in the header file now - we would simply declare the 
method, right?

Lisa


At 09:48 AM 2/8/2002, Andy Cedilnik wrote:
>Hi All!
>
>I made a change to vtkSetGet yesterday. It should not change anything
>for existing projects, but I propose a small addition to the coding
>standard for VTK.
>
>* Only include those files in the header file that are absolutely
>         necessary.
>
>Let me explain that. So far, header files in VTK include several other
>header files, where most of them are unnecessary. For example
>vtkLight includes vtkMatrix4x4, which is only needed because
>of the vtkSetObjectMacro. I added macro vtkSetObjectImplementationMacro,
>which solves that problem. The way it works is that you put the actual
>prototype for the set method:
>
>         void SetTransformMatrix(vtkMatrix4x4*);
>
>to header file and put the macro in the c++ file:
>
>vtkSetObjectImplementationMacro(vtkLight,TransformMatrix,vtkMatrix4x4);
>
>This eliminates need for the inclusion of additional header files.
>It will therefore clean the header files and the inclusion process
>will be much more direct. The header will only include the path from the
>header file to the vtkObject class instead of several other branches in
>VTK hierarchy.
>
>So, what does that mean?
>
>If possible, for the new projects reduce or stop using vtkSetObjectMacro.
>vtkSetObjectMacro calls methods on the class, so it needs the class
>header file. vtkSetObjectMacro will stay and I guess old files will
>still use it. All new classes should use vtkSetObjectImplementationMacro.
>
>There is also another addition to vtkSetGet.
>Before if you were trying to do something after setting object, you
>essentially had to implement your own vtkSetObjectMacro. The alternative
>was to add another method that called vtkSetObjectMacro. I added
>another macro called vtkSetObjectBodyMacro, which defines the body
>of vtkSetObjectMacro and vtkSetObjectImplementationMacro. So, now
>you can implement your own vtkSetObjectMacro by doing something like:
>
>
>void vtkSomeClass::SetSomeMember(vtkMemberClass *arg)
>{
>         this->DoSomethingBeforeSetting(arg);
>         vtkSetObjectBodyMacro(SomeMeber, vtkMemberClass, arg);
>         this->DoSomethingAfterSetting(arg);
>}
>
>Sounds good?
>
>Please comment on that.
>
>
>                                 Andy Cedilnik
>
>_______________________________________________
>vtk-developers mailing list
>vtk-developers at public.kitware.com
>http://public.kitware.com/mailman/listinfo/vtk-developers




More information about the vtk-developers mailing list