3 #ifndef GCP_MATLAB_MEXHANDLER_H
4 #define GCP_MATLAB_MEXHANDLER_H
18 #include "gcp/util/common/Debug.h"
19 #include "gcp/util/common/DataType.h"
20 #include "gcp/util/common/ErrHandler.h"
21 #include "gcp/util/common/Logger.h"
22 #include "gcp/util/common/MonitorDataType.h"
23 #include "gcp/util/common/RegDescription.h"
24 #include "gcp/util/common/RegParser.h"
26 #include "gcp/matlab/common/MexParser.h"
33 #define MXPRINT(statement) \
35 std::ostringstream os;\
37 os << statement << std::endl;\
38 mexPrintf(os.str().c_str());\
41 #define MXPRINTN(statement) \
43 std::ostringstream os;\
46 mexPrintf(os.str().c_str());\
77 void operator=(mxArray* array) {
79 vPtr_ = mxGetData(array);
93 static mxArray*
createMatlabArray(
int ndim,
const int* dims, gcp::util::DataType::Type dataType);
94 static mxArray*
createMatlabArray(
int length, gcp::util::DataType::Type dataType);
97 gcp::util::MonitorDataType::FormatType formatType);
101 static double* createDoubleArray(mxArray** mxArray,
int ndim,
const int* dims);
102 static double* createDoubleArray(mxArray** mxArray,
unsigned len);
103 static float* createFloatArray(mxArray** mxArray,
int ndim,
const int* dims);
104 static double* createDoubleArray(mxArray** mxArray,
MexParser& parser);
106 static mxClassID matlabTypeOf(gcp::util::DataType::Type dataType);
108 static mxClassID matlabTypeOf(gcp::util::MonitorDataType::FormatType formatType);
112 static mxComplexity
matlabComplexityOf(gcp::util::MonitorDataType::FormatType formatType);
116 static mxArray*
addRegisterField(mxArray* ptr, std::string regName,
unsigned nElements);
123 gcp::util::MonitorDataType::FormatType formatType,
127 std::string fieldName,
128 gcp::util::DataType::Type=gcp::util::DataType::NONE,
132 static mxArray*
addNamedStructField(mxArray* parentPtr, std::string fieldName,
unsigned nElement=1,
unsigned index=0);
133 static mxArray*
addNamedCellField(mxArray* parentPtr, std::string fieldName,
unsigned iDim,
unsigned index=0);
136 unsigned len,
unsigned index=0);
139 std::string str,
unsigned index=0);
141 static mxArray*
addNamedStructField(mxArray* parentPtr, std::string fieldName,
int ndim,
const int* dims, gcp::util::DataType::Type dataType,
unsigned index=0);
144 std::string fieldName,
145 unsigned nElement,
unsigned index=0);
148 std::string fieldName,
149 std::vector<int> dims,
unsigned index=0);
152 std::vector<int> dims,
unsigned index=0);
155 std::string fieldName,
156 unsigned nElement,
unsigned index=0);
159 std::string fieldName,
160 unsigned nElement,
unsigned index=0);
173 static void checkArgs(
int nlhsExpected,
int nrhsExpected,
174 int nlhsActual,
int nrhsActual);
176 static LOG_HANDLER_FN(stdoutPrintFn);
177 static LOG_HANDLER_FN(stderrPrintFn);
179 static ERR_HANDLER_FN(throwFn);
180 static ERR_HANDLER_FN(reportFn);
181 static ERR_HANDLER_FN(logFn);
187 std::vector<unsigned>& dims);
190 std::vector<unsigned>& dims);
196 static void getIndicesC(std::vector<unsigned>& cVec,
197 std::vector<unsigned>& cDims);
200 static unsigned getMatlabIndex(
unsigned n1,
unsigned n2,
201 unsigned i1,
unsigned i2);
203 static unsigned getMatlabIndex(
unsigned n1,
unsigned n2,
unsigned n3,
204 unsigned i1,
unsigned i2,
unsigned i3);
211 std::vector<unsigned>& mDims);
214 std::vector<int>& mDims);
221 static void getIndices(std::vector<unsigned>& cVec, std::vector<unsigned>& mVec,
222 std::vector<unsigned>& dims,
223 int iDim=0,
unsigned indLast=0,
224 unsigned nLast=0,
unsigned baseLast=0);
228 static std::vector<mwSize> convertDims(
int ndim,
const int* dims);
237 #endif // End #ifndef GCP_MATLAB_MEXHANDLER_H
static double * addNamedDoubleStructField(mxArray *parentPtr, std::string fieldName, unsigned nElement, unsigned index=0)
Definition: MexHandler.cc:473
static mxComplexity matlabComplexityOf(gcp::util::DataType::Type dataType)
Definition: MexHandler.cc:94
static mxArray * addNamedStructField(mxArray *parentPtr, std::string fieldName, unsigned nElement=1, unsigned index=0)
Definition: MexHandler.cc:383
Definition: MonitorDataType.h:16
static char * addNamedStringStructField(mxArray *parentPtr, std::string fieldName, unsigned len, unsigned index=0)
Definition: MexHandler.cc:414
static mxArray * addRegisterField(mxArray *ptr, gcp::util::RegDescription ®)
Definition: MexHandler.cc:215
static unsigned * addNamedUintStructField(mxArray *parentPtr, std::string fieldName, unsigned nElement, unsigned index=0)
Definition: MexHandler.cc:454
static mxArray * addNamedCellField(mxArray *parentPtr, std::string fieldName, unsigned iDim, unsigned index=0)
Definition: MexHandler.cc:537
static void getIndicesMatlab(std::vector< unsigned > &mVec, std::vector< unsigned > &mDims)
Definition: MexHandler.cc:691
Definition: MexHandler.h:60
static void getIndices(std::vector< unsigned > &cVec, std::vector< unsigned > &mVec, std::vector< unsigned > &dims, int iDim=0, unsigned indLast=0, unsigned nLast=0, unsigned baseLast=0)
Definition: MexHandler.cc:733
static float * addNamedFloatStructField(mxArray *parentPtr, std::string fieldName, std::vector< int > dims, unsigned index=0)
Definition: MexHandler.cc:525
virtual ~MexHandler()
Definition: MexHandler.cc:22
static unsigned indexStartingWithSlowest(std::vector< unsigned > &coord, std::vector< unsigned > &dims)
Definition: MexHandler.cc:653
Definition: MexParser.h:19
static mxArray * addHierNamedStructField(mxArray *parentPtr, std::string fieldName, gcp::util::DataType::Type=gcp::util::DataType::NONE, unsigned nDim=0, int *dims=0)
Definition: MexHandler.cc:301
static mxArray * createRegValArray(mxArray *ptr, gcp::util::RegDescription ®, gcp::util::MonitorDataType::FormatType formatType, unsigned nFrame)
Definition: MexHandler.cc:266
static mxArray * createMatlabArray(int ndim, const int *dims, gcp::util::DataType::Type dataType)
Definition: MexHandler.cc:27
static unsigned indexStartingWithFastest(std::vector< unsigned > &coord, std::vector< unsigned > &dims)
Definition: MexHandler.cc:666
Definition: MexHandler.h:54
static double * copyNamedDoubleStructField(mxArray *parentPtr, std::string fieldName, std::string copyName)
Definition: MexHandler.cc:636
MexHandler()
Definition: MexHandler.cc:17
Definition: RegDescription.h:26
static void checkArgs(int nlhsExpected, int nrhsExpected, int nlhsActual, int nrhsActual)
Definition: MexHandler.cc:568
static void getIndicesC(std::vector< unsigned > &cVec, std::vector< unsigned > &cDims)
Definition: MexHandler.cc:680