[osg-users] dynamic_cast equivalent in osgDotNet
robert.osfield at gmail.com
Thu Oct 4 00:56:55 PDT 2007
osgGA knows about core osg wher osg::View is defined, so could this work?
On 10/4/07, Michael Wittman <wittman at acm.org> wrote:
> Hi Robert,
> On Wed, Oct 03, 2007 at 09:11:21AM +0100, Robert Osfield wrote:
> > On 10/3/07, Michael Wittman <wittman at acm.org> wrote:
> > > It's possible to add support to osgDotNet for upcasts along non-leftmost
> > > inheritance branches. But downcasting in the same situation is a much
> > > harder problem, and I don't know of a good solution for it at the moment.
> > Perhaps we could add a GUIActionAdapter:asView() virtual function that
> > returns a osg::View pointer.
> > Another possibility would be to have a asViewer() and
> > asCompositeViewer() methods too, but we'd have to forward declare
> > osgViewer::Viewer and osgViewer::CompositeViewer to achieve this. I'm
> > not sure what the consequences for the wrappers would be with this
> > though.
> Unfortunately I don't think those approaches would help, as there's no
> analogue to C++'s incomplete types in the CLR. And having knowledge of
> full osgViewer wrapper types in the osgGA wrappers would necessitate a
> circular dependency between the two assemblies, which is not permitted
> (nor wise, in any case).
> I'm not entirely sure it would work, but best approach I can think of
> would be implemented completely within the wrappers. It would involve
> a registry of downcast conversion functions for every inheriting type
> from all the types in its inheritance tree, indexed off the CLR's
> type IDs for the inheriting and inherited types. A separate function
> would then be provided to index into the registry and apply the correct
> conversion function based on the CLR type IDs. The invoking code would
> look something like this:
> OsgGA.GUIActionAdapter aa;
> OsgViewer.Viewer v = OsgWrapper.Convert.Downcast(aa.GetType(), typeof(OsgViewer.Viewer)) as OsgViewer.Viewer;
> One thing that's not clear to me currently is how to reliably construct
> a unified conversion function registry across multiple wrapper assemblies.
> osg-users mailing list
> osg-users at lists.openscenegraph.org
More information about the osg-users