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

Last change on this file since 3404 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

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-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: [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.