[97] | 1 | /* |
---|
| 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * INTERFACE: Matlab Rappture Library Source |
---|
| 4 | * |
---|
[154] | 5 | * [nodeHandle,err] = rpLibElementAsObject(libHandle,path) |
---|
[97] | 6 | * |
---|
| 7 | * ====================================================================== |
---|
| 8 | * AUTHOR: Derrick Kearney, Purdue University |
---|
[3177] | 9 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
[115] | 10 | * |
---|
| 11 | * See the file "license.terms" for information on usage and |
---|
| 12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
[97] | 13 | * ====================================================================== |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "RpMatlabInterface.h" |
---|
| 17 | |
---|
[154] | 18 | /**********************************************************************/ |
---|
| 19 | // METHOD: [retStr,err] = rpLibElementAsObject(libHandle,path) |
---|
| 20 | /// Return a handle to the element at location 'path' in 'libHandle' |
---|
| 21 | /** |
---|
| 22 | * This method searches the Rappture Library Object 'libHandle' for the |
---|
| 23 | * node at the location described by the path 'path' and returns |
---|
| 24 | * a handle to it. |
---|
| 25 | * |
---|
| 26 | * If path is an empty string, the root of the node is used. 'libHandle' |
---|
| 27 | * is the handle representing the instance of the RpLibrary object. |
---|
| 28 | * Error code, err=0 on success, anything else is failure. |
---|
| 29 | */ |
---|
| 30 | |
---|
[97] | 31 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
| 32 | int nrhs, const mxArray *prhs[]) |
---|
| 33 | { |
---|
| 34 | int libIndex = 0; |
---|
| 35 | int retLibIndex = 0; |
---|
[154] | 36 | int err = 1; |
---|
[97] | 37 | RpLibrary* lib = NULL; |
---|
| 38 | RpLibrary* retLib = NULL; |
---|
[162] | 39 | std::string path = ""; |
---|
[97] | 40 | |
---|
| 41 | /* Check for proper number of arguments. */ |
---|
[162] | 42 | if (nrhs != 2) { |
---|
[97] | 43 | mexErrMsgTxt("Two input required."); |
---|
[162] | 44 | } |
---|
[97] | 45 | |
---|
| 46 | libIndex = getIntInput(prhs[0]); |
---|
| 47 | path = getStringInput(prhs[1]); |
---|
| 48 | |
---|
[162] | 49 | /* Call the C++ subroutine. */ |
---|
| 50 | if ( (libIndex > 0) && (!path.empty()) ) { |
---|
[1085] | 51 | lib = (RpLibrary*) getObject_Void(libIndex); |
---|
[97] | 52 | if (lib) { |
---|
[162] | 53 | retLib = lib->element(path); |
---|
[1085] | 54 | retLibIndex = storeObject_Void((void*)retLib); |
---|
[154] | 55 | if (retLibIndex) { |
---|
| 56 | err = 0; |
---|
| 57 | } |
---|
[97] | 58 | } |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | /* Set double scalar node handle to MATLAB mexFunction output*/ |
---|
| 62 | plhs[0] = mxCreateDoubleScalar(retLibIndex); |
---|
[154] | 63 | plhs[1] = mxCreateDoubleScalar(err); |
---|
[97] | 64 | |
---|
| 65 | return; |
---|
| 66 | } |
---|