enum_wrapper.cpp
Go to the documentation of this file.
1 #include <gtwrap/matlab.h>
2 #include <map>
3 
4 
5 
6 typedef gtsam::Optimizer<gtsam::GaussNewtonParams> OptimizerGaussNewtonParams;
7 
8 typedef std::set<std::shared_ptr<Pet>*> Collector_Pet;
10 typedef std::set<std::shared_ptr<gtsam::MCU>*> Collector_gtsamMCU;
12 typedef std::set<std::shared_ptr<OptimizerGaussNewtonParams>*> Collector_gtsamOptimizerGaussNewtonParams;
14 
15 
17 {
18  mstream mout;
19  std::streambuf *outbuf = std::cout.rdbuf(&mout);
20 
21  bool anyDeleted = false;
22  { for(Collector_Pet::iterator iter = collector_Pet.begin();
23  iter != collector_Pet.end(); ) {
24  delete *iter;
25  collector_Pet.erase(iter++);
26  anyDeleted = true;
27  } }
28  { for(Collector_gtsamMCU::iterator iter = collector_gtsamMCU.begin();
29  iter != collector_gtsamMCU.end(); ) {
30  delete *iter;
31  collector_gtsamMCU.erase(iter++);
32  anyDeleted = true;
33  } }
34  { for(Collector_gtsamOptimizerGaussNewtonParams::iterator iter = collector_gtsamOptimizerGaussNewtonParams.begin();
36  delete *iter;
38  anyDeleted = true;
39  } }
40 
41  if(anyDeleted)
42  cout <<
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);
47 }
48 
50  const mxArray *alreadyCreated = mexGetVariablePtr("global", "gtsam_enum_rttiRegistry_created");
51  if(!alreadyCreated) {
52  std::map<std::string, std::string> types;
53 
54 
55 
56  mxArray *registry = mexGetVariable("global", "gtsamwrap_rttiRegistry");
57  if(!registry)
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());
62  if(fieldId < 0) {
63  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
64  }
65  mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
66  mxSetFieldByNumber(registry, 0, fieldId, matlabName);
67  }
68  if(mexPutVariable("global", "gtsamwrap_rttiRegistry", registry) != 0) {
69  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
70  }
71  mxDestroyArray(registry);
72 
73  mxArray *newAlreadyCreated = mxCreateNumericMatrix(0, 0, mxINT8_CLASS, mxREAL);
74  if(mexPutVariable("global", "gtsam_enum_rttiRegistry_created", newAlreadyCreated) != 0) {
75  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
76  }
77  mxDestroyArray(newAlreadyCreated);
78  }
79 }
80 
81 void Pet_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
82 {
83  mexAtExit(&_deleteAllObjects);
84  typedef std::shared_ptr<Pet> Shared;
85 
86  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
87  collector_Pet.insert(self);
88 }
89 
90 void Pet_constructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
91 {
92  mexAtExit(&_deleteAllObjects);
93  typedef std::shared_ptr<Pet> Shared;
94 
95  string& name = *unwrap_shared_ptr< string >(in[0], "ptr_string");
96  Pet::Kind type = unwrap_enum<Pet::Kind>(in[1]);
97  Shared *self = new Shared(new Pet(name,type));
98  collector_Pet.insert(self);
99  out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
100  *reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
101 }
102 
103 void Pet_deconstructor_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
104 {
105  typedef std::shared_ptr<Pet> Shared;
106  checkArguments("delete_Pet",nargout,nargin,1);
107  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
108  Collector_Pet::iterator item;
109  item = collector_Pet.find(self);
110  if(item != collector_Pet.end()) {
111  collector_Pet.erase(item);
112  }
113  delete self;
114 }
115 
116 void Pet_getColor_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
117 {
118  checkArguments("getColor",nargout,nargin-1,0);
119  auto obj = unwrap_shared_ptr<Pet>(in[0], "ptr_Pet");
120  out[0] = wrap_enum(obj->getColor(),"Color");
121 }
122 
123 void Pet_setColor_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
124 {
125  checkArguments("setColor",nargout,nargin-1,1);
126  auto obj = unwrap_shared_ptr<Pet>(in[0], "ptr_Pet");
127  Color color = unwrap_enum<Color>(in[1]);
128  obj->setColor(color);
129 }
130 
131 void Pet_get_name_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
132 {
133  checkArguments("name",nargout,nargin-1,0);
134  auto obj = unwrap_shared_ptr<Pet>(in[0], "ptr_Pet");
135  out[0] = wrap< string >(obj->name);
136 }
137 
138 void Pet_set_name_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
139 {
140  checkArguments("name",nargout,nargin-1,1);
141  auto obj = unwrap_shared_ptr<Pet>(in[0], "ptr_Pet");
142  string name = unwrap< string >(in[1]);
143  obj->name = name;
144 }
145 
146 void Pet_get_type_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
147 {
148  checkArguments("type",nargout,nargin-1,0);
149  auto obj = unwrap_shared_ptr<Pet>(in[0], "ptr_Pet");
150  out[0] = wrap_enum(obj->type,"Pet.Kind");
151 }
152 
153 void Pet_set_type_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
154 {
155  checkArguments("type",nargout,nargin-1,1);
156  auto obj = unwrap_shared_ptr<Pet>(in[0], "ptr_Pet");
157  Pet::Kind type = unwrap_enum<Pet::Kind>(in[1]);
158  obj->type = type;
159 }
160 
161 void gtsamMCU_collectorInsertAndMakeBase_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
162 {
163  mexAtExit(&_deleteAllObjects);
164  typedef std::shared_ptr<gtsam::MCU> Shared;
165 
166  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
167  collector_gtsamMCU.insert(self);
168 }
169 
170 void gtsamMCU_constructor_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
171 {
172  mexAtExit(&_deleteAllObjects);
173  typedef std::shared_ptr<gtsam::MCU> Shared;
174 
175  Shared *self = new Shared(new gtsam::MCU());
176  collector_gtsamMCU.insert(self);
177  out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
178  *reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
179 }
180 
181 void gtsamMCU_deconstructor_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
182 {
183  typedef std::shared_ptr<gtsam::MCU> Shared;
184  checkArguments("delete_gtsamMCU",nargout,nargin,1);
185  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
186  Collector_gtsamMCU::iterator item;
187  item = collector_gtsamMCU.find(self);
188  if(item != collector_gtsamMCU.end()) {
189  collector_gtsamMCU.erase(item);
190  }
191  delete self;
192 }
193 
194 void gtsamOptimizerGaussNewtonParams_collectorInsertAndMakeBase_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
195 {
196  mexAtExit(&_deleteAllObjects);
197  typedef std::shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>> Shared;
198 
199  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
201 }
202 
203 void gtsamOptimizerGaussNewtonParams_constructor_13(int nargout, mxArray *out[], int nargin, const mxArray *in[])
204 {
205  mexAtExit(&_deleteAllObjects);
206  typedef std::shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>> Shared;
207 
208  Optimizer<gtsam::GaussNewtonParams>::Verbosity verbosity = unwrap_enum<Optimizer<gtsam::GaussNewtonParams>::Verbosity>(in[0]);
209  Shared *self = new Shared(new gtsam::Optimizer<gtsam::GaussNewtonParams>(verbosity));
211  out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
212  *reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
213 }
214 
215 void gtsamOptimizerGaussNewtonParams_deconstructor_14(int nargout, mxArray *out[], int nargin, const mxArray *in[])
216 {
217  typedef std::shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>> Shared;
218  checkArguments("delete_gtsamOptimizerGaussNewtonParams",nargout,nargin,1);
219  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
220  Collector_gtsamOptimizerGaussNewtonParams::iterator item;
224  }
225  delete self;
226 }
227 
228 void gtsamOptimizerGaussNewtonParams_getVerbosity_15(int nargout, mxArray *out[], int nargin, const mxArray *in[])
229 {
230  checkArguments("getVerbosity",nargout,nargin-1,0);
231  auto obj = unwrap_shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>>(in[0], "ptr_gtsamOptimizerGaussNewtonParams");
232  out[0] = wrap_enum(obj->getVerbosity(),"gtsam.OptimizerGaussNewtonParams.Verbosity");
233 }
234 
235 void gtsamOptimizerGaussNewtonParams_getVerbosity_16(int nargout, mxArray *out[], int nargin, const mxArray *in[])
236 {
237  checkArguments("getVerbosity",nargout,nargin-1,0);
238  auto obj = unwrap_shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>>(in[0], "ptr_gtsamOptimizerGaussNewtonParams");
239  out[0] = wrap_enum(obj->getVerbosity(),"gtsam.VerbosityLM");
240 }
241 
242 void gtsamOptimizerGaussNewtonParams_setVerbosity_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
243 {
244  checkArguments("setVerbosity",nargout,nargin-1,1);
245  auto obj = unwrap_shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>>(in[0], "ptr_gtsamOptimizerGaussNewtonParams");
246  Optimizer<gtsam::GaussNewtonParams>::Verbosity value = unwrap_enum<Optimizer<gtsam::GaussNewtonParams>::Verbosity>(in[1]);
247  obj->setVerbosity(value);
248 }
249 
250 
251 void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
252 {
253  mstream mout;
254  std::streambuf *outbuf = std::cout.rdbuf(&mout);
255 
257 
258  int id = unwrap<int>(in[0]);
259 
260  try {
261  switch(id) {
262  case 0:
263  Pet_collectorInsertAndMakeBase_0(nargout, out, nargin-1, in+1);
264  break;
265  case 1:
266  Pet_constructor_1(nargout, out, nargin-1, in+1);
267  break;
268  case 2:
269  Pet_deconstructor_2(nargout, out, nargin-1, in+1);
270  break;
271  case 3:
272  Pet_getColor_3(nargout, out, nargin-1, in+1);
273  break;
274  case 4:
275  Pet_setColor_4(nargout, out, nargin-1, in+1);
276  break;
277  case 5:
278  Pet_get_name_5(nargout, out, nargin-1, in+1);
279  break;
280  case 6:
281  Pet_set_name_6(nargout, out, nargin-1, in+1);
282  break;
283  case 7:
284  Pet_get_type_7(nargout, out, nargin-1, in+1);
285  break;
286  case 8:
287  Pet_set_type_8(nargout, out, nargin-1, in+1);
288  break;
289  case 9:
290  gtsamMCU_collectorInsertAndMakeBase_9(nargout, out, nargin-1, in+1);
291  break;
292  case 10:
293  gtsamMCU_constructor_10(nargout, out, nargin-1, in+1);
294  break;
295  case 11:
296  gtsamMCU_deconstructor_11(nargout, out, nargin-1, in+1);
297  break;
298  case 12:
300  break;
301  case 13:
302  gtsamOptimizerGaussNewtonParams_constructor_13(nargout, out, nargin-1, in+1);
303  break;
304  case 14:
305  gtsamOptimizerGaussNewtonParams_deconstructor_14(nargout, out, nargin-1, in+1);
306  break;
307  case 15:
308  gtsamOptimizerGaussNewtonParams_getVerbosity_15(nargout, out, nargin-1, in+1);
309  break;
310  case 16:
311  gtsamOptimizerGaussNewtonParams_getVerbosity_16(nargout, out, nargin-1, in+1);
312  break;
313  case 17:
314  gtsamOptimizerGaussNewtonParams_setVerbosity_17(nargout, out, nargin-1, in+1);
315  break;
316  }
317  } catch(const std::exception& e) {
318  mexErrMsgTxt(("Exception from gtsam:\n" + std::string(e.what()) + "\n").c_str());
319  }
320 
321  std::cout.rdbuf(outbuf);
322 }
gtsamOptimizerGaussNewtonParams_setVerbosity_17
void gtsamOptimizerGaussNewtonParams_setVerbosity_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:242
wrap< string >
mxArray * wrap< string >(const string &value)
Definition: matlab.h:134
name
Annotation for function names.
Definition: attr.h:51
gtsamOptimizerGaussNewtonParams_getVerbosity_16
void gtsamOptimizerGaussNewtonParams_getVerbosity_16(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:235
gtsamOptimizerGaussNewtonParams_constructor_13
void gtsamOptimizerGaussNewtonParams_constructor_13(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:203
gtsam.examples.DogLegOptimizerExample.type
type
Definition: DogLegOptimizerExample.py:111
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsamOptimizerGaussNewtonParams_deconstructor_14
void gtsamOptimizerGaussNewtonParams_deconstructor_14(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:215
Pet_constructor_1
void Pet_constructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:90
type
Definition: pytypes.h:1525
gtsamMCU_constructor_10
void gtsamMCU_constructor_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:170
Pet_get_type_7
void Pet_get_type_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:146
Pet_getColor_3
void Pet_getColor_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:116
gtsamOptimizerGaussNewtonParams_getVerbosity_15
void gtsamOptimizerGaussNewtonParams_getVerbosity_15(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:228
Pet_setColor_4
void Pet_setColor_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:123
gtsamMCU_collectorInsertAndMakeBase_9
void gtsamMCU_collectorInsertAndMakeBase_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:161
name
static char name[]
Definition: rgamma.c:72
mxUINT32OR64_CLASS
#define mxUINT32OR64_CLASS
Definition: matlab.h:58
mexFunction
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:251
Pet_set_type_8
void Pet_set_type_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:153
Pet_set_name_6
void Pet_set_name_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:138
checkArguments
void checkArguments(const string &name, int nargout, int nargin, int expected)
Definition: matlab.h:113
mstream
Definition: matlab.h:95
unwrap< int >
int unwrap< int >(const mxArray *array)
Definition: matlab.h:328
Pet_collectorInsertAndMakeBase_0
void Pet_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:81
wrap_enum
mxArray * wrap_enum(const T x, const std::string &classname)
Wrap the C++ enum to Matlab mxArray.
Definition: matlab.h:236
collector_gtsamMCU
static Collector_gtsamMCU collector_gtsamMCU
Definition: enum_wrapper.cpp:11
gtsamOptimizerGaussNewtonParams_collectorInsertAndMakeBase_12
void gtsamOptimizerGaussNewtonParams_collectorInsertAndMakeBase_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:194
out
std::ofstream out("Result.txt")
Collector_gtsamMCU
std::set< std::shared_ptr< gtsam::MCU > * > Collector_gtsamMCU
Definition: enum_wrapper.cpp:10
collector_gtsamOptimizerGaussNewtonParams
static Collector_gtsamOptimizerGaussNewtonParams collector_gtsamOptimizerGaussNewtonParams
Definition: enum_wrapper.cpp:13
_deleteAllObjects
void _deleteAllObjects()
Definition: enum_wrapper.cpp:16
Color
Vector4f Color
Definition: gpuhelper.h:19
iter
iterator iter(handle obj)
Definition: pytypes.h:2475
Pet_get_name_5
void Pet_get_name_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:131
collector_Pet
static Collector_Pet collector_Pet
Definition: enum_wrapper.cpp:9
unwrap< string >
string unwrap< string >(const mxArray *array)
Definition: matlab.h:283
Collector_gtsamOptimizerGaussNewtonParams
std::set< std::shared_ptr< OptimizerGaussNewtonParams > * > Collector_gtsamOptimizerGaussNewtonParams
Definition: enum_wrapper.cpp:12
NULL
#define NULL
Definition: ccolamd.c:609
gtsamMCU_deconstructor_11
void gtsamMCU_deconstructor_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:181
OptimizerGaussNewtonParams
gtsam::Optimizer< gtsam::GaussNewtonParams > OptimizerGaussNewtonParams
Definition: enum_wrapper.cpp:6
Collector_Pet
std::set< std::shared_ptr< Pet > * > Collector_Pet
Definition: enum_wrapper.cpp:8
test_callbacks.value
value
Definition: test_callbacks.py:160
Pet_deconstructor_2
void Pet_deconstructor_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: enum_wrapper.cpp:103
_enum_RTTIRegister
void _enum_RTTIRegister()
Definition: enum_wrapper.cpp:49


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:30