source: trunk/lang/octave/rpLibChildren.cc @ 1025

Last change on this file since 1025 was 135, checked in by dkearney, 18 years ago

1) fixed children function in c++'s library module so users can now
search for children by type.
2) adjusted bindings dictionary module for storing lib's to allow caller
to set the key of the value being stored.
3) removed old targets for rappture_interface.o and rappture_fortran.o
from makefile
4) renamed matlab and octave binding functions names to match the module
they came from.
5) adjusted matlab/octave example in examples/app_fermi/matlab
6) added matlab and octave search paths environment variables to
gui/apps/rappture

File size: 3.2 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [nodeHandle,err] = rpLibChildren(libHandle,path,prevNodeHandle)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2005
10 *  Purdue Research Foundation, West Lafayette, IN
11 * ======================================================================
12 */
13
14#include "RpOctaveInterface.h"
15
16/**********************************************************************/
17// METHOD: [nodeHandle,err] = rpLibChildren(libHandle,path,prevNodeHandle)
18/// Retrieve the children of the node described by 'path'
19/**
20 * This method searches the Rappture Library Object 'libHandle' for the
21 * node at the location described by the path 'path' and returns its
22 * children. If 'prevNodeHandle' = 0, then the
23 * first child is returned, else, the next child is retrieved.
24 * If 'prevNodeHandle' is an invalid child handle, an error will be returned.
25 * Subsequent calls to rpLibChildren() should use previously
26 * returned 'nodeHandle's for it 'prevNodeHandle' argument.
27 * Error code, err=0 on success, anything else is failure.
28 */
29
30DEFUN_DLD (rpLibChildren, args, ,
31"-*- texinfo -*-\n\
32[nodeHandle,err] = rpLibChildren(@var{libHandle},@var{path},@var{prevNodeHandle})\n\
33\n\
34Retrieve the children of the node described by @var{path} \n\
35This method searches the Rappture Library Object 'libHandle' \n\
36for the node at the location described by @var{path} and returns its \n\
37children. If @var{prevNodeHandle} = 0, then the·\n\
38first child is returned, else, the next child is retrieved.\n\
39If @var{prevNodeHandle} is an invalid child handle, an error will be \n\
40returned. Subsequent calls to @code{rpLibChildren} should use \n\
41previously returned 'nodeHandle's for it var{prevNodeHandle}. \n\
42Error code, err=0 on success, anything else is failure.")
43{
44    static std::string who = "rpLibChildren";
45
46    // The list of values to return.
47    octave_value_list retval;
48    int err = 1;
49    int nargin = args.length ();
50    std::string path = "";
51    int prevNodeIndex = 0;
52    int libIndex = 0;
53    RpLibrary* lib = NULL;
54    RpLibrary* prevLib = NULL;
55    RpLibrary* newLib = NULL;
56
57    if (nargin == 3) {
58
59        if (    args(0).is_real_scalar () &&
60                args(1).is_string      () &&
61                args(2).is_real_scalar ()   ) {
62
63            libIndex = args(0).int_value ();
64            path = args(1).string_value ();
65            prevNodeIndex = args(2).int_value ();
66
67            /* Call the C subroutine. */
68            if (    (libIndex != 0)      &&
69                    !path.empty()        &&
70                    (prevNodeIndex >= 0)    ) {
71
72                lib = getObject_Lib(libIndex);
73                prevLib = getObject_Lib(prevNodeIndex);
74
75                if (lib) {
76                    newLib = lib->children(path,prevLib);
77                    err = 0;
78                }
79
80            }
81        }
82        else {
83            print_usage (who.c_str());
84        }
85    }
86    else {
87        print_usage (who.c_str());
88    }
89
90    retval(0) = storeObject_Lib(newLib,prevNodeIndex);
91    retval(1) = err;
92    return retval;
93}
Note: See TracBrowser for help on using the repository browser.