source: trunk/lang/octave/rpLibElementAsComp.cc @ 1262

Last change on this file since 1262 was 1262, checked in by dkearney, 15 years ago

attempting to fix compiler warning for octave's print_usage function
this seems to work for octave3.0
also adding checks to configure for more header files

File size: 3.0 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpLibElementAsComp(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 "RpOctaveInterface.h"
15
16/**********************************************************************/
17// METHOD: [retStr,err] = rpLibElementAsComp(libHandle,path)
18/// Return the component name of the element at location 'path' in 'libHandle'
19/**
20 * This method searches the Rappture Library Object 'libHandle' for the
21 * node at the location described by the path 'path' and returns its
22 * component name, a concatination of the type, id, and index.
23 * If path is an empty string, the root of the node is used. 'libHandle'
24 * is the handle representing the instance of the RpLibrary object.
25 * Error code, err=0 on success, anything else is failure.
26 */
27
28DEFUN_DLD (rpLibElementAsComp, args, ,
29"-*- texinfo -*-\n\
30[retStr,err] = rpLibElementAsComp(@var{libHandle},@var{path})\n\
31\n\
32This method searches the Rappture Library Object @var{libHandle} for the\n\
33node at the location described by the path @var{path} and returns its\n\
34component name, a concatination of the type, id, and index.\n\
35If path is an empty string, the root of the node is used. @var{libHandle}\n\
36is the handle representing the instance of the RpLibrary object.\n\
37Error code, err=0 on success, anything else is failure.")
38{
39    static std::string who = "rpLibElementAsComp";
40
41    // The list of values to return.
42    octave_value_list retval;
43    int err = 1;
44    int nargin = args.length ();
45    std::string path = "";
46    int libHandle = 0;
47    RpLibrary* lib = NULL;
48    RpLibrary* eleLib = NULL;
49    std::string retStr = "";
50
51    if (nargin == 2) {
52
53        if (    args(0).is_real_scalar () &&
54                args(1).is_string      ()   ) {
55
56            libHandle = args(0).int_value ();
57            path = args(1).string_value ();
58
59            /* Call the C subroutine. */
60            // path can be an empty string
61            if ( (libHandle != 0) ) {
62
63                lib = (RpLibrary*) getObject_Void(libHandle);
64
65                if (lib) {
66                    eleLib = lib->element(path);
67                    if (eleLib) {
68                        retStr = eleLib->nodeComp();
69                        if (!retStr.empty()) {
70                            err = 0;
71                        }
72                    }
73                }
74                else {
75                    //error message
76                }
77            }
78            else {
79                _PRINT_USAGE (who.c_str());
80            }
81        }
82        else {
83            _PRINT_USAGE (who.c_str());
84        }
85    }
86    else {
87        _PRINT_USAGE (who.c_str());
88    }
89
90    retval(0) = retStr;
91    retval(1) = err;
92    return retval;
93}
Note: See TracBrowser for help on using the repository browser.