1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Matlab Rappture Library Source |
---|
4 | * |
---|
5 | * [retStr,err] = rpLibNodeId(lib) |
---|
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: [retStr,err] = rpLibNodeId(nodeHandle) |
---|
20 | /// Return the id name of the node represented by 'nodeHandle' |
---|
21 | /** |
---|
22 | * This method returns the id name of the node represented` |
---|
23 | * by 'nodeHandle'. |
---|
24 | * Error code, err=0 on success, anything else is failure. |
---|
25 | */ |
---|
26 | |
---|
27 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
28 | int nrhs, const mxArray *prhs[]) |
---|
29 | { |
---|
30 | int libIndex = 0; |
---|
31 | int err = 1; |
---|
32 | RpLibrary* lib = NULL; |
---|
33 | std::string retStr = ""; |
---|
34 | |
---|
35 | /* Check for proper number of arguments. */ |
---|
36 | if (nrhs != 1) { |
---|
37 | mexErrMsgTxt("One input required."); |
---|
38 | } |
---|
39 | |
---|
40 | // grab the integer value of the library handle |
---|
41 | libIndex = getIntInput(prhs[0]); |
---|
42 | |
---|
43 | /* Call the C subroutine. */ |
---|
44 | if (libIndex > 0) { |
---|
45 | lib = (RpLibrary*) getObject_Void(libIndex); |
---|
46 | if (lib) { |
---|
47 | retStr = lib->nodeId(); |
---|
48 | err = 0; |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | /* Set C-style string output_buf to MATLAB mexFunction output*/ |
---|
53 | plhs[0] = mxCreateString(retStr.c_str()); |
---|
54 | plhs[1] = mxCreateDoubleScalar(err); |
---|
55 | |
---|
56 | return; |
---|
57 | } |
---|