3278
|
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_base_scalar_h) |
|
24 #define octave_base_scalar_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
3278
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
3278
|
33 #include <string> |
|
34 |
|
35 #include "lo-mappers.h" |
|
36 #include "lo-utils.h" |
|
37 #include "oct-alloc.h" |
|
38 #include "str-vec.h" |
|
39 |
|
40 #include "ov-base.h" |
|
41 #include "ov-typeinfo.h" |
|
42 |
|
43 // Real scalar values. |
|
44 |
|
45 template <class ST> |
|
46 class |
|
47 octave_base_scalar : public octave_base_value |
|
48 { |
|
49 public: |
|
50 |
|
51 octave_base_scalar (void) |
|
52 : octave_base_value () { } |
|
53 |
3775
|
54 octave_base_scalar (const ST& s) |
3278
|
55 : octave_base_value (), scalar (s) { } |
|
56 |
|
57 octave_base_scalar (const octave_base_scalar& s) |
|
58 : octave_base_value (), scalar (s.scalar) { } |
|
59 |
|
60 ~octave_base_scalar (void) { } |
|
61 |
4247
|
62 octave_value subsref (const std::string& type, |
4219
|
63 const std::list<octave_value_list>& idx); |
3933
|
64 |
4661
|
65 octave_value_list subsref (const std::string&, |
|
66 const std::list<octave_value_list>&, int) |
4271
|
67 { |
|
68 panic_impossible (); |
|
69 return octave_value_list (); |
|
70 } |
|
71 |
4247
|
72 octave_value subsasgn (const std::string& type, |
4219
|
73 const std::list<octave_value_list>& idx, |
3933
|
74 const octave_value& rhs); |
|
75 |
3278
|
76 bool is_constant (void) const { return true; } |
|
77 |
|
78 bool is_defined (void) const { return true; } |
|
79 |
4563
|
80 dim_vector dims (void) const { static dim_vector dv (1, 1); return dv; } |
|
81 |
4017
|
82 octave_value all (int = 0) const { return (scalar != 0.0); } |
3278
|
83 |
4017
|
84 octave_value any (int = 0) const { return (scalar != 0.0); } |
3278
|
85 |
|
86 bool is_scalar_type (void) const { return true; } |
|
87 |
|
88 bool is_numeric_type (void) const { return true; } |
|
89 |
|
90 bool is_true (void) const { return (scalar != 0.0); } |
|
91 |
3523
|
92 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
3278
|
93 |
3523
|
94 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
3278
|
95 |
3523
|
96 bool print_name_tag (std::ostream& os, const std::string& name) const; |
3278
|
97 |
|
98 protected: |
|
99 |
|
100 // The value of this scalar. |
|
101 ST scalar; |
|
102 }; |
|
103 |
|
104 #endif |
|
105 |
|
106 /* |
|
107 ;;; Local Variables: *** |
|
108 ;;; mode: C++ *** |
|
109 ;;; End: *** |
|
110 */ |