source: trunk/src/octave/rpNodeComp.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.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpNodeComp(nodeHandle)
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] = rpNodeComp(nodeHandle)
18/// Return the component name of the node represented by 'nodeHandle'
19/**
20 * This method returns the component name of the node represented
21 * by 'nodeHandle'. The component name is a concatination of the 
22 * type, id, and index.
23 * Error code, err=0 on success, anything else is failure.
24 */
25
26DEFUN_DLD (rpNodeComp, args, ,
27"-*- texinfo -*-\n\
28[retStr,err] = rpNodeComp(@var{nodeHandle})\n\
29\n\
30This method returns the component name of the node represented \n\
31by @var{nodeHandle}. The component name is a concatination of the \n\
32type, id, and index.\n\
33Error code, err=0 on success, anything else is failure.")
34{
35    static std::string who = "rpNodeComp";
36
37    // The list of values to return.
38    octave_value_list retval;
39    int err = 1;
40    int nargin = args.length ();
41    int libHandle = 0;
42    RpLibrary* lib = NULL;
43    std::string retStr = "";
44
45    if (nargin == 1) {
46
47        if ( args(0).is_real_scalar() ) {
48
49            libHandle = args(0).int_value ();
50
51            /* Call the C subroutine. */
52            if ( (libHandle >= 0) ) {
53
54                lib = getObject_Lib(libHandle);
55                if (lib) {
56                    retStr = lib->nodeComp();
57                    err = 0;
58                }
59                else {
60                    // lib is NULL, not found in dictionary
61                }
62            }
63            else {
64                // libHandle is negative
65                print_usage (who.c_str());
66            }
67        }
68        else {
69            // wrong argument types
70            print_usage (who.c_str());
71        }
72    }
73    else {
74        // wrong number of arguments
75        print_usage (who.c_str());
76    }
77
78    retval(0) = retStr;
79    retval(1) = err;
80    return retval;
81}
Note: See TracBrowser for help on using the repository browser.