source: trunk/src/octave/rpElementAsComp.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.9 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpElementAsComp(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] = rpElementAsComp(libHandle,path)
18/// Return the component 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 * component name, a concatination of the type, id, and index.
23 * If path is an empty string, the root of the node is used. 'libHandle'
24 * is the handle representing the instance of the RpLibrary object.
25 * Error code, err=0 on success, anything else is failure.
26 */
27
28DEFUN_DLD (rpElementAsComp, args, ,
29"-*- texinfo -*-\n\
30[retStr,err] = rpElementAsComp(@var{libHandle},@var{path})\n\
31\n\
32This method searches the Rappture Library Object @var{libHandle} for the\n\
33node at the location described by the path @var{path} and returns its\n\
34component name, a concatination of the type, id, and index.\n\
35If path is an empty string, the root of the node is used. @var{libHandle}\n\
36is the handle representing the instance of the RpLibrary object.\n\
37Error code, err=0 on success, anything else is failure.")
38{
39    static std::string who = "rpElementAsComp";
40
41    // The list of values to return.
42    octave_value_list retval;
43    int err = 1;
44    int nargin = args.length ();
45    std::string path = "";
46    int libHandle = 0;
47    RpLibrary* lib = NULL;
48    RpLibrary* eleLib = NULL;
49    std::string retStr = "";
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                    if (eleLib) {
68                        retStr = eleLib->nodeComp();
69                    }
70                    err = 0;
71                }
72                else {
73                    //error message
74                }
75            }
76            else {
77                print_usage (who.c_str());
78            }
79        }
80        else {
81            print_usage (who.c_str());
82        }
83    }
84    else {
85        print_usage (who.c_str());
86    }
87
88    retval(0) = retStr;
89    retval(1) = err;
90    return retval;
91}
Note: See TracBrowser for help on using the repository browser.