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 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
|
32 #include <string> |
|
33 |
|
34 class ostream; |
|
35 |
|
36 #include "lo-mappers.h" |
|
37 #include "lo-utils.h" |
|
38 #include "oct-alloc.h" |
|
39 #include "str-vec.h" |
|
40 |
|
41 #include "ov-base.h" |
|
42 #include "ov-typeinfo.h" |
|
43 |
|
44 // Real scalar values. |
|
45 |
|
46 template <class ST> |
|
47 class |
|
48 octave_base_scalar : public octave_base_value |
|
49 { |
|
50 public: |
|
51 |
|
52 octave_base_scalar (void) |
|
53 : octave_base_value () { } |
|
54 |
|
55 octave_base_scalar (ST s) |
|
56 : octave_base_value (), scalar (s) { } |
|
57 |
|
58 octave_base_scalar (const octave_base_scalar& s) |
|
59 : octave_base_value (), scalar (s.scalar) { } |
|
60 |
|
61 ~octave_base_scalar (void) { } |
|
62 |
|
63 int rows (void) const { return 1; } |
|
64 |
|
65 int columns (void) const { return 1; } |
|
66 |
|
67 int length (void) const { return 1; } |
|
68 |
|
69 bool is_constant (void) const { return true; } |
|
70 |
|
71 bool is_defined (void) const { return true; } |
|
72 |
|
73 octave_value all (void) const { return (scalar != 0.0); } |
|
74 |
|
75 octave_value any (void) const { return (scalar != 0.0); } |
|
76 |
|
77 bool is_scalar_type (void) const { return true; } |
|
78 |
|
79 bool is_numeric_type (void) const { return true; } |
|
80 |
|
81 bool is_true (void) const { return (scalar != 0.0); } |
|
82 |
|
83 void print (ostream& os, bool pr_as_read_syntax = false) const; |
|
84 |
|
85 void print_raw (ostream& os, bool pr_as_read_syntax = false) const; |
|
86 |
|
87 bool print_name_tag (ostream& os, const string& name) const; |
|
88 |
|
89 protected: |
|
90 |
|
91 // The value of this scalar. |
|
92 ST scalar; |
|
93 }; |
|
94 |
|
95 #endif |
|
96 |
|
97 /* |
|
98 ;;; Local Variables: *** |
|
99 ;;; mode: C++ *** |
|
100 ;;; End: *** |
|
101 */ |