Hi,

On Fri, Mar 16, 2012 at 4:43 PM, John Kaniarz <john.kani...@us.army.mil> wrote:
> What you're trying to do is the PIMPL design pattern.  I'll leave the details 
> to Google :)
>
> You may also want to brush up on the Factory design pattern for generating 
> your opaque handles.
>
> In a direct answer to your question, no you can't use a void* to store a 
> ref_ptr<> (without some trickery). You can, however, store a pointer to a 
> ref_ptr<> as a void* . Then when you need to use it, convert it like this to 
> avoid having to double dereference it every time you use it.
>

If I do this, then I need to maintain the underlying ref_ptr object
no? This isn't particularly convenient. What was wrong with assigning
the osg::Node's pointer to mysteryPtr instead? Basically with ...

osg::ref_ptr<osg::Node> someNode;
mysteryPtr = someNode.Get();

As long as the pointer returned by the Get() method is valid for the
lifetime of the object I'm safe right? Then if I want to do anything
with object:

osg::ref_ptr<osg::Node> someNode = some_cast_call<osg::Node*>(mysteryPtr);
someNode->partyAllDay();

>
> Code:
> ref_ptr< Node> &node = *reinterpret_cast< ref_ptr< Node> *>(mysteryPtr);
>
>
>
> And don't forget to delete the pointer to the ref_ptr<> when you're done. if 
> you leak the ref_ptr<> the node will never get collected.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=46372#46372
>
>
>
>
>
> _______________________________________________
> 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