Base class for C++ MEX functions
The MexFunction
class that you implement in C++ MEX functions must
inherit from the matlab.mex.Function
class. The
matlab.mex.Function
class enables access to the C++ Engine API
and defines a virtual operator()
function that your
MexFunction
class must override.
Namespace: | matlab::mex |
Include: | mexAdapter.hpp — Include this file only once
for the implementation of MexFunction
class |
virtual void operator()(ArgumentList outputs, ArgumentList inputs)
Function call operator that you must override in the
MexFunction
class. This operator enables instances of your
MexFunction
class to be called like a function.
matlab::mex::ArgumentList outputs | Collection of matlab::data::Array objects
that are returned to MATLAB® |
matlab::mex::ArgumentList inputs | Collection of matlab::data::Array objects
that are passed to the MEX function from MATLAB |
class MexFunction : public matlab::mex::Function { public: void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) { ... } }
std::shared_ptr<matlab::engine::MATLABEngine> getEngine()
Returns a pointer to the MATLABEngine
object, which enables
access to the C++ Engine API.
|
Pointer to |
Call the MATLAB
clear
function.
std::shared_ptr<MATLABEngine> matlabPtr = getEngine(); matlabPtr->eval(matlab::engine::convertUTF8StringToUTF16String("clear"));
void mexLock()
Prevents clearing MEX file from memory. Do not call mexLock
or
mexUnlock
from a user thread.
Lock the MEX file.
mexLock();
Unlocks MEX file and allows clearing of the file from memory. Do not call
mexLock
or mexUnlock
from a user
thread.
void mexLock()
Unlock the MEX file.
mexUnlock();
std::u16string getFunctionName() const
Returns the name of the MEX function, which is the name of the source file.
Get the file name of the currently executing MEX function.
std::u16string fileName = getFunctionName();