1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Matlab Rappture Library Source |
---|
4 | * |
---|
5 | * [retStr,err] = rpUnitsGetUnitsName(unitsHandle) |
---|
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: [retStr,err] = rpUnitsGetUnitsName(unitHandle) |
---|
20 | /// Return the unit and exponent of the Rappture Unit represented by unitHandle. |
---|
21 | /** |
---|
22 | * Retrieve the unit and exponent of the Rappture Units object with` |
---|
23 | * the handle 'unitHandle'. |
---|
24 | * Return the unit and exponent as one concatinated string. |
---|
25 | * Error code, err=0 on success, anything else is failure. |
---|
26 | */ |
---|
27 | |
---|
28 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
29 | int nrhs, const mxArray *prhs[]) |
---|
30 | { |
---|
31 | int unitsHandle = 0; |
---|
32 | int err = 1; |
---|
33 | const RpUnits* unitsObj = NULL; |
---|
34 | const char* retString = NULL; |
---|
35 | |
---|
36 | /* Check for proper number of arguments. */ |
---|
37 | if (nrhs != 1) |
---|
38 | mexErrMsgTxt("Two input required."); |
---|
39 | else if (nlhs > 2) |
---|
40 | mexErrMsgTxt("Too many output arguments."); |
---|
41 | |
---|
42 | unitsHandle = getIntInput(prhs[0]); |
---|
43 | |
---|
44 | /* Call the C subroutine. */ |
---|
45 | if (unitsHandle > 0) { |
---|
46 | unitsObj = getObject_UnitsStr(unitsHandle); |
---|
47 | if (unitsObj) { |
---|
48 | retString = unitsObj->getUnitsName().c_str(); |
---|
49 | if (retString) { |
---|
50 | err = 0; |
---|
51 | } |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | /* Set C-style string output_buf to MATLAB mexFunction output*/ |
---|
56 | plhs[0] = mxCreateString(retString); |
---|
57 | plhs[1] = mxCreateDoubleScalar(err); |
---|
58 | |
---|
59 | return; |
---|
60 | } |
---|