3353
|
1 /* |
|
2 |
|
3 Copyright (C) 1999 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 (Cell_h) |
|
24 #define Cell_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <string> |
|
31 |
|
32 #include "Array2.h" |
|
33 #include "oct-alloc.h" |
|
34 #include "str-vec.h" |
|
35 |
|
36 #include "ov.h" |
|
37 |
|
38 class |
|
39 Cell |
|
40 { |
|
41 public: |
|
42 |
|
43 Cell (void) |
|
44 : data () { } |
|
45 |
|
46 Cell (int n, int m, const octave_value& val = octave_value ()) |
|
47 : data (n, m, val) { } |
|
48 |
|
49 Cell (const Cell& c) |
|
50 : data (c.data) { } |
|
51 |
|
52 void *operator new (size_t size) |
|
53 { return allocator.alloc (size); } |
|
54 |
|
55 void operator delete (void *p, size_t size) |
|
56 { allocator.free (p, size); } |
|
57 |
|
58 Cell& operator = (const Cell& c) |
|
59 { |
|
60 if (this != &c) |
|
61 data = c.data; |
|
62 |
|
63 return *this; |
|
64 } |
|
65 |
|
66 int rows (void) const { return data.rows (); } |
|
67 |
|
68 int columns (void) const { return data.columns (); } |
|
69 |
|
70 octave_value& operator () (int i, int j) { return elem (i, j); } |
|
71 |
|
72 octave_value operator () (int i, int j) const { return elem (i, j); } |
|
73 |
|
74 octave_value& elem (int i, int j) { return data.elem (i, j); } |
|
75 |
|
76 octave_value elem (int i, int j) const { return data.elem (i, j); } |
|
77 |
|
78 private: |
|
79 |
|
80 static octave_allocator allocator; |
|
81 |
|
82 Array2<octave_value> data; |
|
83 }; |
|
84 |
|
85 #endif |
|
86 |
|
87 /* |
|
88 ;;; Local Variables: *** |
|
89 ;;; mode: C++ *** |
|
90 ;;; End: *** |
|
91 */ |