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

Last change on this file since 122 was 122, checked in by dkearney, 17 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: 2.6 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpGet(libHandle,path)
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] = rpGet(libHandle,path)
18/// Query the value of a node.
19/**
20 * Clients use this to query the value of a node.  If the path
21 * is not specified, it returns the value associated with the
22 * root node.  Otherwise, it returns the value for the element
23 * specified by the path. Values are returned as strings.
24 *
25 * Error code, err=0 on success, anything else is failure.
26 */
27
28DEFUN_DLD (rpGet, args, ,
29"-*- texinfo -*-\n\
30[retStr,err] = rpGet(@var{libHandle},@var{path})\n\
31\n\
32Clients use this to query the value of a node.  If the path\n\
33is not specified, it returns the value associated with the\n\
34root node.  Otherwise, it returns the value for the element\n\
35specified by the path. Values are returned as strings.\n\
36Error code, err=0 on success, anything else is failure.")
37{
38    static std::string who = "rpGet";
39
40    // The list of values to return.
41    octave_value_list retval;
42    int err = 1;
43    int nargin = args.length ();
44    std::string path = "";
45    int libHandle = 0;
46    RpLibrary* lib = NULL;
47    std::string retStr = "";
48
49    if (nargin == 2) {
50
51        if (    args(0).is_real_scalar () &&
52                args(1).is_string      ()   ) {
53
54            libHandle = args(0).int_value ();
55            path = args(1).string_value ();
56
57            /* Call the C subroutine. */
58            // path can be an empty string
59            if ( (libHandle >= 0) ) {
60
61                lib = getObject_Lib(libHandle);
62
63                if (lib) {
64                    retStr = lib->getString(path);
65                    err = 0;
66                }
67                else {
68                    // lib was null (not found in dictionary)
69                }
70            }
71            else {
72                // invalid libHandle
73                print_usage (who.c_str());
74            }
75        }
76        else {
77            // wrong arg types
78            print_usage (who.c_str());
79        }
80    }
81    else {
82        // wrong number of args.
83        print_usage (who.c_str());
84    }
85
86    retval(0) = retStr;
87    retval(1) = err;
88    return retval;
89}
Note: See TracBrowser for help on using the repository browser.