00001 /* 00002 ot_lib - Object Type Library 00003 Copyright (C) 2002 Alessandro Bonfanti 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 Alessandro Bonfanti 00020 xjbon@tin.it 00021 */ 00022 00023 00024 #ifndef OT_INT_H 00025 #define OT_INT_H 00026 00027 // ----------------------------------------------------------------------------------- 00029 00030 // ----------------------------------------------------------------------------------- 00031 00032 class ot_int : public ot_num<int> 00033 { 00034 00035 private: 00036 00037 00038 public: 00039 00040 00041 // ######################################### 00042 // CONSTRUCTOR & DESTRUCTOR 00043 // ######################################### 00044 00047 ot_int(int val=0) : ot_num<int>(OT_INT,val) {} 00048 00050 ot_int(const ot_int &c) : ot_num<int>(OT_INT,c.m_value) {} 00051 00052 virtual ~ot_int() {} 00053 00054 // ######################################### 00055 // IMPLEMENTATIONS OF THE VIRTUAL FUNCTIONS 00056 // ######################################### 00057 00058 ot_obj *dup(void) const 00059 { 00060 return(new ot_int(*this)); 00061 } 00062 00063 00064 00065 // ######################################### 00066 // PROPIETARY FUNCTIONS 00067 // ######################################### 00068 00069 00070 // ######################################### 00071 // MATH OPERATOR 00072 // ######################################### 00073 00075 ot_int operator = (const ot_int &c) 00076 { 00077 m_value = c.m_value; 00078 00079 return(*this); 00080 } 00081 00083 bool operator == (const ot_int &c) const 00084 { 00085 if (m_value==c.m_value) return(true); 00086 else return(false); 00087 } 00088 00090 bool operator != (const ot_int &c) 00091 { 00092 return(! (*this==c)); 00093 } 00094 00096 ot_int operator+ (const ot_int &c) const {return(ot_int(m_value + c.m_value));} 00097 00099 ot_int operator- (const ot_int &c) const {return(ot_int(m_value - c.m_value));} 00100 00102 ot_int operator* (const ot_int &c) const {return(ot_int(m_value * c.m_value));} 00103 00105 ot_int operator/ (const ot_int &c) const {return(ot_int(m_value / c.m_value));} 00106 00108 void operator+= (const ot_int &c) {m_value += c.m_value;} 00109 00111 void operator-= (const ot_int &c) {m_value -= c.m_value;} 00112 00114 void operator*= (const ot_int &c) {m_value *= c.m_value;} 00115 00117 void operator/= (const ot_int &c) {m_value /= c.m_value;} 00118 00120 void operator++ (void) {m_value ++;} 00121 00123 void operator-- (void) {m_value --;} 00124 00126 operator int (void) const {return(m_value);} 00127 }; 00128 00129 #endif 00130