1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Matlab Rappture Library Source |
---|
4 | * |
---|
5 | * nodeHandle = rpElement(libHandle,path) |
---|
6 | * |
---|
7 | * ====================================================================== |
---|
8 | * AUTHOR: Derrick Kearney, Purdue University |
---|
9 | * Copyright (c) 2005 |
---|
10 | * Purdue Research Foundation, West Lafayette, IN |
---|
11 | * ====================================================================== |
---|
12 | */ |
---|
13 | |
---|
14 | #include "RpMatlabInterface.h" |
---|
15 | |
---|
16 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
17 | int nrhs, const mxArray *prhs[]) |
---|
18 | { |
---|
19 | int libIndex = 0; |
---|
20 | int retLibIndex = 0; |
---|
21 | RpLibrary* lib = NULL; |
---|
22 | RpLibrary* retLib = NULL; |
---|
23 | char* path = NULL; |
---|
24 | |
---|
25 | /* Check for proper number of arguments. */ |
---|
26 | if (nrhs != 2) |
---|
27 | mexErrMsgTxt("Two input required."); |
---|
28 | else if (nlhs > 1) |
---|
29 | mexErrMsgTxt("Too many output arguments."); |
---|
30 | |
---|
31 | libIndex = getIntInput(prhs[0]); |
---|
32 | path = getStringInput(prhs[1]); |
---|
33 | |
---|
34 | /* Call the C subroutine. */ |
---|
35 | if ( (libIndex > 0) && (path) ) { |
---|
36 | lib = getObject_Lib(libIndex); |
---|
37 | if (lib) { |
---|
38 | retLib = rpElement(lib,path); |
---|
39 | retLibIndex = storeObject_Lib(retLib); |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | /* Set double scalar node handle to MATLAB mexFunction output*/ |
---|
44 | plhs[0] = mxCreateDoubleScalar(retLibIndex); |
---|
45 | |
---|
46 | return; |
---|
47 | } |
---|