[vtk-developers] Sized types: vtkInt32Type et al

David Gobbi dgobbi at atamai.com
Mon May 30 17:15:44 EDT 2005


Brad King wrote:

> David Gobbi wrote:
>
>> I see that in vtkTemplateAliasMacro you kept the ability to turn 
>> individual types on or off, just like in my original code.
>> The nested macros are an interesting way to do this... I'd have to 
>> say that my original, verbose formulation was a bit easier to
>> read.  I guess that fewer lines of code means less chance of a typo 
>> creeping in, though.
>
>
> There is more motivation for the nested macros than just the brevity 
> of the code.  This implementation actually allows individual uses to 
> turn on/off the set of types used:
>
> #include "vtkTemplateAliasMacro.h"
> ...
> vtkTemplateAliasMacro(...) // With INT64
> #undef VTK_USE_INT64
> #define VTK_USE_INT64 0
> vtkTemplateAliasMacro(...) // Without INT64
>
> It works because the values of these on/off macros are not tested 
> until the macro is invoked.

Yup, this is exactly what I've just done in vtkImageReslice, and it 
works fine.  Note that my vtkSizedTypes.h would not have precluded the 
ability to turn types on or off, it just would have been necessary to 
either define or leave undefined each of VTK_USE items before header was 
included (and the top bit of the header file where these are defined 
would have to
be removed).

I can see how your method is a lot cleaner, though.  It makes much more 
sense for the test to occur when the macro is invoked rather than when 
the macro is defined.

 - David



More information about the vtk-developers mailing list