source: trunk/lang/matlab/rpLibChildrenByType.cc @ 4346

Last change on this file since 4346 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.6 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [nodeHandle,err] = rpLibChildrenByType(libHandle,path,prevNodeHandle,type)
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] = rpLibChildrenByType(libHandle,path,prevNodeHandle,type)
20/// Retrieve the children of the node described by 'path' of type 'type'
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 that match the type 'type'. 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 rpLibChildrenByType() 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    std::string type = "";
45
46    /* Check for proper number of arguments. */
47    if (nrhs != 4) {
48        mexErrMsgTxt("Four input required.");
49    }
50
51    libIndex = getIntInput(prhs[0]);
52    path = getStringInput(prhs[1]);
53    childIndex = getIntInput(prhs[2]);
54    type = getStringInput(prhs[3]);
55
56    /* Call the C++ subroutine. */
57    if ( (libIndex > 0) && (!path.empty()) && (!type.empty()) ) {
58        lib = (RpLibrary*) getObject_Void(libIndex);
59
60        if (childIndex > 0) {
61            child = (RpLibrary*) getObject_Void(childIndex);
62        }
63
64        if (lib) {
65            retLib = lib->children(path,child,type);
66            retLibIndex = storeObject_Void((void*)retLib);
67            if (retLibIndex) {
68                err = 0;
69            }
70        }
71    }
72
73    /* Set double scalar node handle to MATLAB mexFunction output*/
74    plhs[0] = mxCreateDoubleScalar(retLibIndex);
75    plhs[1] = mxCreateDoubleScalar(err);
76
77    return;
78}
Note: See TracBrowser for help on using the repository browser.