Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Making C++ objects persistent between mex calls, and robust.
Posted:
Jun 8, 2010 9:34 AM
|
|
> So the solution is to define a class which inherits the handle class, something like this: > > classdef myclass < handle > properties (Hidden = true, SetAccess = private) > cpp_handle; > end > methods > % Constructor > function this = myclass() > this.cpp_handle = init_mex(); > end > % Destructor > function delete(this) > clear_mex(this.cpp_handle); > end > % Example method > function output = action(this, data) > output = action_mex(this.cpp_handle, data); > end > end > end >
Thank you Oliver. Couple more questions:
What exactly are you returning from init_mex()? Is that a pointer to a C++ class instance? Are you using "new" or "mxMalloc" to allocate the memory for that instance?
|
|
|
|