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 #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 |
|
39 octave_fcn_handle : public octave_base_value |
4654
|
40 { |
|
41 public: |
4930
|
42 octave_fcn_handle (void) |
4933
|
43 : fcn (), nm () { } |
4654
|
44 |
5007
|
45 octave_fcn_handle (const std::string& n) |
|
46 : fcn (), nm (n) { } |
|
47 |
4930
|
48 octave_fcn_handle (const octave_value& f, const std::string& n) |
4933
|
49 : fcn (f), nm (n) { } |
4654
|
50 |
4967
|
51 octave_fcn_handle (const octave_fcn_handle& fh) |
|
52 : octave_base_value (fh), fcn (fh.fcn), nm (fh.nm) { } |
|
53 |
4654
|
54 ~octave_fcn_handle (void) { } |
|
55 |
4967
|
56 octave_value *clone (void) const { return new octave_fcn_handle (*this); } |
|
57 octave_value *empty_clone (void) const { return new octave_fcn_handle (); } |
|
58 |
4924
|
59 octave_value subsref (const std::string&, |
|
60 const std::list<octave_value_list>&) |
|
61 { |
|
62 panic_impossible (); |
|
63 return octave_value (); |
|
64 } |
|
65 |
|
66 octave_value_list subsref (const std::string& type, |
|
67 const std::list<octave_value_list>& idx, |
|
68 int nargout); |
|
69 |
4925
|
70 bool is_defined (void) const { return true; } |
4654
|
71 |
|
72 bool is_function_handle (void) const { return true; } |
|
73 |
4930
|
74 octave_function *function_value (bool = false) |
|
75 { return fcn.function_value (); } |
|
76 |
4654
|
77 octave_fcn_handle *fcn_handle_value (bool = false) { return this; } |
|
78 |
5007
|
79 octave_value fcn_val (void) const { return fcn; } |
|
80 |
4933
|
81 std::string fcn_name (void) const { return nm; } |
4930
|
82 |
4988
|
83 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
84 bool strip_nan_and_inf); |
|
85 |
|
86 bool load_ascii (std::istream& is); |
|
87 |
|
88 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
89 |
|
90 bool load_binary (std::istream& is, bool swap, |
|
91 oct_mach_info::float_format fmt); |
|
92 |
|
93 #if defined (HAVE_HDF5) |
|
94 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
95 |
|
96 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
97 #endif |
|
98 |
4654
|
99 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
100 |
|
101 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
102 |
|
103 private: |
4343
|
104 |
4612
|
105 DECLARE_OCTAVE_ALLOCATOR |
4343
|
106 |
4612
|
107 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
4925
|
108 |
4933
|
109 protected: |
4930
|
110 |
4925
|
111 // The function we are handling. |
4930
|
112 octave_value fcn; |
4925
|
113 |
|
114 // The name of the handle, including the "@". |
|
115 std::string nm; |
4343
|
116 }; |
|
117 |
|
118 extern octave_value make_fcn_handle (const std::string& nm); |
|
119 |
|
120 #endif |
|
121 |
|
122 /* |
|
123 ;;; Local Variables: *** |
|
124 ;;; mode: C++ *** |
|
125 ;;; End: *** |
|
126 */ |