#include <MexParams.h>
Public Member Functions | |
MexParams (const int minOutput, const int maxOutput, const int numOutput, mxArray *plhs[], const int minInput, const int maxInput, const int numInput, const mxArray *prhs[]) | |
Constructor. | |
~MexParams () | |
Destructor. | |
void | setOutput (const int number, mxArray *out) |
Sets an output variable to a mxArray. | |
void | setScalarOutput (const int number, const double val) |
Sets an output variable to a scalar value. | |
mxArray * | getOutput (const int number) |
Returns one of the assigned output variables. | |
double | getScalarOutput (const int number) |
Returns one of the assigned output variables as a scalar. | |
const mxArray * | getInput (const int number) const |
Returns one of the input variables. | |
const double | getScalarInput (const int number) const |
Returns one of the input variables as a scalar. | |
int | getNumberOutput () const |
Returns the number of outputs. | |
int | getNumberInput () const |
Returns the number of inputs. | |
Protected Attributes | |
const int | itsNumOutput |
mxArray ** | itsOutput |
const int | itsNumInput |
const mxArray ** | itsInput |
Private Member Functions | |
MexParams (const MexParams &) |
This class keeps track of the input and output parameters. It offers routines for accessing input and output variables as mxArray or as double scalars.
Definition at line 22 of file MexParams.h.
MexParams::MexParams | ( | const int | minOutput, | |
const int | maxOutput, | |||
const int | numOutput, | |||
mxArray * | plhs[], | |||
const int | minInput, | |||
const int | maxInput, | |||
const int | numInput, | |||
const mxArray * | prhs[] | |||
) |
Constructor.
minOutput | the minimum number of outputs that need to be provided | |
maxOutput | the maximum number of outputs | |
numOutput | the actual number of outputs: the same as nlhs in mexFunction. The constructor checks is numOutput is between minOutput and maxOutput. | |
plhs | the mxArray field for the output variables | |
minInput | the minimum number of inputs | |
maxInput | the maximum number of inputs | |
numInput | the actual number of inputs: the same as nrhs in mexFunction. The constructor checks is numInput is between minInput and maxInput. | |
prhs | the mxArray field for the input variables |
Definition at line 14 of file MexParams.cpp.
References ASSERT, and K_RightInDd.
MexParams::~MexParams | ( | ) |
Destructor.
Checks if all requested output variables have been assigned.
Definition at line 31 of file MexParams.cpp.
References itsNumOutput, itsOutput, mexError(), and mexFatal().
MexParams::MexParams | ( | const MexParams & | ) | [private] |
void MexParams::setOutput | ( | const int | number, | |
mxArray * | out | |||
) |
Sets an output variable to a mxArray.
number | the index of the output, starting from 0. If number is greater than the number of outputs, the function does nothing. | |
out | the value to set the output to. |
Definition at line 46 of file MexParams.cpp.
References ASSERT, itsNumOutput, and itsOutput.
Referenced by mexFunction(), and setScalarOutput().
void MexParams::setScalarOutput | ( | const int | number, | |
const double | val | |||
) |
Sets an output variable to a scalar value.
number | the index of the output, starting from 0. If number is greater than the number of outputs, the function does nothing. | |
val | a scalar value to set the output paramter to. |
Definition at line 53 of file MexParams.cpp.
References setOutput().
Referenced by mexFunction().
mxArray * MexParams::getOutput | ( | const int | number | ) |
Returns one of the assigned output variables.
number | the index of the output, starting from 0. |
Definition at line 59 of file MexParams.cpp.
References ASSERT, itsNumOutput, and itsOutput.
Referenced by getScalarOutput().
double MexParams::getScalarOutput | ( | const int | number | ) |
Returns one of the assigned output variables as a scalar.
number | the index of the output, starting from 0. |
Definition at line 67 of file MexParams.cpp.
References getOutput().
const mxArray * MexParams::getInput | ( | const int | number | ) | const |
Returns one of the input variables.
number | the index of the inputs, starting from 0. |
Definition at line 73 of file MexParams.cpp.
References ASSERT, itsInput, and itsNumInput.
Referenced by getScalarInput(), and mexFunction().
const double MexParams::getScalarInput | ( | const int | number | ) | const |
Returns one of the input variables as a scalar.
number | the index of the inputs, starting from 0. |
Definition at line 81 of file MexParams.cpp.
References getInput().
Referenced by mexFunction().
int MexParams::getNumberOutput | ( | ) | const |
Returns the number of outputs.
Definition at line 87 of file MexParams.cpp.
References itsNumOutput.
int MexParams::getNumberInput | ( | ) | const |
const int MexParams::itsNumOutput [protected] |
Definition at line 87 of file MexParams.h.
Referenced by getNumberOutput(), getOutput(), setOutput(), and ~MexParams().
mxArray** MexParams::itsOutput [protected] |
Definition at line 88 of file MexParams.h.
Referenced by getOutput(), setOutput(), and ~MexParams().
const int MexParams::itsNumInput [protected] |
const mxArray** MexParams::itsInput [protected] |