source: trunk/src/matlab/rpLibPutDoubleId.cc @ 154

Last change on this file since 154 was 154, checked in by dkearney, 16 years ago

modified matlab bindings and tests.
includes all popular functions available in RpLibrary? and RpUnits
compile and run, but not all tests work as they should
some of these functions will be removed soon because the id field is
no longer a valid argument. path ids should be incorporated in paths from now on.

File size: 2.2 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [err] = rpLibPutDoubleId(libHandle,path,value,id,append)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2004-2005  Purdue Research Foundation
10 *
11 *  See the file "license.terms" for information on usage and
12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * ======================================================================
14 */
15
16#include "RpMatlabInterface.h"
17
18/**********************************************************************/
19// METHOD: [err] = rpLibPutDoubleId (libHandle,path,value,id,append)
20/// Set the value of a node.
21/**
22 * Clients use this to set the value of a node.  If the path
23 * is not specified, it sets the value for the root node.
24 * Otherwise, it sets the value for the element specified
25 * by the path.  The value is treated as the text within the`
26 * tag at the tail of the path.
27 *
28 * 'id' is used to set the identifier field for the tag at the`
29 * tail of the path.  If the append flag is set to 1, then the`
30 * value is appended to the current value.  Otherwise, the`
31 * value specified in the function call replaces the current value.
32 *
33 */
34
35void mexFunction(int nlhs, mxArray *plhs[],
36                 int nrhs, const mxArray *prhs[])
37{
38    int         libIndex = 0;
39    int         append = 0;
40    int         err = 1;
41    RpLibrary*  lib = NULL;
42    RpLibrary*  retLib = NULL;
43    char*       path = NULL;
44    double      value = 0.0;
45    char*       id = NULL;
46
47    /* Check for proper number of arguments. */
48    if (nrhs != 5)
49        mexErrMsgTxt("Two input required.");
50    else if (nlhs > 1)
51        mexErrMsgTxt("Too many output arguments.");
52
53    libIndex = getIntInput(prhs[0]);
54    path = getStringInput(prhs[1]);
55    value = getDoubleInput(prhs[2]);
56    id = getStringInput(prhs[3]);
57    append = getIntInput(prhs[4]);
58
59    /* Call the C subroutine. */
60    if ( (libIndex > 0) && path && id) {
61        lib = getObject_Lib(libIndex);
62
63        if (lib) {
64            rpPutDoubleId(lib,path,value,id,append);
65            err = 0;
66        }
67    }
68
69    plhs[0] = mxCreateDoubleScalar(err);
70
71    return;
72}
Note: See TracBrowser for help on using the repository browser.