MexIFace
A C++/Matlab object-based interface library and cross-platform CMake MEX build tool.
|
Base class for the C++ side of a MexIFace interface class. More...
#include </home/travis/build/markjolah/MexIFace/include/MexIFace/MexIFace.h>
Public Types | |
using | MXArgCountT = int |
using | IdxT = arma::uword |
template<class T > | |
using | Vec = arma::Col< T > |
template<class T > | |
using | Mat = arma::Mat< T > |
template<class T > | |
using | Cube = arma::Cube< T > |
template<class T > | |
using | Hypercube = hypercube::Hypercube< T > |
template<class T > | |
using | Dict = std::map< std::string, T > |
template<class T > | |
using | IsArithmeticT = typename std::enable_if< std::is_arithmetic< T >::value >::type |
template<class T > | |
using | IsNotArithmeticT = typename std::enable_if<!std::is_arithmetic< T >::value >::type |
template<class T > | |
using | IsIntegralT = typename std::enable_if< std::is_integral< T >::value >::type |
template<class T > | |
using | IsUnsignedIntegralT = typename std::enable_if< std::is_integral< T >::value &&std::is_same< T, typename std::make_unsigned< T >::type >::value >::type |
template<class T > | |
using | IsFloatingPointT = typename std::enable_if< std::is_floating_point< T >::value >::type |
Public Member Functions | |
MexIFace () | |
Default constructor. More... | |
void | mexFunction (MXArgCountT _nlhs, mxArray *_lhs[], MXArgCountT _nrhs, const mxArray *_rhs[]) |
The mexFunction that will be exposed as the entry point for the .mex file. More... | |
Static Public Member Functions | |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
static ElemT | toScalar (const mxArray *m) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static Vec< ElemT > | toVec (const mxArray *m) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static Mat< ElemT > | toMat (const mxArray *m) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static Cube< ElemT > | toCube (const mxArray *m) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static Hypercube< ElemT > | toHypercube (const mxArray *m) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
static ElemT | checkedToScalar (const mxArray *m) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static Vec< ElemT > | checkedToVec (const mxArray *m) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static Mat< ElemT > | checkedToMat (const mxArray *m) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static Cube< ElemT > | checkedToCube (const mxArray *m) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static Hypercube< ElemT > | checkedToHypercube (const mxArray *m) |
static mxArray * | toMXArray (bool val) |
static mxArray * | toMXArray (const char *val) |
static mxArray * | toMXArray (std::string val) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static mxArray * | toMXArray (ElemT val) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static mxArray * | toMXArray (const Vec< ElemT > &arr) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static mxArray * | toMXArray (const Mat< ElemT > &arr) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static mxArray * | toMXArray (const Cube< ElemT > &arr) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static mxArray * | toMXArray (const Hypercube< ElemT > &arr) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static mxArray * | toMXArray (const arma::SpMat< ElemT > &arr) |
template<class ElemT , typename = IsArithmeticT<ElemT>> | |
static mxArray * | toMXArray (const std::list< ElemT > &arr) |
template<class ConvertableT > | |
static mxArray * | toMXArray (const Dict< ConvertableT > &arr) |
template<template< typename... > class Array, class ConvertableT > | |
static mxArray * | toMXArray (const Array< ConvertableT > &arr) |
template<class SrcIntT , class DestIntT , typename = IsIntegralT<SrcIntT>, typename = IsIntegralT<DestIntT>> | |
static DestIntT | checkedIntegerToIntegerConversion (const mxArray *m) |
template<class SrcFloatT , class DestIntT , typename = IsFloatingPointT<SrcFloatT>, typename = IsIntegralT<DestIntT>> | |
static DestIntT | checkedFloatToIntegerConversion (const mxArray *m) |
template<class SrcIntT , class DestFloatT , typename = IsIntegralT<SrcIntT>, typename = IsFloatingPointT<DestFloatT>> | |
static DestFloatT | checkedIntegerToFloatConversion (const mxArray *m) |
template<class SrcFloatT , class DestFloatT , typename = IsFloatingPointT<SrcFloatT>, typename = IsFloatingPointT<DestFloatT>> | |
static DestFloatT | checkedFloatToFloatConversion (const mxArray *m) |
template<class ElemT > | |
static void | checkType (const mxArray *m) |
static void | checkType (const mxArray *m, mxClassID classid) |
static void | checkNdim (const mxArray *m, mwSize expected_dim) |
static void | checkMaxNdim (const mxArray *m, mwSize max_expected_dim) |
static void | checkScalarSize (const mxArray *m) |
static void | checkVectorSize (const mxArray *m) |
static void | checkVectorSize (const mxArray *m, mwSize expected_numel) |
Checks that a matlab mxArray object has the correct 2D dimensions. More... | |
static void | checkMatrixSize (const mxArray *m, mwSize expected_rows, mwSize expected_cols) |
Checks that a matlab mxArray object has the correct 2D dimensions. More... | |
static void | checkSameLastDim (const mxArray *m1, const mxArray *m2) |
Checks that two matlab mxArray objects have the same sized last dimension. More... | |
Protected Types | |
using | MethodMap = std::map< std::string, std::function< void()>> |
Protected Member Functions | |
void | checkNumArgs (MXArgCountT expected_nlhs, MXArgCountT expected_nrhs) const |
Checks the mex function was called with an exact number of input and output arguments. More... | |
void | checkMinNumArgs (MXArgCountT min_nlhs, MXArgCountT min_nrhs) const |
Checks the mex function was called with a minimum number of input and output arguments. More... | |
void | checkMaxNumArgs (MXArgCountT max_nlhs, MXArgCountT max_nrhs) const |
Checks the mex function was called with a maximum number of input and output arguments. More... | |
void | checkInputArgRange (MXArgCountT min_nrhs, MXArgCountT max_nrhs) const |
void | checkOutputArgRange (MXArgCountT min_nlhs, MXArgCountT max_nlhs) const |
template<class ElemT = double> | |
ElemT | getAsScalar (const mxArray *m=nullptr) |
bool | getAsBool (const mxArray *m=nullptr) |
template<class IntT = int64_t, typename = IsIntegralT<IntT>> | |
IntT | getAsInt (const mxArray *m=nullptr) |
Reads a mxArray as a scalar C++ int32_t type. More... | |
template<class UnsignedT = uint64_t, typename = IsUnsignedIntegralT<UnsignedT>> | |
UnsignedT | getAsUnsigned (const mxArray *m=nullptr) |
template<class FloatT = double, typename = IsFloatingPointT<FloatT>> | |
FloatT | getAsFloat (const mxArray *m=nullptr) |
template<class ElemT = double> | |
Dict< ElemT > | getAsScalarDict (const mxArray *m=nullptr) |
template<template< typename... > class Array = std::vector, class ElemT = double> | |
Array< ElemT > | getAsScalarArray (const mxArray *m=nullptr) |
std::string | getString (const mxArray *mxdata=nullptr) |
Reads a mxArray as a string. More... | |
template<template< typename... > class Array = std::vector> | |
Array< std::string > | getStringArray (const mxArray *mxdata=nullptr) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
ElemT | getScalar (const mxArray *mxdata=nullptr) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Vec< ElemT > | getVec (const mxArray *mxdata=nullptr) |
Create a armadillo Column vector to directly use the Matlab data for a 1D array of arbitrary element type. More... | |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Mat< ElemT > | getMat (const mxArray *mxdata=nullptr) |
Create an armadillo Mat object to directly work with the Matlab data for a 2D array of arbitrary element type. More... | |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Cube< ElemT > | getCube (const mxArray *mxdata=nullptr) |
Create an armadillo Cube object to directly work with the Matlab data for a 3D array of arbitrary element type. More... | |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Hypercube< ElemT > | getHypercube (const mxArray *mxdata=nullptr) |
Create an Hypercube object to directly work with the Matlab data for a 4D array of arbitrary element type. More... | |
template<template< typename > class NumericArrayT, class ElemT = double> | |
NumericArrayT< ElemT > | getNumeric (const mxArray *m=nullptr) |
template<template< typename... > class Array = std::vector, class ElemT = double> | |
Array< ElemT > | getScalarArray (const mxArray *mxdata=nullptr) |
template<template< typename > class Array = std::vector, class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Array< Vec< ElemT > > | getVecArray (const mxArray *mxdata=nullptr) |
template<template< typename > class Array = std::vector, class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Array< Mat< ElemT > > | getMatArray (const mxArray *mxdata=nullptr) |
template<template< typename > class Array = std::vector, class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Array< Cube< ElemT > > | getCubeArray (const mxArray *mxdata=nullptr) |
template<template< typename > class Array = std::vector, class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Array< Hypercube< ElemT > > | getHypercubeArray (const mxArray *mxdata=nullptr) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Dict< ElemT > | getScalarDict (const mxArray *mxdata=nullptr) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Dict< Vec< ElemT > > | getVecDict (const mxArray *mxdata=nullptr) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Dict< Mat< ElemT > > | getMatDict (const mxArray *mxdata=nullptr) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Dict< Cube< ElemT > > | getCubeDict (const mxArray *mxdata=nullptr) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Dict< Hypercube< ElemT > > | getHypercubeDict (const mxArray *mxdata=nullptr) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Vec< ElemT > | makeOutputArray (IdxT nelem) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Mat< ElemT > | makeOutputArray (IdxT rows, IdxT cols) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Cube< ElemT > | makeOutputArray (IdxT rows, IdxT cols, IdxT slices) |
template<class ElemT = double, typename = IsArithmeticT<ElemT>> | |
Hypercube< ElemT > | makeOutputArray (IdxT rows, IdxT cols, IdxT slices, IdxT hyperslices) |
void | output (mxArray *m) overridefinal |
Append a generic mxArray to the output arguments This is virtual because MexIFaceHandler need to use it to output a Handle pointer. More... | |
template<class ConvertableT > | |
void | output (ConvertableT &&val) |
void | error (std::string condition, std::string message) const |
Reports an error condition to Matlab using the mexErrMsgIdAndTxt function. More... | |
void | error (std::string component, std::string condition, std::string message) const |
Reports an error condition in a specified component to Matlab using the mexErrMsgIdAndTxt function. More... | |
virtual void | objConstruct ()=0 |
Called when the mexFunction gets the @new command, passing on the remaining input arguments. More... | |
virtual void | objDestroy (const mxArray *mxhandle)=0 |
Called when the mexFunction gets the @delete command. More... | |
virtual void | getObjectFromHandle (const mxArray *mxhandle)=0 |
Helper method which saves a pointer to the wrapped class's object in an internal member variable called obj. More... | |
virtual std::string | obj_name () const =0 |
Get the name of the class of the stored object. More... | |
Protected Attributes | |
MethodMap | methodmap |
Maps names (std::string) to member functions (std::function<void()>) More... | |
MethodMap | staticmethodmap |
Maps names (std::string) to static member functions (std::function<void()>) More... | |
MXArgCountT | nlhs |
Number of left-hand-side (output) arguments passed to MexIFace::mexFunction. More... | |
mxArray ** | lhs |
Left-hand-side (output) argument array. Size=nlhs. More... | |
IdxT | lhs_idx |
Index of the next left-hand-side argument to write as output. More... | |
MXArgCountT | nrhs |
Number of right-hand-side (input) arguments passed to MexIFace::mexFunction. More... | |
const mxArray ** | rhs |
Right-hand-side (input) argument array. Size=nrhs. More... | |
IdxT | rhs_idx |
Index of the next right-hand-side argument to read as input. More... | |
Base class for the C++ side of a MexIFace interface class.
The MexIFace class is responsible for managing the C++ side of the MEX interface. The primary entry point from Matlab is the MexIFace::mexFunction method which takes in a variable number of arguments and returns a variable number of arguments. The first input argument is always a string that gives the command name. If it the special command "\@new" or "\@delete" a C++ instance is created or destroyed. The @new command returns a unique handle (number) which can be held onto by the Matlab IfaceMixin base class. This C++ object then remains in memory until the @delete command is called on the MexIFace, which then frees the underlying C++ class from memory.
The special command "\@static" allows static C++ methods to be called by the name passed as the second argument, and there is no need to have a existing object to call the method on because it is static.
Otherwise the command is interpreted as a named method which is registered in the methodmap, internal data structure which maps strings to callable member functions of the interface object which take in no arguments and return no arguments. The Matlab arguments are passed to these functions through the internal storage of the MexIFace object's rhs and lhs member variables.
A C++ class is wrapped by creating a new IFace class that inherits from MexIFace. At a minimum the Iface class must define the pure virtual functions objConstruct(), objDestroy(), and getObjectFromHandle(). It also must implement the interface for any of the methods and static methods that are required. Each of these methods in the Iface class must process the passed Matlab arguments in the rhs member variable and save outputs in the lhs member variable.
In general the Iface mex modules are not intended to be used directly, but rather are paired with a special Matlab class that inherits from the MexIFaceMixin.m base class.
Design decision: Because of the complexities of inheriting from a templated base class with regard to name lookups in superclasses, we chose to keep this MexIFace class non-templated. For this reason any methods and member variables which specifically mention the type of the wrapped class must be defined in the subclass of MexIFace.
Finally we provide many get* and make* which allow the lhs and rhs arguments to be interpreted as armadillo arrays on the C++ side. These methods are part of what makes this interface efficient as we don't need to create new storage and copy data, instead we just use the matlab memory directly, and matlab does all the memory management of parameters passed in and out.
Definition at line 64 of file MexIFace.h.
using mexiface::MexIFace::Cube = arma::Cube<T> |
Definition at line 71 of file MexIFace.h.
using mexiface::MexIFace::Dict = std::map<std::string,T> |
A convenient form for reporting dictionaries of named FP data to matlab
Definition at line 74 of file MexIFace.h.
using mexiface::MexIFace::Hypercube = hypercube::Hypercube<T> |
Definition at line 72 of file MexIFace.h.
using mexiface::MexIFace::IdxT = arma::uword |
A logical type for an IdxT integer index
Definition at line 67 of file MexIFace.h.
using mexiface::MexIFace::IsArithmeticT = typename std::enable_if<std::is_arithmetic<T>::value>::type |
Definition at line 76 of file MexIFace.h.
using mexiface::MexIFace::IsFloatingPointT = typename std::enable_if< std::is_floating_point<T>::value >::type |
Definition at line 80 of file MexIFace.h.
using mexiface::MexIFace::IsIntegralT = typename std::enable_if< std::is_integral<T>::value >::type |
Definition at line 78 of file MexIFace.h.
using mexiface::MexIFace::IsNotArithmeticT = typename std::enable_if<!std::is_arithmetic<T>::value>::type |
Definition at line 77 of file MexIFace.h.
using mexiface::MexIFace::IsUnsignedIntegralT = typename std::enable_if< std::is_integral<T>::value && std::is_same<T, typename std::make_unsigned<T>::type>::value >::type |
Definition at line 79 of file MexIFace.h.
using mexiface::MexIFace::Mat = arma::Mat<T> |
Definition at line 70 of file MexIFace.h.
|
protected |
The type of mapping for mapping names to member functions to call
Definition at line 177 of file MexIFace.h.
using mexiface::MexIFace::MXArgCountT = int |
Type for the mexFunction arg counts and associated nrhs and nlhs data members
Definition at line 66 of file MexIFace.h.
using mexiface::MexIFace::Vec = arma::Col<T> |
Definition at line 69 of file MexIFace.h.
mexiface::MexIFace::MexIFace | ( | ) |
Default constructor.
Definition at line 18 of file MexIFace.cpp.
|
static |
Definition at line 657 of file MexIFace.h.
References mexiface::get_mx_class_name().
|
static |
Definition at line 629 of file MexIFace.h.
References mexiface::get_mx_class_name().
|
static |
Definition at line 643 of file MexIFace.h.
References mexiface::get_mx_class_name().
|
static |
Definition at line 600 of file MexIFace.h.
References mexiface::get_mx_class_name().
|
static |
Definition at line 584 of file MexIFace.h.
References checkMaxNdim().
|
static |
Definition at line 592 of file MexIFace.h.
References checkMaxNdim().
|
static |
Definition at line 576 of file MexIFace.h.
References checkNdim().
|
static |
Definition at line 560 of file MexIFace.h.
References checkScalarSize().
|
static |
Definition at line 568 of file MexIFace.h.
References checkVectorSize().
|
inlineprotected |
Definition at line 432 of file MexIFace.h.
References nrhs.
|
inlinestatic |
Checks that a matlab mxArray object has the correct 2D dimensions.
m | A pointer to the mxArray to check |
expected_rows | the expected number of rows |
expected_cols | the expected number of cols |
Definition at line 399 of file MexIFace.h.
|
inlinestatic |
Test doc here. And more here
Definition at line 343 of file MexIFace.h.
Referenced by checkedToCube(), and checkedToHypercube().
|
inlineprotected |
Checks the mex function was called with a maximum number of input and output arguments.
max_nlhs | Maxmum number of left hand side (output) arguments required. |
max_nrhs | Maxmum number of right hand side (input) arguments required. |
Definition at line 475 of file MexIFace.h.
|
inlineprotected |
Checks the mex function was called with a minimum number of input and output arguments.
min_nlhs | Minimum number of left hand side (output) arguments required. |
min_nrhs | Minimum number of right hand side (input) arguments required. |
Definition at line 456 of file MexIFace.h.
Referenced by mexFunction().
|
inlinestatic |
Test doc here. And more here
Definition at line 332 of file MexIFace.h.
Referenced by checkedToMat().
|
inlineprotected |
Checks the mex function was called with an exact number of input and output arguments.
expected_nlhs | Expected number of left hand side (output) arguments required. |
expected_nrhs | Expected number of right hand side (input) arguments required. |
Definition at line 494 of file MexIFace.h.
|
inlineprotected |
Definition at line 442 of file MexIFace.h.
References nlhs.
|
inlinestatic |
Checks that two matlab mxArray objects have the same sized last dimension.
m1 | A pointer to the first mxArray to check |
m2 | A pointer to the second mxArray to check |
Throws an exception if the last dimensions do not match.
Definition at line 418 of file MexIFace.h.
|
inlinestatic |
Test doc here. And more here
Definition at line 354 of file MexIFace.h.
Referenced by checkedToScalar(), getAsScalarDict(), getCubeDict(), getHypercubeDict(), getMatDict(), getScalarDict(), and getVecDict().
|
static |
Test doc here. And more here
Definition at line 315 of file MexIFace.h.
Referenced by getAsScalarArray(), getAsScalarDict(), getCubeArray(), getCubeDict(), getHypercubeArray(), getHypercubeDict(), getMatArray(), getMatDict(), getScalarArray(), getScalarDict(), getString(), getStringArray(), getVecArray(), and getVecDict().
|
inlinestatic |
Test doc here. And more here
Definition at line 321 of file MexIFace.h.
References mexiface::get_mx_class_name().
|
inlinestatic |
Test doc here. And more here
Definition at line 366 of file MexIFace.h.
Referenced by checkedToVec(), getAsScalarArray(), getCubeArray(), getHypercubeArray(), getMatArray(), getScalarArray(), getString(), getStringArray(), and getVecArray().
|
inlinestatic |
Checks that a matlab mxArray object has the correct 2D dimensions.
m | A pointer to the mxArray to check |
expected_numel | the expected number of elements |
Definition at line 382 of file MexIFace.h.
|
protected |
Reports an error condition to Matlab using the mexErrMsgIdAndTxt function.
condition | String describing the error condition encountered. |
message | Informative message to accompany the error. |
Definition at line 27 of file MexIFace.cpp.
References mexiface::MexIFaceBase::obj_name().
Referenced by mexFunction().
|
protected |
Reports an error condition in a specified component to Matlab using the mexErrMsgIdAndTxt function.
component | String describing the component in which the error was encountered. |
condition | String describing the error condition encountered. |
message | Informative message to accompany the error. |
Definition at line 39 of file MexIFace.cpp.
References mexiface::MexIFaceBase::obj_name().
|
protected |
Definition at line 814 of file MexIFace.h.
References mexiface::get_mx_class_name(), rhs, and rhs_idx.
Referenced by getAsScalar().
|
protected |
Definition at line 875 of file MexIFace.h.
References mexiface::get_mx_class_name(), rhs, and rhs_idx.
|
protected |
Reads a mxArray as a scalar C++ int32_t type.
m | The pointer to the mxArray to interpret. |
The mxArray must be a signed 32 or 64 bit integer type.
Throws an error if the conversion cannot be made.
Definition at line 846 of file MexIFace.h.
References mexiface::get_mx_class_name(), rhs, and rhs_idx.
|
protected |
Definition at line 800 of file MexIFace.h.
References getAsBool().
|
protected |
Definition at line 898 of file MexIFace.h.
References checkType(), checkVectorSize(), rhs, and rhs_idx.
|
protected |
Definition at line 910 of file MexIFace.h.
References checkScalarSize(), checkType(), rhs, and rhs_idx.
|
protected |
Definition at line 869 of file MexIFace.h.
|
protected |
Create an armadillo Cube object to directly work with the Matlab data for a 3D array of arbitrary element type.
m | The pointer to the mxArray that is to be interpreted as an armadillo array. |
Definition at line 980 of file MexIFace.h.
|
protected |
Definition at line 1061 of file MexIFace.h.
References checkType(), checkVectorSize(), rhs, and rhs_idx.
|
protected |
Definition at line 1122 of file MexIFace.h.
References checkScalarSize(), checkType(), rhs, and rhs_idx.
|
protected |
Create an Hypercube object to directly work with the Matlab data for a 4D array of arbitrary element type.
Uses the ability of the armadillo arrays to interpret raw data passed to it as preallocated column major format. This allows us to open the array data in C++ using Matlab's memory directly instead of having to allocate a separate space and copy.
m | The pointer to the mxArray that is to be interpreted as an armadillo array. |
Definition at line 998 of file MexIFace.h.
|
protected |
Definition at line 1074 of file MexIFace.h.
References checkType(), checkVectorSize(), rhs, and rhs_idx.
|
protected |
Definition at line 1134 of file MexIFace.h.
References checkScalarSize(), checkType(), rhs, and rhs_idx.
|
protected |
Create an armadillo Mat object to directly work with the Matlab data for a 2D array of arbitrary element type.
m | The pointer to the mxArray that is to be interpreted as an armadillo array. |
Definition at line 967 of file MexIFace.h.
|
protected |
Definition at line 1049 of file MexIFace.h.
References checkType(), checkVectorSize(), rhs, and rhs_idx.
|
protected |
Definition at line 1110 of file MexIFace.h.
References checkScalarSize(), checkType(), rhs, and rhs_idx.
|
protected |
Definition at line 1005 of file MexIFace.h.
|
protectedpure virtualinherited |
Helper method which saves a pointer to the wrapped class's object in an internal member variable called obj.
This pure virtual function is implemented in the MexIFaceHandler class template.
mxhandle | scalar array where the handle is stored |
Implemented in mexiface::MexIFaceHandler< ObjT >.
Referenced by mexFunction().
|
protected |
Get exact type. No conversions.
Definition at line 940 of file MexIFace.h.
|
protected |
Definition at line 1012 of file MexIFace.h.
References checkType(), checkVectorSize(), rhs, and rhs_idx.
|
protected |
Definition at line 1086 of file MexIFace.h.
References checkScalarSize(), checkType(), rhs, and rhs_idx.
|
protected |
Reads a mxArray as a string.
m | Pointer to the mxArray to interpret. |
Throws an error if the conversion cannot be made.
Definition at line 59 of file MexIFace.cpp.
References checkType(), checkVectorSize(), rhs, and rhs_idx.
Referenced by getStringArray(), and mexFunction().
|
protected |
Definition at line 924 of file MexIFace.h.
References checkType(), checkVectorSize(), getString(), rhs, and rhs_idx.
|
protected |
Create a armadillo Column vector to directly use the Matlab data for a 1D array of arbitrary element type.
m | Pointer to the mxArray to be interpreted. (Default=nullptr). If nullptr then use next rhs param. |
Definition at line 953 of file MexIFace.h.
|
protected |
Definition at line 1037 of file MexIFace.h.
References checkType(), checkVectorSize(), rhs, and rhs_idx.
|
protected |
Definition at line 1098 of file MexIFace.h.
References checkScalarSize(), checkType(), rhs, and rhs_idx.
|
protected |
Definition at line 1149 of file MexIFace.h.
|
protected |
Definition at line 1157 of file MexIFace.h.
|
protected |
Definition at line 1165 of file MexIFace.h.
|
protected |
Definition at line 1174 of file MexIFace.h.
void mexiface::MexIFace::mexFunction | ( | MXArgCountT | _nlhs, |
mxArray * | _lhs[], | ||
MXArgCountT | _nrhs, | ||
const mxArray * | _rhs[] | ||
) |
The mexFunction that will be exposed as the entry point for the .mex file.
[in] | _nlhs | The number of left-hand-side (input) arguments passed from the Matlab side of the Iface. |
[in] | _lhs | The input arguments passed from the Matlab side of the Iface. |
[in] | _nrhs | The number of right-hand-side (output) arguments requested from the Matlab side of the Iface. |
[in,out] | _rhs | The output arguments requested from the Matlab side of the Iface to be filled in. |
This command is the main entry point for the .mex file, and allows the mexFunction to act like a class interface. Special @new, @delete, @static strings allow objects to be created and destroyed and static functions to be called otherwise the command is interpreted as a member function to be called on the given object handle which is expected to be the second argument.
Definition at line 85 of file MexIFace.cpp.
References checkMinNumArgs(), error(), mexiface::exploreMexArgs(), mexiface::MexIFaceBase::getObjectFromHandle(), getString(), methodmap, nrhs, mexiface::MexIFaceBase::obj_name(), mexiface::MexIFaceBase::objConstruct(), mexiface::MexIFaceBase::objDestroy(), rhs, and staticmethodmap.
|
protectedpure virtualinherited |
Get the name of the class of the stored object.
Implemented in mexiface::MexIFaceHandler< ObjT >.
Referenced by error(), and mexFunction().
|
protectedpure virtualinherited |
Called when the mexFunction gets the @new command, passing on the remaining input arguments.
The rhs should have a single output argument which is the handle (number) which corresponds to the wrapped object.
This pure virtual function must be overloaded by the concrete MexIFace subclass that can use the get<> methods to take in arbitrary parameters for whatever constrctor(s) exists for that wrapped class.
Referenced by mexFunction().
|
protectedpure virtualinherited |
Called when the mexFunction gets the @delete command.
This pure virtual function is implemented in the MexIFaceHandler class template.
mxhandle | scalar array where the handle is stored |
Implemented in mexiface::MexIFaceHandler< ObjT >.
Referenced by mexFunction().
|
inlinefinaloverrideprotectedvirtual |
Append a generic mxArray to the output arguments This is virtual because MexIFaceHandler need to use it to output a Handle pointer.
m | Array to append to output arguments. |
Implements mexiface::MexIFaceBase.
Definition at line 1186 of file MexIFace.h.
Referenced by output().
|
protected |
Definition at line 1192 of file MexIFace.h.
References lhs, lhs_idx, nlhs, nrhs, output(), rhs, rhs_idx, and toMXArray().
|
static |
Definition at line 535 of file MexIFace.h.
|
static |
Definition at line 546 of file MexIFace.h.
|
static |
Definition at line 529 of file MexIFace.h.
|
inlinestatic |
Definition at line 673 of file MexIFace.h.
Referenced by output(), and toMXArray().
|
inlinestatic |
Definition at line 681 of file MexIFace.h.
|
inlinestatic |
Definition at line 687 of file MexIFace.h.
|
static |
Definition at line 694 of file MexIFace.h.
|
static |
Definition at line 702 of file MexIFace.h.
|
static |
Definition at line 711 of file MexIFace.h.
|
static |
Definition at line 720 of file MexIFace.h.
|
static |
Definition at line 730 of file MexIFace.h.
|
static |
Definition at line 740 of file MexIFace.h.
|
static |
Definition at line 762 of file MexIFace.h.
|
static |
Definition at line 772 of file MexIFace.h.
References toMXArray().
|
static |
Definition at line 786 of file MexIFace.h.
References toMXArray().
|
static |
Definition at line 510 of file MexIFace.h.
|
static |
Definition at line 523 of file MexIFace.h.
|
protected |
Left-hand-side (output) argument array. Size=nlhs.
Definition at line 183 of file MexIFace.h.
Referenced by makeOutputArray(), and output().
|
protected |
Index of the next left-hand-side argument to write as output.
Definition at line 184 of file MexIFace.h.
Referenced by makeOutputArray(), and output().
|
protected |
Maps names (std::string) to member functions (std::function<void()>)
Definition at line 179 of file MexIFace.h.
Referenced by mexFunction().
|
protected |
Number of left-hand-side (output) arguments passed to MexIFace::mexFunction.
Definition at line 182 of file MexIFace.h.
Referenced by checkMaxNumArgs(), checkMinNumArgs(), checkNumArgs(), checkOutputArgRange(), and output().
|
protected |
Number of right-hand-side (input) arguments passed to MexIFace::mexFunction.
Definition at line 185 of file MexIFace.h.
Referenced by checkInputArgRange(), checkMaxNumArgs(), checkMinNumArgs(), checkNumArgs(), mexFunction(), and output().
|
protected |
Right-hand-side (input) argument array. Size=nrhs.
Definition at line 186 of file MexIFace.h.
Referenced by getAsBool(), getAsFloat(), getAsInt(), getAsScalarArray(), getAsScalarDict(), getCube(), getCubeArray(), getCubeDict(), getHypercube(), getHypercubeArray(), getHypercubeDict(), getMat(), getMatArray(), getMatDict(), getScalar(), getScalarArray(), getScalarDict(), getString(), getStringArray(), getVec(), getVecArray(), getVecDict(), mexFunction(), and output().
|
protected |
Index of the next right-hand-side argument to read as input.
Definition at line 187 of file MexIFace.h.
Referenced by getAsBool(), getAsFloat(), getAsInt(), getAsScalarArray(), getAsScalarDict(), getCube(), getCubeArray(), getCubeDict(), getHypercube(), getHypercubeArray(), getHypercubeDict(), getMat(), getMatArray(), getMatDict(), getScalar(), getScalarArray(), getScalarDict(), getString(), getStringArray(), getVec(), getVecArray(), getVecDict(), and output().
|
protected |
Maps names (std::string) to static member functions (std::function<void()>)
Definition at line 180 of file MexIFace.h.
Referenced by mexFunction().