source: trunk/lang/octave/rpUnitsMakeMetric.cc @ 1095

Last change on this file since 1095 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.5 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [err] = rpUnitsMakeMetric(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] = rpUnitsMakeMetric(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 (rpUnitsMakeMetric, args, ,
27"-*- texinfo -*-\n\
28[err] = rpUnitsMakeMetric(@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 = "rpUnitsMakeMetric";
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.