matlab::mex::Function
Base class for C++ MEX functions
Description
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.
Class Details
Namespace: | matlab::mex |
Include: | mexAdapter.hpp — Include this file only once
for the implementation of MexFunction
class |
Member Functions
operator()
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) {
...
}
}getEngine
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"));
mexLock
void mexLock()Prevents clearing MEX file from memory. Do not call mexLock or
mexUnlock from a user thread.
Lock the MEX file.
mexLock();mexUnlock
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();getFunctionName
std::u16string getFunctionName() constReturns 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();Version History
Introduced in R2018a