source: trunk/src/matlab/rpLibElementAsId.cc @ 708

Last change on this file since 708 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.1 KB
RevLine 
[97]1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
[154]5 *    [retStr,err] = rpLibElementAsId(lib,path)
[97]6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
[115]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.
[97]13 * ======================================================================
14 */
15
16#include "RpMatlabInterface.h"
17
[154]18/**********************************************************************/
19// METHOD: [retStr,err] = rpLibElementAsId(libHandle,path)
20/// Return the id attribute 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 * id attribute.
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]31void 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;
[162]38    RpLibrary*  eleLib = NULL;
39    std::string path = "";
40    std::string retStr = "";
[97]41
42    /* Check for proper number of arguments. */
[162]43    if (nrhs != 2) {
[97]44        mexErrMsgTxt("Two input required.");
[162]45    }
[97]46
47    libIndex = getIntInput(prhs[0]);
48    path = getStringInput(prhs[1]);
49
50    /* Call the C subroutine. */
[162]51    if ( (libIndex > 0) && (!path.empty()) ) {
[97]52        lib = getObject_Lib(libIndex);
53        if (lib) {
[162]54            eleLib = lib->element(path);
55            if (eleLib) {
56                retStr = eleLib->nodeId();
57                // an empty id field is valid
[154]58                err = 0;
59            }
[97]60        }
61    }
62
63    /* Set C-style string output_buf to MATLAB mexFunction output*/
[162]64    plhs[0] = mxCreateString(retStr.c_str());
[154]65    plhs[1] = mxCreateDoubleScalar(err);
[97]66
67    return;
68}
Note: See TracBrowser for help on using the repository browser.