[vtk-developers] [vtkusers] Const get macros?

David Doria daviddoria+vtk at gmail.com
Sat Aug 15 09:52:19 EDT 2009


On Sat, Aug 15, 2009 at 8:52 AM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

>
>
> On Fri, Aug 14, 2009 at 11:38 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:
>
>> David,
>>
>> Be aware that adding a const version of the get macro may affect
>> wrapping. I believe that vtkParse.l handles vtkGetMacro, but there is
>> not provision to handle a GetConstMacro.
>>
>> Bill
>>
>
> In  /..../itk/src/Code/Common/itkMacro.h there is simply
>
> #define itkGetConstMacro(name,type) \
>   virtual type Get##name () const \
>   { \
>     itkDebugMacro("returning " << #name " of " << this->m_##name ); \
>     return this->m_##name; \
>   }
>
> To make the const macro, this could just be changed to:
>
> #define vtkGetConstMacro(name,type) \
>   virtual type Get##name () const { \
>     vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning
> " << #name " of " << this->m_name ); \
>     return this->m_name; \
>   }
>
> (copied from /..../vtk/src/Common/vtkSetGet.h ) which was:
> #define vtkGetMacro(name,type) \
> virtual type Get##name () { \
>   vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning "
> << #name " of " << this->name ); \
>   return this->name; \
>   }
>
> @Bill, I have no idea about wrapping - so if someone sees a problem can you
> please take a look? Was there a reason that this const get method was omited
> in the first place?
>
> Object macros :
>
> I am a bit confused about the ObjectMacros. In vtkSetGet.h, it says
> vtkSetObjectMacro should be used in the h file and vtkCxxSetObjectMacro
> should be used in the cxx file. But the comment for vtkCxxSetObjectMacro
> says you have to actually put
> virtual void Set"name"("type" *);
> in the header file... so then what would be the use of vtkSetObjectMacro?
> and why is there no vtkCxxGetObjectMacro?
>
> Thanks,
>
> David
>

Ok so what is the bottom line? Just don't use const get functions? Or just
write them manually (but then the class cannot be wrapped, is that correct?)

Any comments on the missing vtkCxxGetObjectMacro ? I was looking for this to
try to make an accessor for a custom type variable - am I misunderstanding
the ObjectMacro idea?


Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20090815/62e366b4/attachment.html>


More information about the vtk-developers mailing list