source: trunk/lang/matlab/rpUnitsGetBasis.cc @ 1025

Last change on this file since 1025 was 165, checked in by dkearney, 18 years ago

1) removing matlab and octave tests for put*id functions
2) adding old fortran examples
3) minor changes to matlab and octave to fix rpUnitsGetBasis
4) rpUnitsMakeMetric does not work in matlab
5) changes to fortran bindings to return proper error codes.
6) added debugging to matlab compiling options and changed outdir location in Makefile

File size: 2.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [unitsHandle,err] = rpUnitsGetBasis(unitsHandle)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
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.
13 * ======================================================================
14 */
15
16#include "RpMatlabInterface.h"
17
18/**********************************************************************/
19// METHOD: [basisHandle,err] = rpUnitsGetBasis(unitHandle)
20/// Return a handle to the basis of the provided instance of a Rappture Unit.
21/**
22 * Retrieve the basis of the Rappture Units object with the handle`
23 * 'unitHandle'. Return the handle of the basis if it exists. If there`
24 * is no basis, then return a negative integer.
25 * Error code, err=0 on success, anything else is failure.
26 */
27
28void mexFunction(int nlhs, mxArray *plhs[],
29                 int nrhs, const mxArray *prhs[])
30{
31    char *unitSymbol = NULL;
32    const RpUnits* myBasis = NULL;
33    const RpUnits* myUnit = NULL;
34    int retHandle = 0;
35    int unitsHandle = 0;
36    int err = 1;
37
38    /* Check for proper number of arguments. */
39    if (nrhs != 1)
40        mexErrMsgTxt("Two input required.");
41    else if (nlhs > 2)
42        mexErrMsgTxt("Too many output arguments.");
43
44    unitsHandle = getIntInput(prhs[0]);
45
46    /* Call the C subroutine. */
47    if (unitsHandle > 0) {
48        myUnit = getObject_UnitsStr(unitsHandle);
49
50        if (myUnit) {
51
52            myBasis = myUnit->getBasis();
53            if (myBasis) {
54                // there was a basis, store it an return
55                retHandle = storeObject_UnitsStr(myBasis->getUnitsName());
56                if (retHandle) {
57                    err = 0;
58                }
59            }
60            else {
61                // there was no basis for this unit
62                // return negative handle and set err = 0
63                retHandle = -1;
64                err = 0;
65            }
66        }
67    }
68
69    /* Set C-style string output_buf to MATLAB mexFunction output*/
70    plhs[0] = mxCreateDoubleScalar(retHandle);
71    plhs[1] = mxCreateDoubleScalar(err);
72    return;
73}
Note: See TracBrowser for help on using the repository browser.