source: trunk/src/matlab/rpLibElement.cc @ 154

Last change on this file since 154 was 154, checked in by dkearney, 16 years ago

modified matlab bindings and tests.
includes all popular functions available in RpLibrary? and RpUnits
compile and run, but not all tests work as they should
some of these functions will be removed soon because the id field is
no longer a valid argument. path ids should be incorporated in paths from now on.

File size: 2.1 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [nodeHandle,err] = rpLibElement(libHandle,path)
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: [retVal,err] = rpLibElement(libHandle,path)
20/// Return a handle to the element at location 'path' in 'libHandle'
21/**
22 * This method searches the Rappture Library Object 'libHandle' for the
23 * node at the location described by the path 'path' and returns
24 * a handle to it.
25 *
26 * If path is an empty string, the root of the node is used. 'libHandle'
27 * is the handle representing the instance of the RpLibrary object.
28 * Error code, err=0 on success, anything else is failure.
29 */
30
31
32void mexFunction(int nlhs, mxArray *plhs[],
33                 int nrhs, const mxArray *prhs[])
34{
35    int         libIndex = 0;
36    int         retLibIndex = 0;
37    int         err = 1;
38    RpLibrary*  lib = NULL;
39    RpLibrary*  retLib = NULL;
40    char*       path = NULL;
41
42    /* Check for proper number of arguments. */
43    if (nrhs != 2)
44        mexErrMsgTxt("Two input required.");
45    else if (nlhs > 2)
46        mexErrMsgTxt("Too many output arguments.");
47
48    libIndex = getIntInput(prhs[0]);
49    path = getStringInput(prhs[1]);
50
51    /* Call the C subroutine. */
52    if ( (libIndex > 0) && (path) ) {
53        lib = getObject_Lib(libIndex);
54        if (lib) {
55            retLib = rpElement(lib,path);
56            retLibIndex = storeObject_Lib(retLib);
57            if (retLibIndex) {
58                err = 0;
59            }
60        }
61    }
62
63    /* Set double scalar node handle to MATLAB mexFunction output*/
64    plhs[0] = mxCreateDoubleScalar(retLibIndex);
65    plhs[1] = mxCreateDoubleScalar(err);
66
67    return;
68}
Note: See TracBrowser for help on using the repository browser.