1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Octave Rappture Units Source |
---|
4 | * |
---|
5 | * [err] = rpAddPresets (presetName) |
---|
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] = rpAddPresets (presetName) |
---|
18 | /// Adds the units associated with the group 'presetName' to the list of |
---|
19 | /// available units within the Rappture Units Module. |
---|
20 | /** |
---|
21 | * Usually called in the beginning of the program to seed the Rappture Units |
---|
22 | * Module with default units. Available valid presets include 'all', |
---|
23 | * 'energy', 'length', 'temp', 'time', 'volume'. To find out more |
---|
24 | * check out the Rappture Units Howto. |
---|
25 | * Error code, err=0 on success, anything else is failure. |
---|
26 | */ |
---|
27 | |
---|
28 | DEFUN_DLD (rpAddPresets, args, , |
---|
29 | "-*- texinfo -*-\n\ |
---|
30 | [err] = rpAddPresets (@var{presetName})\n\ |
---|
31 | \n\ |
---|
32 | Adds the units associated with the group @var{presetName} to the list of\n\ |
---|
33 | available units within the Rappture Units Module.\n\ |
---|
34 | Usually called in the beginning of the program to seed the Rappture Units\n\ |
---|
35 | Module with default units. Available valid presets include 'all',\n\ |
---|
36 | 'energy', 'length', 'temp', 'time', 'volume'. To find out more\n\ |
---|
37 | check out the Rappture Units Howto.\n\ |
---|
38 | Error code, err=0 on success, anything else is failure.") |
---|
39 | { |
---|
40 | static std::string who = "rpAddPresets"; |
---|
41 | |
---|
42 | // The list of values to return. |
---|
43 | octave_value_list retval; |
---|
44 | |
---|
45 | int nargin = args.length (); |
---|
46 | std::string presetName = ""; |
---|
47 | RpLibrary* lib = NULL; |
---|
48 | int libIndex = 0; |
---|
49 | |
---|
50 | retval(0) = 1; |
---|
51 | |
---|
52 | if (nargin == 1) { |
---|
53 | if (args(0).is_string ()) { |
---|
54 | presetName = args(0).string_value (); |
---|
55 | /* Call the C subroutine. */ |
---|
56 | if ( !presetName.empty() ) { |
---|
57 | retval(0) = RpUnits::addPresets(presetName); |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | else { |
---|
62 | print_usage ("rpAddPresets"); |
---|
63 | } |
---|
64 | |
---|
65 | return retval; |
---|
66 | } |
---|