1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Matlab Rappture Library Source |
---|
4 | * |
---|
5 | * [err] = rpLibPutDouble(libHandle,path,value,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] = rpLibPutDouble (libHandle,path,value,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 | * If the append flag is set to 1, then the` |
---|
29 | * value is appended to the current value. Otherwise, the` |
---|
30 | * value specified in the function call replaces the current value. |
---|
31 | * |
---|
32 | */ |
---|
33 | |
---|
34 | |
---|
35 | void 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 | std::string path = ""; |
---|
43 | double value = 0.0; |
---|
44 | |
---|
45 | /* Check for proper number of arguments. */ |
---|
46 | if (nrhs != 4) { |
---|
47 | mexErrMsgTxt("Two input required."); |
---|
48 | } |
---|
49 | |
---|
50 | libIndex = getIntInput(prhs[0]); |
---|
51 | path = getStringInput(prhs[1]); |
---|
52 | value = getDoubleInput(prhs[2]); |
---|
53 | append = getIntInput(prhs[3]); |
---|
54 | |
---|
55 | /* Call the C subroutine. */ |
---|
56 | if ( (libIndex > 0) && (!path.empty()) ) { |
---|
57 | lib = getObject_Lib(libIndex); |
---|
58 | |
---|
59 | if (lib) { |
---|
60 | lib->put(path,value,"",append); |
---|
61 | err = 0; |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | plhs[0] = mxCreateDoubleScalar(err); |
---|
66 | |
---|
67 | return; |
---|
68 | } |
---|