Is that reasonable to use a vector in a var ?
I don’t find any way of retrieving the vector once it is (may be) saved in the var.
I created a PtVector class derived from ReferenceCountedObject. I then instanciate such an object, create a DynamicObject from this, then create a var from this last one.
The error shown at the print line is:
“no member named getVector() in ReferenceCountedObject”,
so I suppose it does not refer to the proper PtVector object that was intended at first.
The code resumed looks like this :
PtVector::RefCountedPointVectorPointer pv = new PtVector();
DynamicObject* obj = new DynamicObject();
obj->setProperty(“vector”, &pv);
var toto (obj);
std::cout << “var content : " << toto[“vector”].getObject()->getVector() << “\n”;
The class PointVector looks like this :
class PtVector : public ReferenceCountedObject
{
public:
PtVector()
{
vectorOfPoints = new std::vector<Point>;
typedef ReferenceCountedObjectPtr RefCountedPointVectorPointer;
}
std::vector<Point<int>> getVector()
{
return *vectorOfPoints;
}
typedef ReferenceCountedObjectPtr<PtVector> RefCountedPointVectorPointer;
std::vector<Point<int>> *vectorOfPoints;
};