1 #include <gtwrap/matlab.h> 4 #include <boost/archive/text_iarchive.hpp> 5 #include <boost/archive/text_oarchive.hpp> 6 #include <boost/serialization/export.hpp> 8 #include <folder/path/to/Test.h> 11 #include <path/to/ns1.h> 12 #include <path/to/ns1/ClassB.h> 13 #include <path/to/ns2.h> 14 #include <path/to/ns2/ClassA.h> 15 #include <path/to/ns3.h> 76 std::streambuf *outbuf = std::cout.rdbuf(&mout);
78 bool anyDeleted =
false;
207 "WARNING: Wrap modules with variables in the workspace have been reloaded due to\n" 208 "calling destructors, call 'clear all' again if you plan to now recompile a wrap\n" 209 "module, so that your recompiled module is used instead of the old one." << endl;
210 std::cout.rdbuf(outbuf);
214 const mxArray *alreadyCreated = mexGetVariablePtr(
"global",
"gtsam_namespaces_rttiRegistry_created");
215 if(!alreadyCreated) {
216 std::map<std::string, std::string> types;
217 types.insert(std::make_pair(
typeid(MyBase).
name(),
"MyBase"));
220 types.insert(std::make_pair(
typeid(ForwardKinematicsFactor).
name(),
"ForwardKinematicsFactor"));
222 mxArray *registry = mexGetVariable(
"global",
"gtsamwrap_rttiRegistry");
224 registry = mxCreateStructMatrix(1, 1, 0,
NULL);
225 typedef std::pair<std::string, std::string> StringPair;
226 for(
const StringPair& rtti_matlab: types) {
227 int fieldId = mxAddField(registry, rtti_matlab.first.c_str());
229 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
230 mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
231 mxSetFieldByNumber(registry, 0, fieldId, matlabName);
233 if(mexPutVariable(
"global",
"gtsamwrap_rttiRegistry", registry) != 0)
234 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
235 mxDestroyArray(registry);
237 mxArray *newAlreadyCreated = mxCreateNumericMatrix(0, 0, mxINT8_CLASS, mxREAL);
238 if(mexPutVariable(
"global",
"gtsam_geometry_rttiRegistry_created", newAlreadyCreated) != 0)
239 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
240 mxDestroyArray(newAlreadyCreated);
247 typedef boost::shared_ptr<ns1::ClassA> Shared;
249 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
256 typedef boost::shared_ptr<ns1::ClassA> Shared;
258 Shared *
self =
new Shared(
new ns1::ClassA());
261 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
266 typedef boost::shared_ptr<ns1::ClassA> Shared;
268 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
269 Collector_ns1ClassA::iterator item;
280 typedef boost::shared_ptr<ns1::ClassB> Shared;
282 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
289 typedef boost::shared_ptr<ns1::ClassB> Shared;
291 Shared *
self =
new Shared(
new ns1::ClassB());
294 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
299 typedef boost::shared_ptr<ns1::ClassB> Shared;
301 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
302 Collector_ns1ClassB::iterator item;
313 out[0] = wrap< Vector >(ns1::aGlobalFunction());
318 typedef boost::shared_ptr<ns2::ClassA> Shared;
320 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
327 typedef boost::shared_ptr<ns2::ClassA> Shared;
329 Shared *
self =
new Shared(
new ns2::ClassA());
332 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
337 typedef boost::shared_ptr<ns2::ClassA> Shared;
339 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
340 Collector_ns2ClassA::iterator item;
351 auto obj = unwrap_shared_ptr<ns2::ClassA>(in[0],
"ptr_ns2ClassA");
358 auto obj = unwrap_shared_ptr<ns2::ClassA>(in[0],
"ptr_ns2ClassA");
359 ns1::ClassB&
arg = *unwrap_shared_ptr< ns1::ClassB >(in[1],
"ptr_ns1ClassB");
366 auto obj = unwrap_shared_ptr<ns2::ClassA>(in[0],
"ptr_ns2ClassA");
368 out[0] =
wrap_shared_ptr(boost::make_shared<ns2::ns3::ClassB>(obj->nsReturn(q)),
"ns2.ns3.ClassB",
false);
380 typedef boost::shared_ptr<ns2::ns3::ClassB> Shared;
382 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
389 typedef boost::shared_ptr<ns2::ns3::ClassB> Shared;
391 Shared *
self =
new Shared(
new ns2::ns3::ClassB());
394 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
399 typedef boost::shared_ptr<ns2::ns3::ClassB> Shared;
401 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
402 Collector_ns2ns3ClassB::iterator item;
413 typedef boost::shared_ptr<ns2::ClassC> Shared;
415 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
422 typedef boost::shared_ptr<ns2::ClassC> Shared;
424 Shared *
self =
new Shared(
new ns2::ClassC());
427 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
432 typedef boost::shared_ptr<ns2::ClassC> Shared;
434 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
435 Collector_ns2ClassC::iterator item;
446 out[0] = wrap< Vector >(ns2::aGlobalFunction());
451 ns1::ClassA&
a = *unwrap_shared_ptr< ns1::ClassA >(in[0],
"ptr_ns1ClassA");
452 out[0] =
wrap_shared_ptr(boost::make_shared<ns1::ClassA>(ns2::overloadedGlobalFunction(a)),
"ns1.ClassA",
false);
457 ns1::ClassA&
a = *unwrap_shared_ptr< ns1::ClassA >(in[0],
"ptr_ns1ClassA");
459 out[0] =
wrap_shared_ptr(boost::make_shared<ns1::ClassA>(ns2::overloadedGlobalFunction(a,b)),
"ns1.ClassA",
false);
464 typedef boost::shared_ptr<ClassD> Shared;
466 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
473 typedef boost::shared_ptr<ClassD> Shared;
475 Shared *
self =
new Shared(
new ClassD());
478 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
483 typedef boost::shared_ptr<ClassD> Shared;
485 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
486 Collector_ClassD::iterator item;
495 void mexFunction(
int nargout, mxArray *out[],
int nargin,
const mxArray *in[])
498 std::streambuf *outbuf = std::cout.rdbuf(&mout);
585 }
catch(
const std::exception&
e) {
586 mexErrMsgTxt((
"Exception from gtsam:\n" + std::string(e.what()) +
"\n").c_str());
589 std::cout.rdbuf(outbuf);
void ns1ClassA_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
int unwrap< int >(const mxArray *array)
static Collector_MyTemplatePoint2 collector_MyTemplatePoint2
std::set< boost::shared_ptr< gtsam::Point2 > * > Collector_gtsamPoint2
std::set< boost::shared_ptr< Test > * > Collector_Test
std::set< boost::shared_ptr< ns2::ns3::ClassB > * > Collector_ns2ns3ClassB
void ClassD_deconstructor_25(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< PrimitiveRefDouble > * > Collector_PrimitiveRefDouble
static Collector_MyBase collector_MyBase
static Collector_MyTemplateMatrix collector_MyTemplateMatrix
void checkArguments(const string &name, int nargout, int nargin, int expected)
std::set< boost::shared_ptr< ForwardKinematicsFactor > * > Collector_ForwardKinematicsFactor
static Collector_MultipleTemplatesIntFloat collector_MultipleTemplatesIntFloat
MultipleTemplates< int, float > MultipleTemplatesIntFloat
MyTemplate< gtsam::Point2 > MyTemplatePoint2
std::set< boost::shared_ptr< gtsam::Point3 > * > Collector_gtsamPoint3
void ns2ClassC_deconstructor_19(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void ns2ClassA_constructor_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< MyTemplatePoint2 > * > Collector_MyTemplatePoint2
static Collector_gtsamPoint2 collector_gtsamPoint2
iterator iter(handle obj)
void ns2ClassC_constructor_18(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< gtsam::Point3 > * > Collector_gtsamPoint3
void overloadedGlobalFunction_21(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< ClassD > * > Collector_ClassD
std::set< boost::shared_ptr< MyVector12 > * > Collector_MyVector12
mxArray * wrap_shared_ptr(boost::shared_ptr< Class > shared_ptr, const std::string &matlabName, bool isVirtual)
GeneralSFMFactor< SfmCamera, Point3 > MyFactor
std::set< boost::shared_ptr< MultipleTemplatesIntDouble > * > Collector_MultipleTemplatesIntDouble
static Collector_ClassD collector_ClassD
std::set< boost::shared_ptr< ns2::ClassC > * > Collector_ns2ClassC
std::set< boost::shared_ptr< MyBase > * > Collector_MyBase
std::set< boost::shared_ptr< MultipleTemplatesIntDouble > * > Collector_MultipleTemplatesIntDouble
void ns2ClassA_deconstructor_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< ns1::ClassA > * > Collector_ns1ClassA
PrimitiveRef< double > PrimitiveRefDouble
static Collector_ns1ClassB collector_ns1ClassB
void ClassD_collectorInsertAndMakeBase_23(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< gtsam::Point2 > * > Collector_gtsamPoint2
void ns2ns3ClassB_deconstructor_16(int nargout, mxArray *out[], int nargin, const mxArray *in[])
MyTemplate< gtsam::Matrix > MyTemplateMatrix
void ns1ClassB_collectorInsertAndMakeBase_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_MyVector12 collector_MyVector12
void aGlobalFunction_20(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< MultipleTemplatesIntFloat > * > Collector_MultipleTemplatesIntFloat
double unwrap< double >(const mxArray *array)
std::set< boost::shared_ptr< MyFactorPosePoint2 > * > Collector_MyFactorPosePoint2
void ns2ClassC_collectorInsertAndMakeBase_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< MyTemplateMatrix > * > Collector_MyTemplateMatrix
void overloadedGlobalFunction_22(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_FunDouble collector_FunDouble
std::set< boost::shared_ptr< ns2::ClassA > * > Collector_ns2ClassA
std::set< boost::shared_ptr< FunDouble > * > Collector_FunDouble
static Collector_ns1ClassA collector_ns1ClassA
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void ns1ClassB_constructor_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< PrimitiveRefDouble > * > Collector_PrimitiveRefDouble
EIGEN_DEVICE_FUNC const Scalar & q
static Collector_Test collector_Test
std::set< boost::shared_ptr< ForwardKinematicsFactor > * > Collector_ForwardKinematicsFactor
static Collector_MultipleTemplatesIntDouble collector_MultipleTemplatesIntDouble
void ns2ClassA_collectorInsertAndMakeBase_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< MultipleTemplatesIntFloat > * > Collector_MultipleTemplatesIntFloat
void ns2ns3ClassB_collectorInsertAndMakeBase_14(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
mxArray * wrap< int >(const int &value)
std::set< boost::shared_ptr< Test > * > Collector_Test
static Collector_PrimitiveRefDouble collector_PrimitiveRefDouble
MyTemplate< gtsam::Matrix > MyTemplateMatrix
mxArray * wrap< double >(const double &value)
BOOST_CLASS_EXPORT_GUID(gtsam::Point2,"gtsamPoint2")
static Collector_FunRange collector_FunRange
std::set< boost::shared_ptr< MyVector3 > * > Collector_MyVector3
static Collector_ForwardKinematicsFactor collector_ForwardKinematicsFactor
MyTemplate< gtsam::Point2 > MyTemplatePoint2
void ClassD_constructor_24(int nargout, mxArray *out[], int nargin, const mxArray *in[])
#define mxUINT32OR64_CLASS
void ns2ClassA_nsArg_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< MyVector12 > * > Collector_MyVector12
std::set< boost::shared_ptr< FunDouble > * > Collector_FunDouble
MyVector< 12 > MyVector12
std::set< boost::shared_ptr< MyVector3 > * > Collector_MyVector3
std::set< boost::shared_ptr< ns1::ClassB > * > Collector_ns1ClassB
std::set< boost::shared_ptr< FunRange > * > Collector_FunRange
static Collector_MyFactorPosePoint2 collector_MyFactorPosePoint2
void ns1ClassA_constructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_ns2ClassA collector_ns2ClassA
void ns1ClassA_deconstructor_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
MyFactor< gtsam::Pose2, gtsam::Matrix > MyFactorPosePoint2
std::set< boost::shared_ptr< FunRange > * > Collector_FunRange
std::set< boost::shared_ptr< MyTemplateMatrix > * > Collector_MyTemplateMatrix
void ns1ClassB_deconstructor_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_gtsamPoint3 collector_gtsamPoint3
MultipleTemplates< int, double > MultipleTemplatesIntDouble
std::set< boost::shared_ptr< MyFactorPosePoint2 > * > Collector_MyFactorPosePoint2
std::set< boost::shared_ptr< MyTemplatePoint2 > * > Collector_MyTemplatePoint2
void ns2ClassA_afunction_13(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< boost::shared_ptr< MyBase > * > Collector_MyBase
static Collector_ns2ClassC collector_ns2ClassC
static Collector_ns2ns3ClassB collector_ns2ns3ClassB
void ns2ns3ClassB_constructor_15(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_MyVector3 collector_MyVector3
void aGlobalFunction_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void ns2ClassA_nsReturn_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void ns2ClassA_memberFunction_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void _namespaces_RTTIRegister()