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

Last change on this file since 122 was 122, checked in by dkearney, 19 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.5 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [err] = rpMakeMetric(basisHandle)
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: [err] = rpMakeMetric(basisHandle)
18/// Create metric extensions for the Rappture Unit referenced by basisHandle
19/**
20 * Create the metric extensions for the Rappture Unit, referenced
21 * by basisHandle, within Rappture's internal units dictionary.
22 * Return an error code, err, to specify success or failure.
23 * Error code, err=0 on success, anything else is failure.
24 */
25
26DEFUN_DLD (rpMakeMetric, args, ,
27"-*- texinfo -*-\n\
28[err] = rpMakeMetric(@var{basisHandle})\n\
29\n\
30Create the metric extensions for the Rappture Unit, referenced \n\
31by @var{basisHandle}, within Rappture's internal units dictionary.\n\
32Return an error code, @var{err}, to specify success or failure.\n\
33Error code, err=0 on success, anything else is failure.")
34{
35    static std::string who = "rpMakeMetric";
36
37    // The list of values to return.
38    octave_value_list retval;
39    int err = 1;
40    int nargin = args.length ();
41
42    const RpUnits* myUnit = NULL;
43    int unitHandle = 0;
44
45    if (nargin == 1) {
46
47        if ( args(0).is_real_scalar() ) {
48
49            unitHandle = args(0).int_value ();
50
51            /* Call the C subroutine. */
52            if ( unitHandle >= 0 ) {
53
54                // get the original unit
55                myUnit = getObject_UnitsStr(unitHandle);
56                if (myUnit) {
57                    // make the metric extensions.
58                    err = RpUnits::makeMetric(myUnit);
59                    // adjust error code, because makeMetric returns
60                    // 0 on failure and 1 on success. need to fix this
61                    // in RpUnits.cc
62                    if (err) {
63                        err = 0;
64                    }
65                }
66            }
67            else {
68                // invalid unitHandle
69                print_usage (who.c_str());
70            }
71        }
72        else {
73            print_usage (who.c_str());
74        }
75    }
76    else {
77        print_usage (who.c_str());
78    }
79
80    retval(0) = err;
81    return retval;
82}
Note: See TracBrowser for help on using the repository browser.