Thank you very much.
 I also came up with your second solution during testing, and I might just 
stick with that, but I'll have a look at the pimpl pattern before surrendering 
completely. At least it might go into the to-do list for future refactoring.

Thank you for your help.

Jesper D. Thomsen
AnyBody Technology A/S

-----Original Message-----
From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien 
Guay
Sent: 8. februar 2011 15:22
To: OpenSceneGraph Users
Subject: Re: [osg-users] Forward declarations and ref_ptr members

Hi Jesper,

> error C2079: 'asg::ASGContainer::m_osgroot' uses undefined class 
> 'osg::ref_ptr<T>'

Template classes/methods need to be completely defined when they are used, so 
what you're trying won't work.

In addition to using the pimpl idiom which would completely solve your problem 
but might take some time to implement everywhere it would be needed, you could 
get by just including <osg/ref_ptr> and forward declaring the classes that will 
be contained in a ref_ptr. So instead of:

namespace osg
{
     class Node;
     class Material;
     template <typename T> class ref_ptr; };

you could do:

#include <osg/ref_ptr>

namespace osg
{
     class Node;
     class Material;
};

The ref_ptr header is small and if that is the only one included in most places 
then you've got 98% of what you wanted for much less effort than using pimpl 
everywhere. That said, if I were designing an OSG-based API today I would 
probably use pimpl from the start and keep my public interface independent of 
OSG as much as I can. But that's just a design preference, and when refactoring 
existing code the decisions are different...

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/ 
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to