source: trunk/src/octave/rpUnitsGetExponent.cc @ 829

Last change on this file since 829 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.2 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retVal,err] = rpUnitsGetExponent(unitHandle)
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] = rpUnitsGetExponent(unitHandle)
18/// Return the exponent of the Rappture Unit represented by unitHandle.
19/**
20 * Retrieve the exponent of the Rappture Units object with the handle
21 * 'unitHandle'. Return the exponent as a double.
22 * Error code, err=0 on success, anything else is failure.
23 */
24
25DEFUN_DLD (rpUnitsGetExponent, args, ,
26"-*- texinfo -*-\n\
27[retVal,err] = rpUnitsGetExponent(@var{unitHandle})\n\
28\n\
29Retrieve the exponent of the Rappture Units object with the handle \n\
30'unitHandle'. Return the exponent as a double.\n\
31Error code, err=0 on success, anything else is failure.")
32{
33    static std::string who = "rpUnitsGetExponent";
34
35    // The list of values to return.
36    octave_value_list retval;
37    int err = 1;
38    int nargin = args.length ();
39
40    const RpUnits* myUnit = NULL;
41    int unitHandle = 0;
42    double exponent = 0;
43
44    if (nargin == 1) {
45
46        if ( args(0).is_real_scalar() ) {
47
48            unitHandle = args(0).int_value ();
49
50            /* Call the C subroutine. */
51            if ( unitHandle >= 0 ) {
52
53                // get the original unit
54                myUnit = getObject_UnitsStr(unitHandle);
55                if (myUnit) {
56                    // get the basis
57                    exponent = myUnit->getExponent();
58                    // adjust error code
59                    err = 0;
60                }
61            }
62            else {
63                // invalid unitHandle
64                print_usage (who.c_str());
65            }
66        }
67        else {
68            print_usage (who.c_str());
69        }
70    }
71    else {
72        print_usage (who.c_str());
73    }
74
75    retval(0) = exponent;
76    retval(1) = err;
77    return retval;
78}
Note: See TracBrowser for help on using the repository browser.