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