[osg-submissions] Fixing osgTerrain::Layer::getFileName problem with osgDotNet

Robert Osfield robert.osfield at gmail.com
Wed Sep 5 08:39:14 PDT 2007


Hi Mike,

On 9/5/07, Mike Wittman <mwittman at seismicmicro.com> wrote:
> Testing with 2.1.9 I found that the reference return of
> osgTerrain::Layer::getFileName and its overrides is causing a problem with
> osgDotNet.  In general, reference returns from virtual functions are
> difficult to handle in the wrappers because data conversions between .NET
> and C++ objects are performed with temporary objects.
>
>
> Would you mind changing the return value to just std::string to avoid the
> problem, per the attached file?  (I'd argue this change also makes sense
> from a strictly C++ perspective, as a const std::string& return value forces
> subclasses to maintain a std::string value internally when it might not
> otherwise be necessary.)

Um... C++ wise the const string& is the right thing to do as it avoids
copying a string which is slow.  As for the subclasses needing to
retain a copy, well they already have a std::string virtual of the
base class, and this is there due the different ways that Layers can
be created and used.

I does concern me that you are porposing having to do suboptimal
things on the C++ side to accommodate non C++ path ways.  Please note
that a const reference implies different rules to that of non const
reference, I don't know if you can take advantage of this in the
wrapping code.

Robert.


More information about the osg-submissions mailing list