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);