Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 00004 2006, 2007, 2008, 2009 John W. Eaton 00005 00006 This file is part of Octave. 00007 00008 Octave is free software; you can redistribute it and/or modify it 00009 under the terms of the GNU General Public License as published by the 00010 Free Software Foundation; either version 3 of the License, or (at your 00011 option) any later version. 00012 00013 Octave is distributed in the hope that it will be useful, but WITHOUT 00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Octave; see the file COPYING. If not, see 00020 <http://www.gnu.org/licenses/>. 00021 00022 */ 00023 00024 #if !defined (octave_function_h) 00025 #define octave_function_h 1 00026 00027 #include <string> 00028 00029 #include "oct-time.h" 00030 #include "str-vec.h" 00031 00032 #include "oct-alloc.h" 00033 #include "oct-obj.h" 00034 #include "ov-base.h" 00035 #include "ov-typeinfo.h" 00036 #include "symtab.h" 00037 00038 class tree_walker; 00039 00040 // Functions. 00041 00042 class 00043 OCTINTERP_API 00044 octave_function : public octave_base_value 00045 { 00046 public: 00047 00048 octave_function (void) 00049 : relative (false), locked (false), private_function (false), 00050 xdispatch_class (), my_name (), my_dir_name (), doc () { } 00051 00052 ~octave_function (void) { } 00053 00054 octave_base_value *clone (void) const; 00055 octave_base_value *empty_clone (void) const; 00056 00057 bool is_defined (void) const { return true; } 00058 00059 bool is_function (void) const { return true; } 00060 00061 virtual bool is_system_fcn_file (void) const { return false; } 00062 00063 virtual std::string fcn_file_name (void) const { return std::string (); } 00064 00065 virtual std::string parent_fcn_name (void) const { return std::string (); } 00066 00067 virtual symbol_table::scope_id parent_fcn_scope (void) const { return -1; } 00068 00069 virtual void mark_fcn_file_up_to_date (const octave_time&) { } 00070 00071 virtual symbol_table::scope_id scope (void) { return -1; } 00072 00073 virtual octave_time time_parsed (void) const 00074 { return octave_time (static_cast<time_t> (0)); } 00075 00076 virtual octave_time time_checked (void) const 00077 { return octave_time (static_cast<time_t> (0)); } 00078 00079 virtual bool is_nested_function (void) const { return false; } 00080 00081 virtual bool is_class_constructor (void) const { return false; } 00082 00083 virtual bool is_class_method (void) const { return false; } 00084 00085 virtual bool takes_varargs (void) const { return false; } 00086 00087 virtual bool takes_var_return (void) const { return false; } 00088 00089 void stash_dispatch_class (const std::string& nm) { xdispatch_class = nm; } 00090 00091 std::string dispatch_class (void) const { return xdispatch_class; } 00092 00093 void mark_as_private_function (const std::string& cname = std::string ()) 00094 { 00095 private_function = true; 00096 xdispatch_class = cname; 00097 } 00098 00099 bool is_private_function (void) const { return private_function; } 00100 00101 bool is_private_function_of_class (const std::string& nm) 00102 { return private_function && xdispatch_class == nm; } 00103 00104 std::string dir_name (void) const { return my_dir_name; } 00105 00106 void stash_dir_name (const std::string& dir) { my_dir_name = dir; } 00107 00108 void lock (void) 00109 { 00110 this->lock_subfunctions (); 00111 locked = true; 00112 } 00113 00114 void unlock (void) 00115 { 00116 this->unlock_subfunctions (); 00117 locked = false; 00118 } 00119 00120 bool islocked (void) const { return locked; } 00121 00122 virtual void lock_subfunctions (void) { } 00123 00124 virtual void unlock_subfunctions (void) { } 00125 00126 void mark_relative (void) { relative = true; } 00127 00128 bool is_relative (void) const { return relative; } 00129 00130 std::string name (void) const { return my_name; } 00131 00132 void document (const std::string& ds) { doc = ds; } 00133 00134 std::string doc_string (void) const { return doc; } 00135 00136 virtual void unload (void) { } 00137 00138 virtual void accept (tree_walker&) { } 00139 00140 protected: 00141 00142 octave_function (const std::string& nm, 00143 const std::string& ds = std::string ()) 00144 : relative (false), my_name (nm), doc (ds) { } 00145 00146 // TRUE if this function was found from a relative path element. 00147 bool relative; 00148 00149 // TRUE if this function is tagged so that it can't be cleared. 00150 bool locked; 00151 00152 // TRUE means this is a private function. 00153 bool private_function; 00154 00155 // If this object is a class method or constructor, or a private 00156 // function inside a class directory, this is the name of the class 00157 // to which the method belongs. 00158 std::string xdispatch_class; 00159 00160 // The name of this function. 00161 std::string my_name; 00162 00163 // The name of the directory in the path where we found this 00164 // function. May be relative. 00165 std::string my_dir_name; 00166 00167 // The help text for this function. 00168 std::string doc; 00169 00170 private: 00171 00172 // No copying! 00173 00174 octave_function (const octave_function& f); 00175 00176 octave_function& operator = (const octave_function& f); 00177 00178 DECLARE_OCTAVE_ALLOCATOR 00179 }; 00180 00181 #endif 00182 00183 /* 00184 ;;; Local Variables: *** 00185 ;;; mode: C++ *** 00186 ;;; End: *** 00187 */