source: branches/uq/lang/matlab/rpUnitsFind.cc @ 6036

Last change on this file since 6036 was 5679, checked in by ldelgass, 9 years ago

Full merge 1.3 branch to uq branch to sync. Fixed partial subdirectory merge
by removing mergeinfo from lang/python/Rappture directory.

  • Property svn:eol-style set to native
File size: 2.1 KB
RevLine 
[97]1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
[154]5 *    [unitsHandle,err] = rpUnitsFind(unitSymbol)
[97]6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
[3177]9 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
[115]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
[154]18/**********************************************************************/
19// METHOD: [unitHandle,err] = rpUnitsFind(unitSymbol)
20/// Search the dictionary of Rappture Units for an instance named 'unitSymbol'
21/**
22 * This method searches the Rappture Units Dictionary for the
23 * RpUnit named 'unitSymbol'. If it is found, its handle is`
24 * returned, as a non-negative integer, to the caller for further use,
25 * else a negative integer is returned signifying no unit of that`
26 * name was found.
27 * If unitSymbol is an empty string, unitHandle will be set to zero and err
28 * will be set to a positive value.
29 * Error code, err=0 on success, anything else is failure.
30 */
31
[97]32void mexFunction(int nlhs, mxArray *plhs[],
33                 int nrhs, const mxArray *prhs[])
34{
35    char *unitSymbol = NULL;
[141]36    const RpUnits* myUnit = NULL;
[97]37    int retHandle = 0;
[154]38    int err = 1;
[97]39
40    /* Check for proper number of arguments. */
41    if (nrhs != 1)
42        mexErrMsgTxt("Two input required.");
[154]43    else if (nlhs > 2)
[97]44        mexErrMsgTxt("Too many output arguments.");
45
46    unitSymbol = getStringInput(prhs[0]);
47
48    /* Call the C subroutine. */
49    if (unitSymbol) {
50        myUnit = RpUnits::find(unitSymbol);
51
52        if (myUnit) {
53            retHandle = storeObject_UnitsStr(myUnit->getUnitsName());
[154]54            if (retHandle) {
55                err = 0;
56            }
[97]57        }
58    }
59
60    /* Set C-style string output_buf to MATLAB mexFunction output*/
61    plhs[0] = mxCreateDoubleScalar(retHandle);
[154]62    plhs[1] = mxCreateDoubleScalar(err);
[97]63
64    return;
65}
Note: See TracBrowser for help on using the repository browser.