[osg-users] Need a non-const NodeVisitor -- again

Robert Osfield robert.osfield at gmail.com
Sun Sep 16 00:51:48 PDT 2007

Hi Paul,

All I can say is welcome to C++ :-)

Occasionally one has to cast away constness for the sake of
convinience and to avoid duplicating many code blocks that otherwise
would have to have both const and non const versions.  When you cast
away constness you are effectively taking the law in your hands and
agreeing not to be naughty and break any rules - only bend them a


On 9/15/07, Paul Martz <pmartz at skew-matrix.com> wrote:
> Hi Robert -- Here's an interesting aspect of OSG's design I've just recently
> stumbled across.
> osgDB::ReaderWriter::writeNode's first param is a const
> osg::Node&. I can understand that writing a file is inherently a const
> operation as far as the scene graph is concerned. However, the obvious thing
> to do within writeNode is to traverse the node with a NodeVisitor, which
> requires calling Node::accept(), which requires the node to be non-const.
> So it seems like the nature of the design is to require writeNode to cast
> away const, but I wanted to check: Did you intend implementations of
> writeNode to do something other than use a NodeVisitor?
> Paul Martz
> Skew Matrix Software LLC
> http://www.skew-matrix.com
> 303 859 9466
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list