matlab::mex::Function - Base class for C++ MEX functions - MATLAB (original) (raw)
Main Content
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. Thematlab.mex.Function
class enables access to the C++ Engine API and defines a virtual operator()
function that yourMexFunction
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 theMexFunction
class. This operator enables instances of yourMexFunction
class to be called like a function.
Parameters
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 |
Examples
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.
Returns
std::shared_ptrmatlab::engine::MATLABEngine | Pointer to MATLABEngine object |
---|
Examples
Call the MATLABclear
function.
std::shared_ptr matlabPtr = getEngine(); matlabPtr->eval(matlab::engine::convertUTF8StringToUTF16String("clear"));
mexLock
Prevents clearing MEX file from memory. Do not call mexLock
ormexUnlock
from a user thread.
Examples
Lock the MEX file.
mexUnlock
Unlocks MEX file and allows clearing of the file from memory. Do not callmexLock
or mexUnlock
from a user thread.
Examples
Unlock the MEX file.
getFunctionName
std::u16string getFunctionName() const
Returns the name of the MEX function, which is the name of the source file.
Examples
Get the file name of the currently executing MEX function.
std::u16string fileName = getFunctionName();
Version History
Introduced in R2018a