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

Last change on this file since 122 was 122, checked in by dkearney, 18 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.8 KB
RevLine 
[122]1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpElementAsType(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] = rpElementAsType(libHandle,path)
18/// Return the type name of 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 its
22 * type name.
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 (rpElementAsType, args, ,
30"-*- texinfo -*-\n\
31[retStr,err] = rpElementAsType(@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 its\n\
35type name.\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 = "rpElementAsType";
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    std::string retStr = "";
51
52    if (nargin == 2) {
53
54        if (    args(0).is_real_scalar () &&
55                args(1).is_string      ()   ) {
56
57            libHandle = args(0).int_value ();
58            path = args(1).string_value ();
59
60            /* Call the C subroutine. */
61            // path can be an empty string
62            if ( (libHandle != 0) ) {
63
64                lib = getObject_Lib(libHandle);
65
66                if (lib) {
67                    eleLib = lib->element(path);
68                    if (eleLib) {
69                        retStr = eleLib->nodeType();
70                    }
71                    err = 0;
72                }
73                else {
74                    //error message
75                }
76            }
77            else {
78                print_usage (who.c_str());
79            }
80        }
81        else {
82            print_usage (who.c_str());
83        }
84    }
85    else {
86        print_usage (who.c_str());
87    }
88
89    retval(0) = retStr;
90    retval(1) = err;
91    return retval;
92}
Note: See TracBrowser for help on using the repository browser.