STK++ 0.9.13
STK_Cell.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004 Serge Iovleff
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...) */
23
24/*
25 * Project: stkpp::DManager
26 * Purpose: Define the template CellBase, CellVe and CellHo classes.
27 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
28 *
29 **/
30
35#ifndef STK_CELL_H
36#define STK_CELL_H
37
38namespace STK
39{
46template<class Type>
48{
49 protected:
50 Type data_;
51
52 public:
54 CellBase() : data_(Type()) {}
56 CellBase( Type const& data): data_(data)
57 {}
62 virtual ~CellBase() {}
65 { data_ = C.data_; return *this;}
68 { data_ = v; return *this;}
70 inline Type const& data() const { return data_;}
72 inline Type& data() { return data_;}
74 void setData(Type const& data) { data_ = data;}
75};
76
82template<class Type>
83class CellVe : virtual public CellBase<Type>
84{
85 using STK::CellBase<Type>::data_;
86
87 protected:
90
91 public:
94
98 , Type const& data);
99
101 CellVe(const CellVe<Type> &C);
102
104 virtual ~CellVe();
105
108
110 CellVe<Type>& operator=(Type const& v);
111
113 CellVe<Type>* getUp() const;
114
116 CellVe<Type>* getDown() const;
117
119 void setUp(CellVe<Type>* pcell);
120
123};
124
130template<class Type>
131class CellHo : virtual public CellBase<Type>
132{
133 // needed for template classes
134 using STK::CellBase<Type>::data_;
135
136 protected:
139
140 public:
144
147 : CellBase<Type>(data)
148 { left_ = left; right_ = right; }
149
152 : CellBase<Type>(C)
153 , left_(C.left_)
154 , right_(C.right_)
155 { ;}
156
158 virtual ~CellHo() { ;}
159
162 { data_ = C.data_;
163 left_ = C.left_;
164 right_ = C.right_;
165 return *this;
166 }
167
170 { data_ = v;
171 return *this;
172 }
173
176 { return left_;}
177
180 { return right_;}
181
184 { left_ = left;}
185
189};
190
195template<class Type>
196class Cell2D : virtual public CellVe<Type>
197 , virtual public CellHo<Type>
198{
199 using STK::CellBase<Type>::data_;
200 using STK::CellHo<Type>::up_;
201 using STK::CellHo<Type>::down_;
202 using STK::CellVe<Type>::left_;
203 using STK::CellVe<Type>::right_;
204
205 public:
207 Cell2D( const Cell2D<Type>* left =NULL
208 , const Cell2D<Type>* up =NULL
209 , const Cell2D<Type>* right =NULL
210 , const Cell2D<Type>* down =NULL);
211
213 Cell2D( const Cell2D<Type>* left
214 , const Cell2D<Type>* up
215 , const Cell2D<Type>* right
216 , const Cell2D<Type>* down
217 , Type const& data);
218
220 Cell2D(const Cell2D<Type> &C);
221
223 virtual ~Cell2D();
224
227
229 Cell2D<Type>& operator=(Type const& v);
230};
231
232// Constructor with a pointer on the data
233template<class Type>
238
239// Constructor with a reference to the data
240template<class Type>
243 , Type const& data)
244 : CellBase<Type>(data)
245{ up_ = up; down_ = down; }
246
247// Copy Constructor.
248template<class Type>
250{ data_ = C.data_; up_ = C.up_; down_ = C.down_; }
251
252/* virtual destructor. */
253template<class Type>
255
256/* operator = : overwrite the Cell with C. */
257template<class Type>
260{ data_ = C.data_; up_ = C.up_; down_ = C.down_;
261 return *this;
262}
263
264/* operator = : overwrite the data with v. */
265template<class Type>
267{ data_ = v;
268 return *this;
269}
270
271/* Accessors. */
272template<class Type>
274{ return up_;}
275
276// Give the adress of the cell down
277template<class Type>
279{ return down_;}
280
281// Set the adress of the cell up
282template<class Type>
285
286// Set the adress of the cell down
287template<class Type>
290
291// Constructor with a pointer on the data
292template<class Type>
294 , const Cell2D<Type>* up
295 , const Cell2D<Type>* right
296 , const Cell2D<Type>* down)
297 : CellBase<Type>()
298 , CellHo<Type>(left, right)
299 , CellVe<Type>(up, down)
300{ ;}
301
302// Constructor with a reference to the data
303template<class Type>
305 , const Cell2D<Type>* up
306 , const Cell2D<Type>* right
307 , const Cell2D<Type>* down
308 , Type const& data)
309 : CellBase<Type>(data)
310 , CellHo<Type>(left, right)
311 , CellVe<Type>(up, down)
312{ ;}
313
314// Copy Constructor.
315template<class Type>
317{ data_ = C.data_;
318 up_ = C.up_;
319 down_ = C.down_;
320 left_ = C.left_;
321 right_ = C.right_;
322}
323
324/* virtual destructor. */
325template<class Type>
327
328/* operator = : overwrite the Cell with C. */
329template<class Type>
332{ data_ = C.data_;
333 up_ = C.up_;
334 down_ = C.down_;
335 left_ = C.left_;
336 right_ = C.right_;
337}
338
339/* operator = : overwrite the data with v. */
340template<class Type>
342{ data_ = v;}
343
344
345} // namespace STK
346
347#endif
348// STK_CELL_H
template class for the 2 Dimensional Cells.
Definition STK_Cell.h:198
Cell2D(const Cell2D< Type > *left=NULL, const Cell2D< Type > *up=NULL, const Cell2D< Type > *right=NULL, const Cell2D< Type > *down=NULL)
Default constructor with a pointer on the data.
Definition STK_Cell.h:293
Cell2D< Type > & operator=(const Cell2D< Type > &C)
operator = : overwrite the Cell with C.
Definition STK_Cell.h:331
virtual ~Cell2D()
virtual destructor.
Definition STK_Cell.h:326
template Base class for the Cell in a list .
Definition STK_Cell.h:48
virtual ~CellBase()
virtual destructor.
Definition STK_Cell.h:62
CellBase< Type > & operator=(Type const &v)
Operator = : write a value on the cell.
Definition STK_Cell.h:67
Type const & data() const
Definition STK_Cell.h:70
CellBase()
constructor with a pointer on the data.
Definition STK_Cell.h:54
Type & data()
Definition STK_Cell.h:72
void setData(Type const &data)
Set data.
Definition STK_Cell.h:74
Type data_
Data contained by the Cell.
Definition STK_Cell.h:50
CellBase< Type > & operator=(const CellBase< Type > &C)
Operator = : overwrite the Cell with C.
Definition STK_Cell.h:64
CellBase(const CellBase< Type > &C)
Copy constructor.
Definition STK_Cell.h:59
CellBase(Type const &data)
constructor with a reference to the data.
Definition STK_Cell.h:56
template class for the Horizontal Cell of a Horizontal List.
Definition STK_Cell.h:132
void setRight(CellHo< Type > *right)
Set the right cell adress.
Definition STK_Cell.h:187
CellHo< Type > & operator=(Type const &v)
operator = : write a value on the cell.
Definition STK_Cell.h:169
void setLeft(CellHo< Type > *left)
Set the left cell adress.
Definition STK_Cell.h:183
CellHo< Type > * left_
pointer on the left cell
Definition STK_Cell.h:137
CellHo< Type > * right_
pointer on the right cell
Definition STK_Cell.h:138
virtual ~CellHo()
virtual destructor.
Definition STK_Cell.h:158
CellHo(CellHo< Type > *left=NULL, CellHo< Type > *right=NULL)
Default constructor
Definition STK_Cell.h:142
CellHo< Type > * getRight() const
Give the adress of the cell right.
Definition STK_Cell.h:179
CellHo< Type > & operator=(const CellHo< Type > &C)
Operator = : overwrite the Cell with C.
Definition STK_Cell.h:161
CellHo(CellHo< Type > *left, CellHo< Type > *right, Type const &data)
constructor with a reference to the data.
Definition STK_Cell.h:146
CellHo(const CellHo< Type > &C)
Copy constructor
Definition STK_Cell.h:151
CellHo< Type > * getLeft() const
Give the adress of the cell left.
Definition STK_Cell.h:175
template class for the Vertical Cell of a Vertical List.
Definition STK_Cell.h:84
CellVe< Type > * getUp() const
Give the adress of the cell up.
Definition STK_Cell.h:273
CellVe< Type > * getDown() const
Give the adress of the cell down.
Definition STK_Cell.h:278
CellVe< Type > * up_
pointer on the upper cell
Definition STK_Cell.h:88
CellVe< Type > * down_
pointer on the cell down
Definition STK_Cell.h:89
void setUp(CellVe< Type > *pcell)
Set the adress of the cell up.
Definition STK_Cell.h:283
CellVe(CellVe< Type > *up=0, CellVe< Type > *down=0)
Default constructor.
Definition STK_Cell.h:234
virtual ~CellVe()
Virtual destructor.
Definition STK_Cell.h:254
void setDown(CellVe< Type > *pcell)
Set the adress of the cell down.
Definition STK_Cell.h:288
CellVe< Type > & operator=(const CellVe< Type > &C)
Operator = : overwrite the Cell with C.
Definition STK_Cell.h:259
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
The namespace STK is the main domain space of the Statistical ToolKit project.