source: trunk/lang/matlab/rpLibElementAsObject.cc @ 2661

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

adjusting matlab and octave bindings to use the void* bindings dictionary instead of the lib* dictionary in hopes that we can phase out the lib* dictionary.

File size: 2.1 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [nodeHandle,err] = rpLibElementAsObject(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: [retStr,err] = rpLibElementAsObject(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
31void mexFunction(int nlhs, mxArray *plhs[],
32                 int nrhs, const mxArray *prhs[])
33{
34    int         libIndex = 0;
35    int         retLibIndex = 0;
36    int         err = 1;
37    RpLibrary*  lib = NULL;
38    RpLibrary*  retLib = NULL;
39    std::string path = "";
40
41    /* Check for proper number of arguments. */
42    if (nrhs != 2) {
43        mexErrMsgTxt("Two input required.");
44    }
45
46    libIndex = getIntInput(prhs[0]);
47    path = getStringInput(prhs[1]);
48
49    /* Call the C++ subroutine. */
50    if ( (libIndex > 0) && (!path.empty()) ) {
51        lib = (RpLibrary*) getObject_Void(libIndex);
52        if (lib) {
53            retLib = lib->element(path);
54            retLibIndex = storeObject_Void((void*)retLib);
55            if (retLibIndex) {
56                err = 0;
57            }
58        }
59    }
60
61    /* Set double scalar node handle to MATLAB mexFunction output*/
62    plhs[0] = mxCreateDoubleScalar(retLibIndex);
63    plhs[1] = mxCreateDoubleScalar(err);
64
65    return;
66}
Note: See TracBrowser for help on using the repository browser.