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 | |
---|
30 | DEFUN_DLD (rpLibChildren, args, , |
---|
31 | "-*- texinfo -*-\n\ |
---|
32 | [nodeHandle,err] = rpLibChildren(@var{libHandle},@var{path},@var{prevNodeHandle})\n\ |
---|
33 | \n\ |
---|
34 | Retrieve the children of the node described by @var{path} \n\ |
---|
35 | This method searches the Rappture Library Object 'libHandle' \n\ |
---|
36 | for the node at the location described by @var{path} and returns its \n\ |
---|
37 | children. If @var{prevNodeHandle} = 0, then the·\n\ |
---|
38 | first child is returned, else, the next child is retrieved.\n\ |
---|
39 | If @var{prevNodeHandle} is an invalid child handle, an error will be \n\ |
---|
40 | returned. Subsequent calls to @code{rpLibChildren} should use \n\ |
---|
41 | previously returned 'nodeHandle's for it var{prevNodeHandle}. \n\ |
---|
42 | Error 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 | } |
---|