source: trunk/src/matlab/rpConvertObjStr.cc @ 122

Last change on this file since 122 was 115, checked in by mmc, 19 years ago

Updated all copyright notices.

File size: 1.8 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    (retStr,result) =
6 *          rpConvertObjStr(fromObjHandle, toObjHandle, value, showUnits)
7 *
8 * ======================================================================
9 *  AUTHOR:  Derrick Kearney, Purdue University
10 *  Copyright (c) 2004-2005  Purdue Research Foundation
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16
17#include "RpMatlabInterface.h"
18
19void mexFunction(int nlhs, mxArray *plhs[],
20                 int nrhs, const mxArray *prhs[])
21{
22    int         result        = 0;
23    std::string retStr        = "";
24    int         fromObjHandle = 0;
25    int         toObjHandle   = 0;
26    RpUnits*    fromObj       = NULL;
27    RpUnits*    toObj         = NULL;
28    double      value         = 0;
29    int         showUnits     = 0;
30
31    /* Check for proper number of arguments. */
32    if (nrhs != 4)
33        mexErrMsgTxt("Two input required.");
34    else if (nlhs > 2)
35        mexErrMsgTxt("Too many output arguments.");
36
37    fromObjHandle = getIntInput(prhs[0]);
38    toObjHandle   = getIntInput(prhs[1]);
39    value         = getDoubleInput(prhs[2]);
40    showUnits     = getIntInput(prhs[3]);
41
42    // grab the RpUnits objects from the dictionary
43    fromObj       = getObject_UnitsStr(fromObjHandle);
44    toObj         = getObject_UnitsStr(toObjHandle);
45
46    /* Call the C subroutine. */
47    if (fromObj && toObj) {
48        retStr = fromObj->convert(toObj,value,showUnits,&result);
49    }
50
51    /* Set C-style string output_buf to MATLAB mexFunction output*/
52    plhs[0] = mxCreateString(retStr.c_str());
53    plhs[1] = mxCreateDoubleScalar((double)result);
54
55    return;
56}
Note: See TracBrowser for help on using the repository browser.