source: trunk/lang/matlab/rpLibElementAsType.cc @ 1082

Last change on this file since 1082 was 162, checked in by dkearney, 18 years ago

changed matlab api to call c++ functions instead of rappture's c api
removed following functions because they are outdated and should not be included at matlab/octave's release
src/octave/rpLibPutDoubleId.cc
src/octave/rpLibPutStringId.cc
src/matlab/rpLibPutDoubleId.cc
src/matlab/rpLibPutStringId.cc
cleaned up makefile to reflect the removal of above functions.
matlab bindings need to be retested. they receive a runtime error about undefined symbols

File size: 2.2 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [retStr,err] = rpLibElementAsType(lib,path)
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] = rpLibElementAsType(libHandle,path)
20/// Return the type name of 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 its
24 * type name.
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
31void mexFunction(int nlhs, mxArray *plhs[],
32                 int nrhs, const mxArray *prhs[])
33{
34    int         libIndex = 0;
35    int         retLibIndex = 0;
36    int         err = 1;
37    RpLibrary*  lib = NULL;
38    RpLibrary*  eleLib = NULL;
39    std::string path = "";
40    std::string retStr = "";
41
42    /* Check for proper number of arguments. */
43    if (nrhs != 2) {
44        mexErrMsgTxt("Two input required.");
45    }
46
47    libIndex = getIntInput(prhs[0]);
48    path = getStringInput(prhs[1]);
49
50    /* Call the C++ subroutine. */
51    if ( (libIndex > 0) && (!path.empty()) ) {
52        lib = getObject_Lib(libIndex);
53        if (lib) {
54            eleLib = lib->element(path);
55            if (eleLib) {
56                retStr = eleLib->nodeType();
57                if (!retStr.empty()) {
58                    err = 0;
59                }
60            }
61        }
62    }
63
64    /* Set C-style string output_buf to MATLAB mexFunction output*/
65    plhs[0] = mxCreateString(retStr.c_str());
66    plhs[1] = mxCreateDoubleScalar(err);
67
68    return;
69}
Note: See TracBrowser for help on using the repository browser.