source: trunk/lang/octave/rpAddPresets.cc @ 1216

Last change on this file since 1216 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.1 KB
Line 
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
28DEFUN_DLD (rpAddPresets, args, ,
29"-*- texinfo -*-\n\
30[err] = rpAddPresets (@var{presetName})\n\
31\n\
32Adds the units associated with the group @var{presetName} to the list of\n\
33available units within the Rappture Units Module.\n\
34Usually called in the beginning of the program to seed the Rappture Units\n\
35Module with default units. Available valid presets include 'all',\n\
36'energy', 'length', 'temp', 'time', 'volume'. To find out more\n\
37check out the Rappture Units Howto.\n\
38Error 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}
Note: See TracBrowser for help on using the repository browser.