source: trunk/lang/matlab/rpLib.cc @ 4503

Last change on this file since 4503 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 1.6 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Source
4 *
5 *    [libHandle,err] = rpLib(fileName)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
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: [libHandle,err] = rpLib (fileName)
20/// Opens a Rappture Library Object based on the xml file 'fileName'.
21/**
22 * Usually called in the beginning of a program to load an xml file
23 * for future reading.
24 */
25
26void mexFunction(int nlhs, mxArray *plhs[],
27                 int nrhs, const mxArray *prhs[])
28{
29    std::string path;
30    RpLibrary* lib = NULL;
31    int libIndex = 0;
32    int err = 1;
33
34    /* Check for proper number of arguments. */
35    if (nrhs != 1) {
36        mexErrMsgTxt("One input required.");
37    }
38
39    path = getStringInput(prhs[0]);
40
41    /* Call the C++ subroutine. */
42    lib = new RpLibrary(path);
43    if (lib) {
44        // store the library and return a dictionary key
45        libIndex = storeObject_Void((void*)lib);
46        if (libIndex) {
47            err = 0;
48        }
49    }
50
51    /* Set C-style string output_buf to MATLAB mexFunction output*/
52    plhs[0] = mxCreateDoubleScalar(libIndex);
53    plhs[1] = mxCreateDoubleScalar(err);
54
55    return;
56}
Note: See TracBrowser for help on using the repository browser.