4343
|
1 /* |
|
2 |
|
3 Copyright (C) 2003 John W. Eaton |
|
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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_fcn_handle_h) |
|
24 #define octave_fcn_handle_h 1 |
|
25 |
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <iostream> |
|
31 #include <string> |
|
32 |
|
33 #include "oct-alloc.h" |
|
34 |
|
35 #include "ov-base.h" |
4654
|
36 #include "ov-base-mat.h" |
4343
|
37 #include "ov-fcn.h" |
4654
|
38 #include "ov-typeinfo.h" |
4343
|
39 |
|
40 // Function handles. |
|
41 |
4925
|
42 class |
|
43 octave_fcn_handle : public octave_base_value |
4654
|
44 { |
|
45 public: |
4930
|
46 octave_fcn_handle (void) |
4933
|
47 : fcn (), nm () { } |
4654
|
48 |
5007
|
49 octave_fcn_handle (const std::string& n) |
|
50 : fcn (), nm (n) { } |
|
51 |
4930
|
52 octave_fcn_handle (const octave_value& f, const std::string& n) |
4933
|
53 : fcn (f), nm (n) { } |
4654
|
54 |
4967
|
55 octave_fcn_handle (const octave_fcn_handle& fh) |
|
56 : octave_base_value (fh), fcn (fh.fcn), nm (fh.nm) { } |
|
57 |
4654
|
58 ~octave_fcn_handle (void) { } |
|
59 |
4967
|
60 octave_value *clone (void) const { return new octave_fcn_handle (*this); } |
|
61 octave_value *empty_clone (void) const { return new octave_fcn_handle (); } |
|
62 |
4924
|
63 octave_value subsref (const std::string&, |
|
64 const std::list<octave_value_list>&) |
|
65 { |
|
66 panic_impossible (); |
|
67 return octave_value (); |
|
68 } |
|
69 |
|
70 octave_value_list subsref (const std::string& type, |
|
71 const std::list<octave_value_list>& idx, |
|
72 int nargout); |
|
73 |
4925
|
74 bool is_defined (void) const { return true; } |
4654
|
75 |
|
76 bool is_function_handle (void) const { return true; } |
|
77 |
4930
|
78 octave_function *function_value (bool = false) |
|
79 { return fcn.function_value (); } |
|
80 |
4654
|
81 octave_fcn_handle *fcn_handle_value (bool = false) { return this; } |
|
82 |
5007
|
83 octave_value fcn_val (void) const { return fcn; } |
|
84 |
4933
|
85 std::string fcn_name (void) const { return nm; } |
4930
|
86 |
4988
|
87 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
88 bool strip_nan_and_inf); |
|
89 |
|
90 bool load_ascii (std::istream& is); |
|
91 |
|
92 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
93 |
|
94 bool load_binary (std::istream& is, bool swap, |
|
95 oct_mach_info::float_format fmt); |
|
96 |
|
97 #if defined (HAVE_HDF5) |
|
98 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
99 |
|
100 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
101 #endif |
|
102 |
4654
|
103 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
104 |
|
105 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
106 |
|
107 private: |
4343
|
108 |
4612
|
109 DECLARE_OCTAVE_ALLOCATOR |
4343
|
110 |
4612
|
111 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
4925
|
112 |
4933
|
113 protected: |
4930
|
114 |
4925
|
115 // The function we are handling. |
4930
|
116 octave_value fcn; |
4925
|
117 |
|
118 // The name of the handle, including the "@". |
|
119 std::string nm; |
4343
|
120 }; |
|
121 |
|
122 extern octave_value make_fcn_handle (const std::string& nm); |
|
123 |
|
124 #endif |
|
125 |
|
126 /* |
|
127 ;;; Local Variables: *** |
|
128 ;;; mode: C++ *** |
|
129 ;;; End: *** |
|
130 */ |