I sort of agree with Karthik... It would be better if we could make VTK as a whole honor const where it makes sense. This, however, does not seem like a lightweight task by any means.<div><br></div><div>However, I also think we should make it easy for people not to have to resort to const_cast madness.<br>
<br></div><div>Changing vtkSetGet.h is a good start, but there are many method overrides in subclasses that will now have a different signature than their parent class methods unless they are carefully sought out and changed to match the new parent signature. You do not want to unintentionally change a method override to a method overload.</div>
<div><br></div><div>After thinking about this for a little while, I'd be very hesitant to make this change without reserving a lot of time for chasing down strange behavior to follow...</div><div><br></div><div><br></div>
<div>David</div><div><br></div><div><br><div class="gmail_quote">On Fri, Nov 7, 2008 at 1:02 PM, Karthik Krishnan <span dir="ltr"><<a href="mailto:karthik.krishnan@kitware.com">karthik.krishnan@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">VTK's public API as a whole does not respect constness. It might be<br>
more painful if we were to make bits and pieces of the public API<br>
const correct. Sometimes slightly correct is not better than<br>
fully incorrect.<br>
<br>
Did you also check if you would be causing the wrappers<br>
problems ?<br>
<br>
Thanks<br>
--<br>
karthik<br>
<br>
2008/11/7 Burlen Loring <<a href="mailto:burlen.loring@kitware.com">burlen.loring@kitware.com</a>>:<br>
<div><div></div><div class="Wj3C7c">> Hi,<br>
><br>
> would anyone object to changing the vtkSetVectorXMacro's to respect const<br>
> pointers?<br>
> for eg. the change to SetVector3Macro would be:<br>
><br>
> -virtual void Set##name (type _arg[3]) \<br>
> +virtual void Set##name (const type _arg[3]) \<br>
> { \<br>
> this->Set##name (_arg[0], _arg[1], _arg[2]);\<br>
> }<br>
><br>
><br>
> This would be helpful in a situation like:<br>
><br>
> class A<br>
> {<br>
> public:<br>
> const double *GetBlah(){ return this->Blah; }<br>
> private:<br>
> double Blah[3];<br>
> };<br>
><br>
> class B : public vtkObject<br>
> {<br>
> public:<br>
> vtkSetVector3Macro(Bleh,double);<br>
> private:<br>
> double Bleh[3];<br>
> };<br>
><br>
> A a;<br>
> B *b=B::New();<br>
> b->SetBleh(a.GetBlah());<br>
><br>
> where I want to return a pointer to an array for efficiency but want to<br>
> document, and enforce, that the array's contents aren't to be modified, and<br>
> don't want to end up using const_cast's everywhere I need to pass the array<br>
> to a vtkObject.<br>
><br>
> --<br>
> Burlen Loring<br>
> Kitware, Inc.<br>
> R&D Engineer<br>
> 28 Corporate Drive<br>
> Clifton Park, NY 12065-8662<br>
> Phone: 518-371-3971 x137<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> vtk-developers mailing list<br>
> <a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a><br>
> <a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
><br>
><br>
<br>
<br>
<br>
--<br>
Karthik Krishnan<br>
R&D Engineer,<br>
Kitware Inc.<br>
Ph: 518 371 3971 x119<br>
Fax: 518 371 3971<br>
_______________________________________________<br>
vtk-developers mailing list<br>
<a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a><br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
</blockquote></div><br></div>