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 |
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 |
|
54 octave_base_scalar (ST s) |
|
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 |
|
62 int rows (void) const { return 1; } |
|
63 |
|
64 int columns (void) const { return 1; } |
|
65 |
|
66 int length (void) const { return 1; } |
|
67 |
|
68 bool is_constant (void) const { return true; } |
|
69 |
|
70 bool is_defined (void) const { return true; } |
|
71 |
|
72 octave_value all (void) const { return (scalar != 0.0); } |
|
73 |
|
74 octave_value any (void) const { return (scalar != 0.0); } |
|
75 |
|
76 bool is_scalar_type (void) const { return true; } |
|
77 |
|
78 bool is_numeric_type (void) const { return true; } |
|
79 |
|
80 bool is_true (void) const { return (scalar != 0.0); } |
|
81 |
3523
|
82 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
3278
|
83 |
3523
|
84 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
3278
|
85 |
3523
|
86 bool print_name_tag (std::ostream& os, const std::string& name) const; |
3278
|
87 |
|
88 protected: |
|
89 |
|
90 // The value of this scalar. |
|
91 ST scalar; |
|
92 }; |
|
93 |
|
94 #endif |
|
95 |
|
96 /* |
|
97 ;;; Local Variables: *** |
|
98 ;;; mode: C++ *** |
|
99 ;;; End: *** |
|
100 */ |