1 #include <gtwrap/matlab.h> 17 std::streambuf *outbuf = std::cout.rdbuf(&mout);
19 bool anyDeleted =
false;
35 "WARNING: Wrap modules with variables in the workspace have been reloaded due to\n" 36 "calling destructors, call 'clear all' again if you plan to now recompile a wrap\n" 37 "module, so that your recompiled module is used instead of the old one." << endl;
38 std::cout.rdbuf(outbuf);
42 const mxArray *alreadyCreated = mexGetVariablePtr(
"global",
"gtsam_template_rttiRegistry_created");
44 std::map<std::string, std::string> types;
48 mxArray *registry = mexGetVariable(
"global",
"gtsamwrap_rttiRegistry");
50 registry = mxCreateStructMatrix(1, 1, 0,
NULL);
51 typedef std::pair<std::string, std::string> StringPair;
52 for(
const StringPair& rtti_matlab: types) {
53 int fieldId = mxAddField(registry, rtti_matlab.first.c_str());
55 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
57 mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
58 mxSetFieldByNumber(registry, 0, fieldId, matlabName);
60 if(mexPutVariable(
"global",
"gtsamwrap_rttiRegistry", registry) != 0) {
61 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
63 mxDestroyArray(registry);
65 mxArray *newAlreadyCreated = mxCreateNumericMatrix(0, 0, mxINT8_CLASS, mxREAL);
66 if(mexPutVariable(
"global",
"gtsam_template_rttiRegistry_created", newAlreadyCreated) != 0) {
67 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
69 mxDestroyArray(newAlreadyCreated);
76 typedef std::shared_ptr<TemplatedConstructor> Shared;
78 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
85 typedef std::shared_ptr<TemplatedConstructor> Shared;
87 Shared *
self =
new Shared(
new TemplatedConstructor());
90 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
96 typedef std::shared_ptr<TemplatedConstructor> Shared;
98 string&
arg = *unwrap_shared_ptr< string >(in[0],
"ptr_string");
99 Shared *
self =
new Shared(
new TemplatedConstructor(arg));
102 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
108 typedef std::shared_ptr<TemplatedConstructor> Shared;
111 Shared *
self =
new Shared(
new TemplatedConstructor(arg));
114 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
120 typedef std::shared_ptr<TemplatedConstructor> Shared;
123 Shared *
self =
new Shared(
new TemplatedConstructor(arg));
126 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
131 typedef std::shared_ptr<TemplatedConstructor> Shared;
133 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
134 Collector_TemplatedConstructor::iterator item;
145 typedef std::shared_ptr<ScopedTemplate<Result>> Shared;
147 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
154 typedef std::shared_ptr<ScopedTemplate<Result>> Shared;
156 Result::Value&
arg = *unwrap_shared_ptr< Result::Value >(in[0],
"ptr_Result::Value");
157 Shared *
self =
new Shared(
new ScopedTemplate<Result>(arg));
160 *
reinterpret_cast<Shared**
> (mxGetData(out[0])) =
self;
165 typedef std::shared_ptr<ScopedTemplate<Result>> Shared;
167 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
168 Collector_ScopedTemplateResult::iterator item;
180 std::streambuf *outbuf = std::cout.rdbuf(&mout);
216 }
catch(
const std::exception&
e) {
217 mexErrMsgTxt((
"Exception from gtsam:\n" + std::string(e.what()) +
"\n").c_str());
220 std::cout.rdbuf(outbuf);
int unwrap< int >(const mxArray *array)
void ScopedTemplateResult_constructor_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void TemplatedConstructor_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::ofstream out("Result.txt")
void checkArguments(const string &name, int nargout, int nargin, int expected)
void ScopedTemplateResult_deconstructor_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
iterator iter(handle obj)
ScopedTemplate< Result > ScopedTemplateResult
void TemplatedConstructor_constructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
double unwrap< double >(const mxArray *array)
void TemplatedConstructor_deconstructor_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void TemplatedConstructor_constructor_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Array< double, 1, 3 > e(1./3., 0.5, 2.)
std::set< std::shared_ptr< TemplatedConstructor > * > Collector_TemplatedConstructor
void ScopedTemplateResult_collectorInsertAndMakeBase_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
#define mxUINT32OR64_CLASS
void TemplatedConstructor_constructor_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< std::shared_ptr< TemplatedConstructor > * > Collector_TemplatedConstructor
std::set< std::shared_ptr< ScopedTemplateResult > * > Collector_ScopedTemplateResult
static Collector_ScopedTemplateResult collector_ScopedTemplateResult
static Collector_TemplatedConstructor collector_TemplatedConstructor
void TemplatedConstructor_constructor_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void _template_RTTIRegister()