source: trunk/src/matlab/rpUnitsDefineUnit.cc @ 141

Last change on this file since 141 was 141, checked in by dkearney, 17 years ago

added const to RpUnits*'s. these now compile correctly with matlab's mex compiler

File size: 1.5 KB
RevLine 
[97]1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
[135]5 *    [unitsHandle] = rpUnitsDefineUnit(unitSymbol, basisHandle)
[97]6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
[115]9 *  Copyright (c) 2004-2005  Purdue Research Foundation
10 *
11 *  See the file "license.terms" for information on usage and
12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
[97]13 * ======================================================================
14 */
15
16#include "RpMatlabInterface.h"
17
18void mexFunction(int nlhs, mxArray *plhs[],
19                 int nrhs, const mxArray *prhs[])
20{
21    char *unitSymbol = NULL;
[141]22    const RpUnits* basis = NULL;
[97]23    RpUnits* myUnit = NULL;
24    int retHandle = 0;
25    int basisHandle = 0;
26    int retIndex = 0;
27
28    /* Check for proper number of arguments. */
29    if (nrhs != 2)
30        mexErrMsgTxt("Two input required.");
31    else if (nlhs > 1)
32        mexErrMsgTxt("Too many output arguments.");
33
34    unitSymbol = getStringInput(prhs[0]);
35    basisHandle = getIntInput(prhs[1]);
36
37    /* Call the C subroutine. */
38    if (basisHandle > 0) {
39        basis = getObject_UnitsStr(basisHandle);
40    }
41
42    if (unitSymbol) {
43        myUnit = RpUnits::define(unitSymbol,basis);
44
45        if (myUnit) {
46            retHandle = storeObject_UnitsStr(myUnit->getUnitsName());
47        }
48    }
49
50    /* Set C-style string output_buf to MATLAB mexFunction output*/
51    plhs[0] = mxCreateDoubleScalar(retHandle);
52
53    return;
54}
Note: See TracBrowser for help on using the repository browser.