Hi Andrew,
On 1/28/07, Andrew Somerville <[EMAIL PROTECTED]> wrote:
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":
Both these problems are solveable with a small code tweak, see below:
///////////////////////// 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/////////////////////
Solution - change FrontEndDataType to "has a" osg::Node instead of "is
a" osg::Node.
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 ////////////
Solution: use element wise copying of the vector, using the .get() to
get the raw C pointer from the elements in the source array.
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/