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" |
|
36 #include "ov-fcn.h" |
|
37 #include "symtab.h" |
|
38 |
|
39 // Function handles. |
|
40 |
|
41 class |
|
42 octave_fcn_handle : public octave_base_value |
|
43 { |
|
44 public: |
|
45 |
4346
|
46 octave_fcn_handle (octave_function *f, const std::string& n) |
4343
|
47 : fcn (f), nm (n) { } |
|
48 |
|
49 octave_fcn_handle (const octave_fcn_handle& fh) |
|
50 : fcn (fh.fcn), nm (fh.nm) { } |
|
51 |
|
52 octave_fcn_handle& operator = (const octave_fcn_handle& fh) |
|
53 { |
|
54 if (this != &fh) |
|
55 { |
|
56 fcn = fh.fcn; |
|
57 nm = fh.nm; |
|
58 } |
|
59 |
|
60 return *this; |
|
61 } |
|
62 |
|
63 ~octave_fcn_handle (void) { } |
|
64 |
|
65 bool is_defined (void) const { return fcn; } |
|
66 |
|
67 octave_function *function_value (bool) { return fcn; } |
|
68 |
4346
|
69 octave_fcn_handle *fcn_handle_value (bool) { return this; } |
4343
|
70 |
|
71 bool print_as_scalar (void) const { return true; } |
|
72 |
|
73 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
74 |
|
75 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
76 |
|
77 std::string name (void) const { return nm; } |
|
78 |
|
79 private: |
|
80 |
|
81 // The function we are handling. |
|
82 octave_function *fcn; |
|
83 |
|
84 // The name of the handle. |
|
85 std::string nm; |
|
86 |
4612
|
87 DECLARE_OCTAVE_ALLOCATOR |
4343
|
88 |
4612
|
89 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
4343
|
90 }; |
|
91 |
|
92 extern octave_value make_fcn_handle (const std::string& nm); |
|
93 |
|
94 #endif |
|
95 |
|
96 /* |
|
97 ;;; Local Variables: *** |
|
98 ;;; mode: C++ *** |
|
99 ;;; End: *** |
|
100 */ |