source: trunk/src/octave/rpPutDoubleId.cc @ 125

Last change on this file since 125 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: 3.6 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [err] = rpPutDoubleId(libHandle,path,value,id,append)
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] = rpPutDoubleId (libHandle,path,value,id,append)
18/// Set the value of a node.
19/**
20 * Clients use this to set the value of a node.  If the path
21 * is not specified, it sets the value for the root node.
22 * Otherwise, it sets the value for the element specified
23 * by the path.  The value is treated as the text within the
24 * tag at the tail of the path.
25 *
26 * 'id' is used to set the identifier field for the tag at the
27 * tail of the path.  If the append flag is set to 1, then the
28 * value is appended to the current value.  Otherwise, the
29 * value specified in the function call replaces the current value.
30 *
31 */
32
33DEFUN_DLD (rpPutDoubleId, args, ,
34"-*- texinfo -*-\n\
35[err] = rpPutDoubleId(@var{libHandle},@var{path},@var{value},@var{id},@var{append})\n\
36\n\
37Clients use this to set the value of a node.  If the @var{path}\n\
38is not specified (ie. empty string ""), it sets the value for the\n\
39root node.  Otherwise, it sets the value for the element specified\n\
40by the path.  The @var{value} is treated as the text within the \n\
41tag at the tail of the @var{path}.\n\
42\n\
43@var{id} is used to set the identifier field for the tag at the \n\
44tail of the @var{path}.  If the @var{append} flag is set to 1, then the \n\
45@var{value} is appended to the current value.  Otherwise, the \n\
46@var{value} specified in the function call replaces the current value.\n\
47Error Codes: err = 0 is success, anything else is failure.")
48{
49    static std::string who = "rpPutDoubleId";
50
51    // The list of values to return.
52    octave_value_list retval;
53    int err           = 1;
54    int nargin        = args.length ();
55    int libHandle     = 0;
56    std::string path  = "";
57    double value      = 0;
58    std::string id    = "";
59    int append        = 0;
60    RpLibrary* lib    = NULL;
61
62    if (nargin == 5) {
63
64        if ( args(0).is_real_scalar() &&
65             args(1).is_string()      &&
66             args(2).is_real_scalar() &&
67             args(3).is_string()      &&
68             args(4).is_real_scalar()   ) {
69
70            libHandle = args(0).int_value ();
71            path      = args(1).string_value ();
72            value     = args(2).double_value ();
73            id        = args(3).string_value ();
74            append    = args(4).int_value ();
75
76            /* Call the C subroutine. */
77            // the only input that has restrictions is libHandle
78            // all other inputs may be empty strings or any integer value
79            if ( (libHandle >= 0) ) {
80
81                lib = getObject_Lib(libHandle);
82                if (lib) {
83                    lib->put(path,value,id,append);
84                    err = 0;
85                }
86                else {
87                    // lib is NULL, not found in dictionary
88                }
89            }
90            else {
91                // libHandle is negative
92                print_usage (who.c_str());
93            }
94        }
95        else {
96            // wrong argument types
97            print_usage (who.c_str());
98        }
99    }
100    else {
101        // wrong number of arguments
102        print_usage (who.c_str());
103    }
104
105    retval(0) = err;
106    return retval;
107}
Note: See TracBrowser for help on using the repository browser.