[vtk-developers] const in set vector macros

Karthik Krishnan karthik.krishnan at kitware.com
Fri Nov 7 13:02:20 EST 2008


VTK's public API as a whole does not respect constness. It might be
more painful if we were to make bits and pieces of the public API
const correct. Sometimes slightly correct is not better than
fully incorrect.

Did you also check if you would be causing the wrappers
problems ?

Thanks
--
karthik

2008/11/7 Burlen Loring <burlen.loring at kitware.com>:
> Hi,
>
> would anyone object to changing the vtkSetVectorXMacro's to respect const
> pointers?
> for eg. the change to SetVector3Macro would be:
>
> -virtual void Set##name (type _arg[3]) \
> +virtual void Set##name (const type _arg[3]) \
>  { \
>  this->Set##name (_arg[0], _arg[1], _arg[2]);\
>  }
>
>
> This would be helpful in a situation like:
>
> class A
> {
> public:
>   const double *GetBlah(){ return this->Blah; }
> private:
>   double Blah[3];
> };
>
> class B : public vtkObject
> {
> public:
>   vtkSetVector3Macro(Bleh,double);
> private:
>   double Bleh[3];
> };
>
> A a;
> B *b=B::New();
> b->SetBleh(a.GetBlah());
>
> where I want to return a pointer to an array for efficiency but want to
> document, and enforce, that the array's contents aren't to be modified, and
> don't want to end up using const_cast's everywhere I need to pass the array
> to a vtkObject.
>
> --
> Burlen Loring
> Kitware, Inc.
> R&D Engineer
> 28 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-371-3971 x137
>
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



-- 
Karthik Krishnan
R&D Engineer,
Kitware Inc.
Ph: 518 371 3971 x119
Fax: 518 371 3971



More information about the vtk-developers mailing list