[vtk-developers] Const get macro?

David Doria daviddoria+vtk at gmail.com
Sat Aug 15 08:56:39 EDT 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20090815/158b00dc/attachment.html>


More information about the vtk-developers mailing list