source: trunk/lang/matlab/rpLibChildren.cc @ 2701

Last change on this file since 2701 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.5 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [nodeHandle,err] = rpLibChildren(libHandle,path,prevNodeHandle)
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: [nodeHandle,err] = rpLibChildren(libHandle,path,prevNodeHandle)
20/// Retrieve the children of the node described by 'path'
21/**
22 * This method searches the Rappture Library Object 'libHandle' for the
23 * node at the location described by the path 'path' and returns its
24 * children. If 'prevNodeHandle' = 0, then the`
25 * first child is returned, else, the next child is retrieved.
26 * If 'prevNodeHandle' is an invalid child handle, an error will be returned.
27 * Subsequent calls to rpLibChildren() should use previously`
28 * returned 'nodeHandle's for it 'prevNodeHandle' argument.
29 * Error code, err=0 on success, anything else is failure.
30 */
31
32
33void mexFunction(int nlhs, mxArray *plhs[],
34                 int nrhs, const mxArray *prhs[])
35{
36    int         libIndex = 0;
37    int         childIndex = 0;
38    int         retLibIndex = 0;
39    int         err = 1;
40    RpLibrary*  lib = NULL;
41    RpLibrary*  child = NULL;
42    RpLibrary*  retLib = NULL;
43    std::string  path = "";
44
45    /* Check for proper number of arguments. */
46    if (nrhs != 3) {
47        mexErrMsgTxt("Three input required.");
48    }
49
50    libIndex = getIntInput(prhs[0]);
51    path = getStringInput(prhs[1]);
52    childIndex = getIntInput(prhs[2]);
53
54    /* Call the C++ subroutine. */
55    if ( (libIndex > 0)     &&
56         (!path.empty())      &&
57         (childIndex >= 0)      ) {
58
59        lib = (RpLibrary*) getObject_Void(libIndex);
60
61        if (childIndex > 0) {
62            child = (RpLibrary*) getObject_Void(childIndex);
63        }
64
65        if (lib) {
66            retLib = lib->children(path,child);
67            retLibIndex = storeObject_Void((void*)retLib);
68            if (retLibIndex) {
69                err = 0;
70            }
71        }
72    }
73
74    /* Set double scalar node handle to MATLAB mexFunction output*/
75    plhs[0] = mxCreateDoubleScalar(retLibIndex);
76    plhs[1] = mxCreateDoubleScalar(err);
77
78    return;
79}
Note: See TracBrowser for help on using the repository browser.