ov-mex-fcn.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 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     : mex_fcn_ptr (), exit_fcn_ptr (), have_fmex (), sh_lib (),
00048       t_checked (), system_fcn_file () { }
00049 
00050   octave_mex_function (void *fptr, bool fmex, const octave_shlib& shl,
00051                        const std::string& nm = std::string ());
00052 
00053   ~octave_mex_function (void);
00054 
00055   octave_value subsref (const std::string& type,
00056                         const std::list<octave_value_list>& idx)
00057     {
00058       octave_value_list tmp = subsref (type, idx, 1);
00059       return tmp.length () > 0 ? tmp(0) : octave_value ();
00060     }
00061 
00062   octave_value_list subsref (const std::string& type,
00063                              const std::list<octave_value_list>& idx,
00064                              int nargout);
00065 
00066   octave_function *function_value (bool = false) { return this; }
00067 
00068   const octave_function *function_value (bool = false) const { return this; }
00069 
00070   void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; }
00071 
00072   std::string fcn_file_name (void) const;
00073 
00074   octave_time time_parsed (void) const;
00075 
00076   octave_time time_checked (void) const { return t_checked; }
00077 
00078   bool is_system_fcn_file (void) const { return system_fcn_file; }
00079 
00080   bool is_builtin_function (void) const { return false; }
00081 
00082   bool is_mex_function (void) const { return true; }
00083 
00084   octave_value_list
00085   do_multi_index_op (int nargout, const octave_value_list& args);
00086 
00087   void atexit (void (*fcn) (void)) { exit_fcn_ptr = fcn; }
00088 
00089   octave_shlib get_shlib (void) const
00090     { return sh_lib; }
00091 
00092 private:
00093 
00094   void *mex_fcn_ptr;
00095 
00096   void (*exit_fcn_ptr) (void);
00097 
00098   bool have_fmex;
00099 
00100   octave_shlib sh_lib;
00101 
00102   // The time the file was last checked to see if it needs to be
00103   // parsed again.
00104   mutable octave_time t_checked;
00105 
00106   // True if this function came from a file that is considered to be a
00107   // system function.  This affects whether we check the time stamp
00108   // on the file to see if it has changed.
00109   bool system_fcn_file;
00110 
00111   // No copying!
00112 
00113   octave_mex_function (const octave_mex_function& fn);
00114 
00115   octave_mex_function& operator = (const octave_mex_function& fn);
00116 
00117   DECLARE_OCTAVE_ALLOCATOR
00118 
00119   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00120 };
00121 
00122 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines