42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
// automatically generated by wrap
|
|
#include <wrap/matlab.h>
|
|
#include <Point2.h>
|
|
typedef boost::shared_ptr<Point2> Shared;
|
|
|
|
static std::set<Shared*> collector;
|
|
|
|
void cleanup(void) {
|
|
for(std::set<Shared*>::iterator iter = collector.begin(); iter != collector.end(); ) {
|
|
delete *iter;
|
|
collector.erase(iter++);
|
|
}
|
|
}
|
|
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
|
{
|
|
mexAtExit(cleanup);
|
|
|
|
const mxArray* input = in[0];
|
|
Shared* self = *(Shared**) mxGetData(input);
|
|
|
|
if(self) {
|
|
if(nargin > 1) {
|
|
collector.insert(self);
|
|
}
|
|
else if(collector.erase(self))
|
|
delete self;
|
|
} else {
|
|
int nc = unwrap<int>(in[1]);
|
|
|
|
if(nc == 0)
|
|
self = new Shared(new Point2());
|
|
if(nc == 1) {
|
|
double x = unwrap< double >(in[2]);
|
|
double y = unwrap< double >(in[3]);
|
|
self = new Shared(new Point2(x,y));
|
|
}
|
|
collector.insert(self);
|
|
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
|
|
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
|
|
}
|
|
}
|