source: trunk/src/octave/rpLibGet.cc @ 829

Last change on this file since 829 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: 2.6 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpLibGet(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] = rpLibGet(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 (rpLibGet, args, ,
29"-*- texinfo -*-\n\
30[retStr,err] = rpLibGet(@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 = "rpLibGet";
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->get(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.