00001 /***************************************************************************** 00002 * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch) 00003 ***************************************************************************** 00004 * Project : Zeus Base Library 00005 * Module : ZValueType 00006 * Package : Zeus.ZeusBase.System 00007 * Author : Benjamin Hadorn 00008 * Date : 27.12.2011 00009 * System : Zeus-Framework 00010 ***************************************************************************** 00011 * Licence: * 00012 * This library is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU Lesser General Public License as * 00014 * published by the Free Software Foundation; either version * 00015 * 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 * Changes: 00029 * 27.12.2011 bha: created zeus 2.0 00030 *****************************************************************************/ 00031 00032 #ifndef ZValueTypeH 00033 #define ZValueTypeH 00034 00035 #include <zeusbase/System/ZObject.h> 00036 00037 BEGIN_NAMESPACE_Zeus 00038 00039 /*****************************************************************************/ 00042 /*****************************************************************************/ 00043 template <class T> class TZValueType : public TZObject 00044 { 00045 public: 00046 TZValueType(); 00047 TZValueType(const TZValueType<T>& rValue); 00048 TZValueType(T tValue); 00049 virtual ~TZValueType(); 00050 00051 T& getValue(); 00052 const T& getValue() const; 00053 00054 //Operators 00055 TZValueType<T>& operator =(const TZValueType<T>& rInVal); 00056 TZValueType<T>& operator =(const T tValue); 00057 bool operator ==(const TZValueType<T>& rValue)const; 00058 bool operator ==(const T tValue)const; 00059 bool operator !=(const TZValueType<T>& rValue)const; 00060 bool operator !=(const T tValue)const; 00061 T operator+ (const TZValueType<T>& rValue) const; 00062 T operator+ (const T tValue) const; 00063 T operator- (const TZValueType<T>& rValue) const; 00064 T operator- (const T tValue) const; 00065 T operator* (const TZValueType<T>& rValue) const; 00066 T operator* (const T tValue) const; 00067 T operator/ (const TZValueType<T>& rValue) const; 00068 T operator/ (const T tValue) const; 00069 T& operator+= (const TZValueType<T>& rValue); 00070 T& operator+= (const T tValue); 00071 T& operator-= (const TZValueType<T>& rValue); 00072 T& operator-= (const T tValue); 00073 T& operator*= (const TZValueType<T>& rValue); 00074 T& operator*= (const T tValue); 00075 T& operator/= (const TZValueType<T>& rValue); 00076 T& operator/= (const T tValue); 00077 T& operator * (); 00078 const T& operator * () const; 00079 00080 protected: 00082 T m_tValue; 00083 }; 00084 00085 00086 /****************************************************************************/ 00089 /****************************************************************************/ 00090 template <class T> inline TZValueType<T>::TZValueType() 00091 : TZObject(), 00092 m_tValue(T()) 00093 {} 00094 00095 /**************************************************************************/ 00098 /**************************************************************************/ 00099 template <class T> inline TZValueType<T>::TZValueType(const TZValueType<T>& rValue) 00100 : TZObject(), 00101 m_tValue(rValue.m_tValue) 00102 {} 00103 00104 /**************************************************************************/ 00107 /**************************************************************************/ 00108 template <class T> inline TZValueType<T>::TZValueType(T tValue) 00109 : TZObject(), 00110 m_tValue(tValue) 00111 { 00112 } 00113 00114 /**************************************************************************/ 00117 /**************************************************************************/ 00118 template <class T> inline TZValueType<T>::~TZValueType() 00119 {} 00120 00121 /**************************************************************************/ 00124 /**************************************************************************/ 00125 template <class T> inline T& TZValueType<T>::getValue() 00126 { 00127 return m_tValue; 00128 } 00129 00130 /**************************************************************************/ 00133 /**************************************************************************/ 00134 template <class T> inline const T& TZValueType<T>::getValue() const 00135 { 00136 return m_tValue; 00137 } 00138 00139 /**************************************************************************/ 00142 /**************************************************************************/ 00143 template <class T> inline TZValueType<T>& TZValueType<T>::operator =(const TZValueType<T>& rInVal) 00144 { 00145 m_tValue = rInVal.m_tValue; 00146 return *this; 00147 } 00148 00149 /**************************************************************************/ 00152 /**************************************************************************/ 00153 template <class T> inline TZValueType<T>& TZValueType<T>::operator =(const T tValue) 00154 { 00155 m_tValue = tValue; 00156 return *this; 00157 } 00158 00159 /**************************************************************************/ 00162 /**************************************************************************/ 00163 template <class T> inline bool TZValueType<T>::operator ==(const TZValueType<T>& rValue)const 00164 { 00165 return (m_tValue == rValue.m_tValue); 00166 } 00167 00168 /**************************************************************************/ 00171 /**************************************************************************/ 00172 template <class T> inline bool TZValueType<T>::operator ==(const T tValue)const 00173 { 00174 return (m_tValue == tValue); 00175 } 00176 00177 /**************************************************************************/ 00180 /**************************************************************************/ 00181 template <class T> inline bool TZValueType<T>::operator !=(const TZValueType<T>& rValue)const 00182 { 00183 return (m_tValue != rValue.m_tValue); 00184 } 00185 00186 /**************************************************************************/ 00189 /**************************************************************************/ 00190 template <class T> inline bool TZValueType<T>::operator !=(const T tValue)const 00191 { 00192 return !(m_tValue != tValue); 00193 } 00194 00195 /**************************************************************************/ 00199 /**************************************************************************/ 00200 template <class T> inline T TZValueType<T>::operator+ (const TZValueType<T>& rValue) const 00201 { 00202 return m_tValue + rValue.m_tValue; 00203 } 00204 00205 /**************************************************************************/ 00209 /**************************************************************************/ 00210 template <class T> inline T TZValueType<T>::operator+ (const T tValue) const 00211 { 00212 return m_tValue + tValue; 00213 } 00214 00215 /**************************************************************************/ 00218 /**************************************************************************/ 00219 template <class T> inline T TZValueType<T>::operator- (const TZValueType<T>& rValue) const 00220 { 00221 return m_tValue - rValue.m_tValue; 00222 } 00223 00224 /**************************************************************************/ 00227 /**************************************************************************/ 00228 template <class T> inline T TZValueType<T>::operator- (const T tValue) const 00229 { 00230 return m_tValue - tValue; 00231 } 00232 00233 /**************************************************************************/ 00236 /**************************************************************************/ 00237 template <class T> inline T TZValueType<T>::operator* (const TZValueType<T>& rValue) const 00238 { 00239 return m_tValue * rValue.m_tValue; 00240 } 00241 00242 /**************************************************************************/ 00245 /**************************************************************************/ 00246 template <class T> inline T TZValueType<T>::operator* (const T tValue) const 00247 { 00248 return m_tValue * tValue; 00249 } 00250 00251 /**************************************************************************/ 00254 /**************************************************************************/ 00255 template <class T> inline T TZValueType<T>::operator/ (const TZValueType<T>& rValue) const 00256 { 00257 return m_tValue / rValue.m_tValue; 00258 } 00259 00260 /**************************************************************************/ 00263 /**************************************************************************/ 00264 template <class T> inline T TZValueType<T>::operator/ (const T tValue) const 00265 { 00266 return m_tValue / tValue; 00267 } 00268 00269 /**************************************************************************/ 00272 /**************************************************************************/ 00273 template <class T> inline T& TZValueType<T>::operator+= (const TZValueType<T>& rValue) 00274 { 00275 m_tValue += rValue.m_tValue; 00276 return m_tValue; 00277 } 00278 00279 /**************************************************************************/ 00282 /**************************************************************************/ 00283 template <class T> inline T& TZValueType<T>::operator+= (const T tValue) 00284 { 00285 m_tValue += tValue; 00286 return m_tValue; 00287 } 00288 00289 /**************************************************************************/ 00292 /**************************************************************************/ 00293 template <class T> inline T& TZValueType<T>::operator-= (const TZValueType<T>& rValue) 00294 { 00295 m_tValue -= rValue.m_tValue; 00296 return m_tValue; 00297 } 00298 00299 /**************************************************************************/ 00302 /**************************************************************************/ 00303 template <class T> inline T& TZValueType<T>::operator-= (const T tValue) 00304 { 00305 m_tValue -= tValue; 00306 return m_tValue; 00307 } 00308 00309 /**************************************************************************/ 00312 /**************************************************************************/ 00313 template <class T> inline T& TZValueType<T>::operator*= (const TZValueType<T>& rValue) 00314 { 00315 m_tValue *= rValue.m_tValue; 00316 return m_tValue; 00317 } 00318 00319 /**************************************************************************/ 00322 /**************************************************************************/ 00323 template <class T> inline T& TZValueType<T>::operator*= (const T tValue) 00324 { 00325 m_tValue *= tValue; 00326 return m_tValue; 00327 } 00328 00329 /**************************************************************************/ 00332 /**************************************************************************/ 00333 template <class T> inline T& TZValueType<T>::operator/= (const TZValueType<T>& rValue) 00334 { 00335 m_tValue /= rValue.m_tValue; 00336 return m_tValue; 00337 } 00338 00339 /**************************************************************************/ 00342 /**************************************************************************/ 00343 template <class T> inline T& TZValueType<T>::operator/= (const T tValue) 00344 { 00345 m_tValue /= tValue; 00346 return m_tValue; 00347 } 00348 00349 /**************************************************************************/ 00352 /**************************************************************************/ 00353 template <class T> inline T& TZValueType<T>::operator * () 00354 { 00355 return getValue(); 00356 } 00357 00358 /**************************************************************************/ 00361 /**************************************************************************/ 00362 template <class T> inline const T& TZValueType<T>::operator * () const 00363 { 00364 return getValue(); 00365 } 00366 00367 00368 END_NAMESPACE_Zeus 00369 00370 #endif 00371