Methods for OML Toolboxes
This section describes the methods exposed in OML to interface new toolboxes.
OMLInterface Class Methods
RegisterFunction(const char* function_name, FUNCPTR function_pointer)
typedef bool (*FUNCPTR) (OMLInterface*, const OMLCurrencyList* inputs, OMLCurrencyList* outputs);
This method is called once for each function that the toolbox needs to register with OML. If a function with the given name already exists, it will be replaced by this function call.
ThrowError(const char* message)
Call this method when an unrecoverable error occurs. Execution of the script will be halted and the message will be reported to the user.
int Nargout() const
Returns the number of outputs expected from this function for the given call. This value is dependent on how the function is called, not on anything in the function itself.
OMLCurrencyList Class Const Methods
These are the only methods that can be called on the inputs list.
int Size() const
Returns the number of OMLCurrency objects in the list. It may be 0.
const OMLCurrency* Get(int idx) const
Returns a pointer to the specified OMLCurrency. The index is 0-based. If the index is out of range, a NULL pointer is returned.
OMLCurrencyList Class Non-const Methods
void AddScalar(double);
Appends the specified double value to the list.
void AddString(const char* string)
Appends the specified (NULL terminated) string to the list.
void AddCellArray(OMLCellArray*)
Appends the specified cellarray object to the list.
void AddStruct(OMLStruct*)
Appends the specified struct object to the list.
void AddMatrix(OMLMatrix* matrix)
Appends the specified 2-dimensional matrix to the list.
void AddNDMatrix(OMLNDMatrix* nd_matrix)
Appends the specified N-dimensional matrix to the list.
void AddComplex(OMLComplex* complex)
Appends the specified complex value to the list.
OMLCellArray* CreateCellArray(int rows, int cols)
Creates an empty OMLCellArray object with the specified dimensions and returns a pointer to it. You need to fill in the contents of this object.
OMLStruct* CreateStruct(int rows, int cols)
Creates an empty OMLStruct object with the specified dimensions and returns a pointer to it. You need to fill in the contents of this object and then add it to the outputs if desired.
OMLMatrix* CreateMatrix(int rows, int cols, double* data)
Creates an OMLMatrix object with the specified dimensions using the real data supplied and returns a pointer to it. The data is assumed to be column-major.
OMLMatrix* CreateMatrix(int rows, int cols, double* real, double* imag)
Creates an OMLMatrix object with the specified dimensions using the complex data supplied and returns a pointer to it. The data is assumed to be column-major.
OMLNDMatrix* CreateNDMatrix(int num_dims, int* dims, double* real)
Creates an OMLNDMatrix object with the specified dimensions using the real data supplied and returns a pointer to it. The data is assumed to be stored FORTRAN-style.
OMLNDMatrix* CreateNDMatrix(int num_dims, int* dims, double* real, double* imag)
Creates an OMLNDMatrix object with the specified dimensions using the complex data supplied and returns a pointer to it. The data is assumed to be stored FORTRAN-style.
OMLComplex* CreateComplex(double real, double imag)
Creates an OMLComplex object using data supplied and returns a pointer to it.
OMLCurrency* CreateCurrencyFromDouble(double dbl)
Creates an OMLCurrency object using data supplied and returns a pointer to it. This is useful when inserting a double value into an OMLCellArray or OMLStruct.
OMLCurrency* CreateCurrencyFromString(const char* str)
Creates an OMLCurrency object using data supplied and returns a pointer to it. This is useful when inserting a string value into an OMLCellArray or OMLStruct.
OMLCurrency Class Methods (all are const)
bool IsScalar()
Returns true if this OMLCurrency is a scalar.
bool IsComplex()
Returns true if this OMLCurrency is a single complex value.
bool IsString()
Returns true if this OMLCurrency is a string. The string may span multiple lines.
bool IsMatrix()
Returns true if this OMLCurrency is a two-dimensional matrix or a one-dimensional vector.
bool IsNDMatrix()
Returns true if this OMLCurrency is a multi-dimensional matrix.
bool IsCellArray()
Returns true if this OMLCurrency is a cell array. It may be a single cell.
bool IsStruct()
Returns true if this OMLCurrency is a struct array. It may be a single struct.
double GetScalar()
Returns the underlying double value for this OMLCurrency.
const char* GetString()
Returns a pointer to the underlying character string for this OMLCurrency.
const OMLCellArray* GetCellArray()
Returns a pointer to the underlying OMLCellArray for this OMLCurrency.
const OMLMatrix* GetMatrix()
Returns a pointer to the underlying OMLMatrix for this OMLCurrency.
const OMLNDMatrix* GetNDMatrix()
Returns a pointer to the underlying OMLNDMatrix for this OMLCurrency.
const OMLComplex* GetComplex()
Returns a pointer to the underlying OMLComplex for this OMLCurrency.
const OMLStruct* GetStruct()
Returns a pointer to the underlying OMLStruct for this OMLCurrency.
Note that calling an improper Get method will not generate an error, but it will return unsafe data that could result in a crash later.
OMLComplex Class Methods (all are const)
double GetReal()
Returns the real value of the OMLComplex.
double GetImag()
Returns the imaginary value of the OMLComplex.
OMLCurrency* GetCurrency()
Returns a pointer to an OMLCurrency that contains the given OMLComplex. This is useful to insert an OMLComplex into an OMLCellArray or OMLStruct.
OMLMatrix Class Methods (all are const)
bool IsReal()
Returns true if the OMLMatrix contains only real data.
int GetRows()
Returns the number of rows in the OMLMatrix.
int GetCols()
Returns the number of columns in the OMLMatrix.
const double* GetRealData()
Returns a const pointer to the underlying real data of the OMLMatrix. The data is stored column-major. This can be used for both real and complex matrices.
const double* GetImaginaryData()
Returns a const pointer to the underlying imaginary data of the OMLMatrix. The data is stored column-major. This method will return NULL for a real OMLMatrix.
OMLCurrency* GetCurrency()
Returns a pointer to an OMLCurrency that contains the given OMLMatrix. This is useful to insert an OMLMatrix into an OMLCellArray or OMLStruct.
.OMLNDMatrix Class Methods
bool IsReal()
Returns true if the OMLNDMatrix contains only real data.
int GetNumDimensions()
Returns the number of dimensions in the OMLNDMatrix.
int GetDimension(int index)
Returns the requested dimension of the OMLNDMatrix. Index is 0-based.
const double* GetRealData()
Returns a const pointer to the underlying real data of the OMLNDMatrix. The data is stored using FORTRAN storage. This can be used for both real and complex matrices (But currently it will not work properly for complex matrices.)
const double* GetImaginaryData()
(This method is not yet implemented and will always return NULL.) Returns a const pointer to the underlying imaginary data of the OMLNDMatrix. The data is stored using FORTRAN storage. This method should not be called on a real OMLNDMatrix.
OMLCurrency* GetCurrency()
Returns a pointer to an OMLCurrency that contains the given OMLNDMatrix. This is useful to insert an OMLNDMatrix into an OMLCellArray or OMLStruct.
OMLCellArray Class Const Methods
OMLCurrency* GetValue(int index)
Returns a pointer to the OMLCurrency contained within the OMLCellArray at the specified index. The index is 0-based.
OMLCurrency* GetValue(int index1, int index2)
Returns a pointer to the OMLCurrency contained within the OMLCellArray at the specified indices. The indices are 0-based.
int GetRows()
Returns the number of rows in the OMLCellArray.
int GetCols()
Returns the number of columns in the OMLCellArray.
OMLCurrency* GetCurrency()
Returns a pointer to an OMLCurrency that contains the given OMLCellArray. This is useful to insert an OMLCellArray into an OMLCellArray or OMLStruct. OMLCellArrays can contain other OMLCellArrays.
void SetValue(int index, OMLCurrency* val)
Sets the cell value at the specified index to val. The index is 0-based.
void SetValue(int index1, int index2, OMLCurrency* val)
Sets the cell value at the specified indices to val. The indices are 0-based.
OMLStruct Class Const Methods
OMLCurrency* GetValue(int index1, const char* field)
Returns a pointer to the OMLCurrency contained within the specified field of the OMLStruct at the specified index. The index is 0-based.
OMLCurrency* GetValue(int index1, int index2, const char* field)
Returns a pointer to the OMLCurrency contained within the specified field of the OMLStruct at the specified indices. The indices are 0-based.
int GetRows()
Returns the number of rows in the OMLStruct.
int GetCols()
Returns the number of columns in the OMLStruct.
OMLCurrency* GetCurrency()
Returns a pointer to an OMLCurrency that contains the given OMLStruct. This is useful to insert an OMLStruct into an OMLCellArray or OMLStruct. OMLStructs can contain other OMLStructs.
void SetValue(int index, const char* field, OMLCurrency* val)
Sets the value of the field at the specified index to val. The index is 0-based.
void SetValue(int index1, int index2, const char* field, OMLCurrency* val)
Sets the value of the field at the specified indices to val. The indices are 0-based.