Robert Osfield wrote:
...
You've lost me a bit here. The OSG's reference counted objects don't
need osg::ref_ptr<> and osg::ref_ptr<> doesn't need osg::Referenced.
This means any osg::Referenced object can work with a new ref_ptr<>
implementation (as long as wall ref/unref/unref_nodelete or
osg::ref_ptr<> can work any object that implements
ref/unref/unref_nodelete. This is what I mean by loose coupling.
As you said, one can always use another external smart pointer
implementation along side OSG's (boost or otherwise), but having two
different implementations of the same solution is undesirable as it can
lead to confusion in code, and strange incompatibilities down the line.
I can certainly understand the desire to avoid externalizing an
additional dependencies though especially since it appears only Ignacio
and I find the proposal desirable.
For the time spent on this thread you could have implemented you
custom smart pointer.
I completely understand what you are saying. I think I'm just having a
hard time explaining what I mean. It is perhaps best for me to
illustrate with code. The following is one example of how having my own
implementation of a smart pointer would be "incompatible":
///////////////////////// example program/////////////////////////////
#include <osg/ref_ptr>
#include <osg/Node>
#include <list>
class MyReferenced
{
public:
MyReferenced() : count(0) {}
void ref() { count++; }
void unref() { count--; if(count<1) printf( "delete\n"
); }
void unref_nodelete() { count--; }
private:
int count;
};
struct SharedDataType : public virtual MyReferenced
{
};
struct FrontEndDataType : public SharedDataType, public osg::Node
{
};
void frontendFunction0()
{
osg::ref_ptr<FrontEndDataType> myFedtPointer0;
// error: request for member `unref' is ambiguous
myref_ptr<FrontEndDataType> myFedtPointer1;
// error: ditto
}
////////////////////end example program/////////////////////
another, perhaps trivial, example would be:
//////////////////// second example program /////////////////
...
struct SharedContainerDataType
{
std::list< myref_ptr<SharedDataType> > sdtList;
};
void frontendFunction1( SharedContainerDataType arg )
{
std::list< osg::ref_ptr<SharedDataType> > sdtListCopy;
sdtListCopy = arg.sdtList;
// error cant do (simple) copy because they arent the same type of list
}
//////////////////// end second example program ////////////
Andy
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/