1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Octave Rappture Library Source |
---|
4 | * |
---|
5 | * [retStr,err] = rpNodeType(nodeHandle) |
---|
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: [retStr,err] = rpNodeType(nodeHandle) |
---|
18 | /// Return the type name of the node represented by 'nodeHandle' |
---|
19 | /** |
---|
20 | * This method returns the type name of the node represented |
---|
21 | * by 'nodeHandle'. |
---|
22 | * Error code, err=0 on success, anything else is failure. |
---|
23 | */ |
---|
24 | |
---|
25 | DEFUN_DLD (rpNodeType, args, , |
---|
26 | "-*- texinfo -*-\n\ |
---|
27 | [retStr,err] = rpNodeType(@var{nodeHandle})\n\ |
---|
28 | \n\ |
---|
29 | This method returns the type name of the node represented \n\ |
---|
30 | by @var{nodeHandle}.\n\ |
---|
31 | Error code, err=0 on success, anything else is failure.") |
---|
32 | { |
---|
33 | static std::string who = "rpNodeType"; |
---|
34 | |
---|
35 | // The list of values to return. |
---|
36 | octave_value_list retval; |
---|
37 | int err = 1; |
---|
38 | int nargin = args.length (); |
---|
39 | int libHandle = 0; |
---|
40 | RpLibrary* lib = NULL; |
---|
41 | std::string retStr = ""; |
---|
42 | |
---|
43 | if (nargin == 1) { |
---|
44 | |
---|
45 | if ( args(0).is_real_scalar() ) { |
---|
46 | |
---|
47 | libHandle = args(0).int_value (); |
---|
48 | |
---|
49 | /* Call the C subroutine. */ |
---|
50 | if ( (libHandle >= 0) ) { |
---|
51 | |
---|
52 | lib = getObject_Lib(libHandle); |
---|
53 | if (lib) { |
---|
54 | retStr = lib->nodeType(); |
---|
55 | err = 0; |
---|
56 | } |
---|
57 | else { |
---|
58 | // lib is NULL, not found in dictionary |
---|
59 | } |
---|
60 | } |
---|
61 | else { |
---|
62 | // libHandle is negative |
---|
63 | print_usage (who.c_str()); |
---|
64 | } |
---|
65 | } |
---|
66 | else { |
---|
67 | // wrong argument types |
---|
68 | print_usage (who.c_str()); |
---|
69 | } |
---|
70 | } |
---|
71 | else { |
---|
72 | // wrong number of arguments |
---|
73 | print_usage (who.c_str()); |
---|
74 | } |
---|
75 | |
---|
76 | retval(0) = retStr; |
---|
77 | retval(1) = err; |
---|
78 | return retval; |
---|
79 | } |
---|