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 | |
---|
26 | DEFUN_DLD (rpUnitsMakeMetric, args, , |
---|
27 | "-*- texinfo -*-\n\ |
---|
28 | [err] = rpUnitsMakeMetric(@var{basisHandle})\n\ |
---|
29 | \n\ |
---|
30 | Create the metric extensions for the Rappture Unit, referenced \n\ |
---|
31 | by @var{basisHandle}, within Rappture's internal units dictionary.\n\ |
---|
32 | Return an error code, @var{err}, to specify success or failure.\n\ |
---|
33 | Error 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 | } |
---|