Mercurial > hg > octave-lojdl
annotate src/ov-fcn-handle.h @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | f6fffa74b9b5 |
children | d865363208d6 |
rev | line source |
---|---|
4343 | 1 /* |
2 | |
8920 | 3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 John W. Eaton |
4343 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
4343 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
4343 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_fcn_handle_h) | |
24 #define octave_fcn_handle_h 1 | |
25 | |
26 #include <iostream> | |
27 #include <string> | |
28 | |
29 #include "oct-alloc.h" | |
30 | |
31 #include "ov-base.h" | |
4654 | 32 #include "ov-base-mat.h" |
4343 | 33 #include "ov-fcn.h" |
4654 | 34 #include "ov-typeinfo.h" |
4343 | 35 |
36 // Function handles. | |
37 | |
4925 | 38 class |
7867
f6fffa74b9b5
Export additional symbols: octave_fcn_inline, octave_fcn_handle, read_binary_data, save_binary_data.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7761
diff
changeset
|
39 OCTINTERP_API |
4925 | 40 octave_fcn_handle : public octave_base_value |
4654 | 41 { |
42 public: | |
4930 | 43 octave_fcn_handle (void) |
5663 | 44 : warn_reload (true), fcn (), nm () { } |
4654 | 45 |
5007 | 46 octave_fcn_handle (const std::string& n) |
5663 | 47 : warn_reload (true), fcn (), nm (n) { } |
5007 | 48 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
49 octave_fcn_handle (const octave_value& f, const std::string& n); |
4654 | 50 |
4967 | 51 octave_fcn_handle (const octave_fcn_handle& fh) |
5663 | 52 : octave_base_value (fh), warn_reload (fh.warn_reload), |
53 fcn (fh.fcn), nm (fh.nm) { } | |
4967 | 54 |
4654 | 55 ~octave_fcn_handle (void) { } |
56 | |
5759 | 57 octave_base_value *clone (void) const { return new octave_fcn_handle (*this); } |
58 octave_base_value *empty_clone (void) const { return new octave_fcn_handle (); } | |
4967 | 59 |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
60 octave_value subsref (const std::string& type, |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
61 const std::list<octave_value_list>& idx) |
4924 | 62 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
63 octave_value_list tmp = subsref (type, idx, 1); |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
64 return tmp.length () > 0 ? tmp(0) : octave_value (); |
4924 | 65 } |
66 | |
67 octave_value_list subsref (const std::string& type, | |
68 const std::list<octave_value_list>& idx, | |
69 int nargout); | |
70 | |
4925 | 71 bool is_defined (void) const { return true; } |
4654 | 72 |
73 bool is_function_handle (void) const { return true; } | |
74 | |
5654 | 75 dim_vector dims (void) const { static dim_vector dv (1, 1); return dv; } |
76 | |
4930 | 77 octave_function *function_value (bool = false) |
78 { return fcn.function_value (); } | |
79 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
80 const octave_function *function_value (bool = false) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
81 { return fcn.function_value (); } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
82 |
6625 | 83 octave_user_function *user_function_value (bool = false) |
84 { return fcn.user_function_value (); } | |
85 | |
4654 | 86 octave_fcn_handle *fcn_handle_value (bool = false) { return this; } |
87 | |
5007 | 88 octave_value fcn_val (void) const { return fcn; } |
89 | |
4933 | 90 std::string fcn_name (void) const { return nm; } |
4930 | 91 |
6974 | 92 bool save_ascii (std::ostream& os); |
4988 | 93 |
94 bool load_ascii (std::istream& is); | |
95 | |
96 bool save_binary (std::ostream& os, bool& save_as_floats); | |
97 | |
98 bool load_binary (std::istream& is, bool swap, | |
99 oct_mach_info::float_format fmt); | |
100 | |
101 #if defined (HAVE_HDF5) | |
102 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); | |
103 | |
104 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); | |
105 #endif | |
106 | |
4654 | 107 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
108 | |
109 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; | |
110 | |
111 private: | |
4343 | 112 |
6625 | 113 bool set_fcn (const std::string &octaveroot, const std::string& fpath); |
114 | |
4612 | 115 DECLARE_OCTAVE_ALLOCATOR |
4343 | 116 |
4612 | 117 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
4925 | 118 |
5663 | 119 // If TRUE, print a warning if the pointed-to fucntion is out of |
120 // date. This variable may be removed when updating is properly | |
121 // implemented. | |
122 mutable bool warn_reload; | |
123 | |
4933 | 124 protected: |
4930 | 125 |
4925 | 126 // The function we are handling. |
4930 | 127 octave_value fcn; |
4925 | 128 |
129 // The name of the handle, including the "@". | |
130 std::string nm; | |
4343 | 131 }; |
132 | |
133 extern octave_value make_fcn_handle (const std::string& nm); | |
134 | |
135 #endif | |
136 | |
137 /* | |
138 ;;; Local Variables: *** | |
139 ;;; mode: C++ *** | |
140 ;;; End: *** | |
141 */ |