source: trunk/lang/matlab/rpUnitsMakeMetric.cc @ 3177

Last change on this file since 3177 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 2.0 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [error] = rpUnitsMakeMetric(basisHandle)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
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: [err] = rpUnitsMakeMetric(basisHandle)
20/// Create metric extensions for the Rappture Unit referenced by basisHandle
21/**
22 * Create the metric extensions for the Rappture Unit, referenced`
23 * by basisHandle, within Rappture's internal units dictionary.
24 * Return an error code, err, to specify success or failure.
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    const RpUnits* basis       = NULL;
32    int            retVal      = 0;
33    int            basisHandle = 0;
34    int            retIndex    = 0;
35
36    /* Check for proper number of arguments. */
37    if (nrhs != 1)
38        mexErrMsgTxt("Two input required.");
39    else if (nlhs > 1)
40        mexErrMsgTxt("Too many output arguments.");
41
42    basisHandle = getIntInput(prhs[0]);
43
44    /* Call the C subroutine. */
45    if (basisHandle > 0) {
46        basis = getObject_UnitsStr(basisHandle);
47
48        if (basis) {
49             retVal = RpUnits::makeMetric(basis);
50        }
51        else {
52            std::string errMsg = "Error while retrieving basis handle.\n";
53            errMsg += "Possibly invalid handle?\n";
54            mexErrMsgTxt(errMsg.c_str());
55        }
56    }
57
58    /* Set C-style string output_buf to MATLAB mexFunction output*/
59    plhs[0] = mxCreateDoubleScalar(retVal);
60
61    return;
62}
Note: See TracBrowser for help on using the repository browser.