2974
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 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_mapper_h) |
|
24 #define octave_mapper_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <string> |
|
31 |
|
32 #include "ov-fcn.h" |
|
33 #include "ov-typeinfo.h" |
|
34 |
|
35 class octave_value; |
|
36 class octave_value_list; |
|
37 |
|
38 // Builtin mapper functions. |
|
39 |
|
40 class |
|
41 octave_mapper : public octave_function |
|
42 { |
|
43 public: |
|
44 |
|
45 typedef int (*ch_mapper) (int); |
3249
|
46 typedef bool (*d_b_mapper) (double); |
|
47 typedef bool (*c_b_mapper) (const Complex&); |
2974
|
48 typedef double (*d_d_mapper) (double); |
|
49 typedef double (*d_c_mapper) (const Complex&); |
|
50 typedef Complex (*c_c_mapper) (const Complex&); |
|
51 |
3249
|
52 octave_mapper (ch_mapper ch, d_b_mapper db, c_b_mapper cb, |
|
53 d_d_mapper dd, d_c_mapper dc, |
2974
|
54 c_c_mapper cc, double ll, double ul, int f, |
|
55 const string& nm = string (), |
|
56 const string& ds = string ()) |
3249
|
57 : octave_function (nm, ds), ch_map_fcn (ch), |
|
58 d_b_map_fcn (db), c_b_map_fcn (cb), |
|
59 d_d_map_fcn (dd), d_c_map_fcn (dc), c_c_map_fcn (cc), |
2974
|
60 lower_limit (ll), upper_limit (ul), flag (f) { } |
|
61 |
|
62 ~octave_mapper (void) { } |
|
63 |
|
64 octave_function *function_value (bool) { return this; } |
|
65 |
|
66 octave_value_list do_index_op (int nargout, const octave_value_list& args); |
|
67 |
|
68 private: |
|
69 |
|
70 octave_mapper (void); |
|
71 |
|
72 octave_mapper (const octave_mapper& m); |
|
73 |
|
74 octave_value apply (const octave_value& arg) const; |
|
75 |
|
76 // ch_map_fcn is a kluge. |
|
77 |
|
78 ch_mapper ch_map_fcn; |
3249
|
79 d_b_mapper d_b_map_fcn; |
|
80 c_b_mapper c_b_map_fcn; |
2974
|
81 d_d_mapper d_d_map_fcn; |
|
82 d_c_mapper d_c_map_fcn; |
|
83 c_c_mapper c_c_map_fcn; |
|
84 |
|
85 // If flag is nonzero and we are not calling ch_map_fcn, lower_limit |
|
86 // and upper_limit specify the range of values for which a real arg |
|
87 // returns a real value. Outside that range, we have to convert args |
|
88 // to complex, and call the complex valued function. |
|
89 |
|
90 double lower_limit; |
|
91 double upper_limit; |
|
92 |
|
93 // For ch_map_fcn, flag has the following meanings: |
|
94 // |
|
95 // 0 => this function returns a matrix of ones and zeros |
|
96 // 1 => this function returns a numeric matrix (any values) |
|
97 // 2 => this function returns a string array |
|
98 // |
|
99 // For other mappers, nonzero means that this function can return a |
|
100 // complex value for some real arguments. |
|
101 |
|
102 int flag; |
|
103 |
3219
|
104 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2974
|
105 |
3219
|
106 DECLARE_OCTAVE_ALLOCATOR |
2974
|
107 }; |
|
108 |
|
109 #endif |
|
110 |
|
111 /* |
|
112 ;;; Local Variables: *** |
|
113 ;;; mode: C++ *** |
|
114 ;;; End: *** |
|
115 */ |