Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 1996, 1997, 2006, 2007, 2008 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #if !defined (octave_mex_function_h) 00024 #define octave_mex_function_h 1 00025 00026 #include <string> 00027 00028 #include "oct-shlib.h" 00029 00030 #include "ov-fcn.h" 00031 #include "ov-builtin.h" 00032 #include "ov-typeinfo.h" 00033 00034 class octave_shlib; 00035 00036 class octave_value; 00037 class octave_value_list; 00038 00039 // Dynamically-linked functions. 00040 00041 class 00042 octave_mex_function : public octave_function 00043 { 00044 public: 00045 00046 octave_mex_function (void) { } 00047 00048 octave_mex_function (void *fptr, bool fmex, const octave_shlib& shl, 00049 const std::string& nm = std::string ()); 00050 00051 ~octave_mex_function (void); 00052 00053 octave_value subsref (const std::string& type, 00054 const std::list<octave_value_list>& idx) 00055 { 00056 octave_value_list tmp = subsref (type, idx, 1); 00057 return tmp.length () > 0 ? tmp(0) : octave_value (); 00058 } 00059 00060 octave_value_list subsref (const std::string& type, 00061 const std::list<octave_value_list>& idx, 00062 int nargout); 00063 00064 octave_function *function_value (bool = false) { return this; } 00065 00066 const octave_function *function_value (bool = false) const { return this; } 00067 00068 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } 00069 00070 std::string fcn_file_name (void) const; 00071 00072 octave_time time_parsed (void) const; 00073 00074 octave_time time_checked (void) const { return t_checked; } 00075 00076 bool is_system_fcn_file (void) const { return system_fcn_file; } 00077 00078 bool is_builtin_function (void) const { return false; } 00079 00080 bool is_mex_function (void) const { return true; } 00081 00082 octave_value_list 00083 do_multi_index_op (int nargout, const octave_value_list& args); 00084 00085 void atexit (void (*fcn) (void)) { exit_fcn_ptr = fcn; } 00086 00087 private: 00088 00089 void *mex_fcn_ptr; 00090 00091 void (*exit_fcn_ptr) (void); 00092 00093 bool have_fmex; 00094 00095 octave_shlib sh_lib; 00096 00097 // The time the file was last checked to see if it needs to be 00098 // parsed again. 00099 mutable octave_time t_checked; 00100 00101 // True if this function came from a file that is considered to be a 00102 // system function. This affects whether we check the time stamp 00103 // on the file to see if it has changed. 00104 bool system_fcn_file; 00105 00106 // No copying! 00107 00108 octave_mex_function (const octave_mex_function& fn); 00109 00110 octave_mex_function& operator = (const octave_mex_function& fn); 00111 00112 DECLARE_OCTAVE_ALLOCATOR 00113 00114 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA 00115 }; 00116 00117 #endif 00118 00119 /* 00120 ;;; Local Variables: *** 00121 ;;; mode: C++ *** 00122 ;;; End: *** 00123 */