1 #include <gtwrap/matlab.h>
19 std::streambuf *outbuf = std::cout.rdbuf(&mout);
21 bool anyDeleted =
false;
43 "WARNING: Wrap modules with variables in the workspace have been reloaded due to\n"
44 "calling destructors, call 'clear all' again if you plan to now recompile a wrap\n"
45 "module, so that your recompiled module is used instead of the old one." << endl;
46 std::cout.rdbuf(outbuf);
50 const mxArray *alreadyCreated = mexGetVariablePtr(
"global",
"gtsam_multiple_files_rttiRegistry_created");
52 std::map<std::string, std::string> types;
56 mxArray *registry = mexGetVariable(
"global",
"gtsamwrap_rttiRegistry");
58 registry = mxCreateStructMatrix(1, 1, 0,
NULL);
59 typedef std::pair<std::string, std::string> StringPair;
60 for(
const StringPair& rtti_matlab: types) {
61 int fieldId = mxAddField(registry, rtti_matlab.first.c_str());
63 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
65 mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
66 mxSetFieldByNumber(registry, 0, fieldId, matlabName);
68 if(mexPutVariable(
"global",
"gtsamwrap_rttiRegistry", registry) != 0) {
69 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
71 mxDestroyArray(registry);
73 mxArray *newAlreadyCreated = mxCreateNumericMatrix(0, 0, mxINT8_CLASS, mxREAL);
74 if(mexPutVariable(
"global",
"gtsam_multiple_files_rttiRegistry_created", newAlreadyCreated) != 0) {
75 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
77 mxDestroyArray(newAlreadyCreated);
84 typedef std::shared_ptr<gtsam::Class1> Shared;
86 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
93 typedef std::shared_ptr<gtsam::Class1> Shared;
95 Shared *
self =
new Shared(
new gtsam::Class1());
98 *
reinterpret_cast<Shared**
> (mxGetData(
out[0])) =
self;
103 typedef std::shared_ptr<gtsam::Class1> Shared;
105 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
106 Collector_gtsamClass1::iterator item;
117 typedef std::shared_ptr<gtsam::Class2> Shared;
119 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
126 typedef std::shared_ptr<gtsam::Class2> Shared;
128 Shared *
self =
new Shared(
new gtsam::Class2());
131 *
reinterpret_cast<Shared**
> (mxGetData(
out[0])) =
self;
136 typedef std::shared_ptr<gtsam::Class2> Shared;
138 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
139 Collector_gtsamClass2::iterator item;
150 typedef std::shared_ptr<gtsam::ClassA> Shared;
152 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
159 typedef std::shared_ptr<gtsam::ClassA> Shared;
161 Shared *
self =
new Shared(
new gtsam::ClassA());
164 *
reinterpret_cast<Shared**
> (mxGetData(
out[0])) =
self;
169 typedef std::shared_ptr<gtsam::ClassA> Shared;
171 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
172 Collector_gtsamClassA::iterator item;
184 std::streambuf *outbuf = std::cout.rdbuf(&mout);
220 }
catch(
const std::exception&
e) {
221 mexErrMsgTxt((
"Exception from gtsam:\n" + std::string(
e.what()) +
"\n").c_str());
224 std::cout.rdbuf(outbuf);