source: trunk/src/octave/rpChildrenByType.cc @ 122

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

added initial version of octave language bindings.
1) no claiming language bindings work, but will happily take credit if they do.
2) bindings are untested
3) bindings happen to work with mystery example that happens to be located in examples/app-fermi/matlab/fermi_rp.m and happens to be invokable with examples/app-fermi/matlab/tool_rp.xml
4) bindings need octave2.1-headers installed (in debian: apt-get install octave2.1-headers) to get the mkoctfile program
5) binding function names might be changing to be more discriptive and more tightly bound to either the lib or units module.
6) adjusted Makefile to add octave bindings compilation.

File size: 3.5 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [nodeHandle,err] = rpChildrenByType(libHandle,path,prevNodeHandle,type)
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] = rpChildrenByType(libHandle,path,prevNodeHandle,type)
18/// Retrieve the children of the node described by 'path' of type 'type'
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 that match the type 'type'. 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 rpChildrenByType() 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 (rpChildrenByType, args, ,
31"-*- texinfo -*-\n\
32[nodeHandle,err] = rpChildrenByType(@var{libHandle},@var{path},@var{prevNodeHandle},@var{type})\n\
33\n\
34Retrieve the children of the node described by @var{path} of type\n\
35@var{type} This method searches the Rappture Library Object 'libHandle' \n\
36for the node at the location described by @var{path} and returns its \n\
37children that match @var{type}. 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{rpChildrenByType} 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 = "rpChildrenByType";
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    std::string type = "";
52    int prevNodeIndex = 0;
53    int libIndex = 0;
54    RpLibrary* lib = NULL;
55    RpLibrary* prevLib = NULL;
56    RpLibrary* newLib = NULL;
57
58    retval(0) = 1;
59
60    if (nargin == 4) {
61
62        if (    args(0).is_real_scalar () &&
63                args(1).is_string      () &&
64                args(2).is_real_scalar () &&
65                args(3).is_string      ()       ) {
66
67            libIndex = args(0).int_value ();
68            path = args(1).string_value ();
69            prevNodeIndex = args(2).int_value ();
70            type = args(3).string_value ();
71
72            /* Call the C subroutine. */
73            if (    (libIndex != 0)      &&
74                    !path.empty()        &&
75                    (prevNodeIndex != 0) &&
76                    !type.empty()           ) {
77
78                lib = getObject_Lib(libIndex);
79                prevLib = getObject_Lib(prevNodeIndex);
80
81                if (lib) {
82                    newLib = lib->children(path,prevLib,type);
83                    err = 0;
84                }
85
86            }
87        }
88        else {
89            print_usage ("rpChildrenByType");
90        }
91    }
92    else {
93        print_usage ("rpChildrenByType");
94    }
95
96    retval(0) = storeObject_Lib(newLib);
97    retval(1) = err;
98    return retval;
99}
Note: See TracBrowser for help on using the repository browser.