Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

datanode.h

Go to the documentation of this file.
00001 
00002 //****************************************************
00003 //  April, 1993, University of Illinois
00004 // Copyright (C) 1993, 1994 Tianlin Wang
00005 /* Copyright (C) 1994-2003 Matvec Development Team. 
00006 
00007   This program is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Library General Public
00009   License as published by the Free Software Foundation; either
00010   version 2 of the License, or (at your option) any later version.
00011   
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Library General Public License for more details.
00016     
00017   You should have received a copy of the GNU Library General Public
00018   License along with this library; if not, write to the Free
00019   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00020   MA 02111-1307, USA 
00021 */
00022 
00023 #ifndef DATANODE_H
00024 #define DATANODE_H
00025 
00026 namespace matvec {
00027 /*!
00028   \class DataNode  DataNode.h
00029   \brief a node in a data structure
00030 
00031   \sa Data
00032 */
00033 class DataNode {
00034    friend class Individual;
00035    friend class Field;
00036    protected:
00037       union {
00038          int       int_value;
00039          double    double_value;
00040          unsigned  unsigned_value;
00041       } data;
00042 
00043       void copyfrom(const DataNode& A);
00044 
00045    public:
00046       int  missing;
00047 
00048       DataNode(void) {missing=1;}              // missing is the default
00049       DataNode(const DataNode& A);             // copy constructor
00050 
00051       friend std::ostream&  operator<<(std::ostream& stream, const DataNode& A);
00052 
00053       const DataNode&  operator=(const DataNode& A);
00054       const DataNode&  operator=(const double x) {data.double_value = x;
00055                                                   missing = 0; return *this;}
00056 
00057       const DataNode&  operator=(const int x) {data.int_value = x; missing=0;
00058                                                return *this;}
00059 
00060       const DataNode&  operator=(const unsigned x) {data.unsigned_value=x;
00061                                                     missing=0; return *this;}
00062       const DataNode&  operator+=(const double x) {data.double_value += x;
00063                                                    return *this;}
00064       const DataNode&  operator-=(const double x) {data.double_value -= x;
00065                                                    return *this;}
00066       const DataNode&  operator*=(const double x) {data.double_value *= x;
00067                                                    return *this;}
00068       const DataNode&  operator/=(const double x) {data.double_value /= x;
00069                                                    return *this;}
00070 
00071       const DataNode&  operator+=(const int x) {data.int_value += x;
00072                                                 return *this;}
00073       const DataNode&  operator-=(const int x) {data.int_value -= x;
00074                                                 return *this;}
00075       const DataNode&  operator*=(const int x) {data.int_value *= x;
00076                                                 return *this;}
00077       const DataNode&  operator/=(const int x) {data.int_value /= x;
00078                                                 return *this;}
00079 
00080       const DataNode&  operator+=(const unsigned x) {data.unsigned_value += x;
00081                                                      return *this;}
00082       const DataNode&  operator-=(const unsigned x) {data.unsigned_value -= x;
00083                                                      return *this;}
00084       const DataNode&  operator*=(const unsigned x) {data.unsigned_value *= x;
00085                                                      return *this;}
00086       const DataNode&  operator/=(const unsigned x) {data.unsigned_value /= x;
00087                                                      return *this;}
00088 
00089       void     double_val(const double x) {data.double_value=x; missing=0;}
00090       void     int_val(const int x) {data.int_value = x; missing=0;}
00091       void     unsigned_val(const unsigned x){data.unsigned_value=x; missing=0;}
00092       double   double_val(void) const {return data.double_value;}
00093       int      int_val(void) const {return data.int_value;}
00094       unsigned unsigned_val(void) const {return data.unsigned_value;}
00095 };
00096 
00097 }
00098 #endif

Generated on Thu Jun 16 17:13:38 2005 for Matvec by doxygen1.2.16