source: trunk/src/octave/rpLibElement.cc @ 827

Last change on this file since 827 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 *    [retVal,err] = rpLibElement(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: [retVal,err] = rpLibElement(libHandle,path)
18/// Return a handle to the element at location 'path' in 'libHandle'
19/**
20 * This method searches the Rappture Library Object 'libHandle' for the
21 * node at the location described by the path 'path' and returns
22 * a handle to it.
23 *
24 * If path is an empty string, the root of the node is used. 'libHandle'
25 * is the handle representing the instance of the RpLibrary object.
26 * Error code, err=0 on success, anything else is failure.
27 */
28
29DEFUN_DLD (rpLibElement, args, ,
30"-*- texinfo -*-\n\
31[retVal,err] = rpLibElement(@var{libHandle},@var{path})\n\
32\n\
33This method searches the Rappture Library Object @var{libHandle} for the\n\
34node at the location described by the path @var{path} and returns\n\
35a handle to it.\n\
36If path is an empty string, the root of the node is used. @var{libHandle}\n\
37is the handle representing the instance of the RpLibrary object.\n\
38Error code, err=0 on success, anything else is failure.")
39{
40    static std::string who = "rpLibElement";
41
42    // The list of values to return.
43    octave_value_list retval;
44    int err = 1;
45    int nargin = args.length ();
46    std::string path = "";
47    int libHandle = 0;
48    RpLibrary* lib = NULL;
49    RpLibrary* eleLib = NULL;
50
51    if (nargin == 2) {
52
53        if (    args(0).is_real_scalar () &&
54                args(1).is_string      ()   ) {
55
56            libHandle = args(0).int_value ();
57            path = args(1).string_value ();
58
59            /* Call the C subroutine. */
60            // path can be an empty string
61            if ( (libHandle != 0) ) {
62
63                lib = getObject_Lib(libHandle);
64
65                if (lib) {
66                    eleLib = lib->element(path);
67                    err = 0;
68                }
69                else {
70                    //error message
71                }
72            }
73            else {
74                print_usage (who.c_str());
75            }
76        }
77        else {
78            print_usage (who.c_str());
79        }
80    }
81    else {
82        print_usage (who.c_str());
83    }
84
85    retval(0) = storeObject_Lib(eleLib);
86    retval(1) = err;
87    return retval;
88}
Note: See TracBrowser for help on using the repository browser.