From fe1ef6b47f59899e8687bb1dcc92eba1d103a08f Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 10 May 2009 19:48:42 +0200 Subject: making cdat a template --- ue3/mycpu/cdat.cpp | 126 -------------------------------------- ue3/mycpu/cdat.h | 176 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 118 insertions(+), 184 deletions(-) delete mode 100644 ue3/mycpu/cdat.cpp (limited to 'ue3') diff --git a/ue3/mycpu/cdat.cpp b/ue3/mycpu/cdat.cpp deleted file mode 100644 index 455d3bc..0000000 --- a/ue3/mycpu/cdat.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @module cdat - * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) - * @brief TODO - * @date 10.05.2009 - */ - -#include "cdat.h" - - -int CDat::value() const -{ - return m_value; -} - -/*----------------------------------------------------------------------------*/ - -bool CDat::operator<(const CDat& x) const -{ - return m_value < x.m_value; -} - -/*----------------------------------------------------------------------------*/ - -bool CDat::operator==(const CDat& x) const -{ - return m_value == x.m_value; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator+=(const CDat& x) -{ - m_value += x.m_value; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator-=(const CDat& x) -{ - m_value -= x.m_value; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator*=(const CDat& x) -{ - m_value *= x.m_value; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator/=(const CDat& x) -{ - m_value /= x.m_value; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator%=(const CDat& x) -{ - m_value %= x.m_value; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator|=(const CDat& x) -{ - m_value |= x.m_value; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator&=(const CDat& x) -{ - m_value &= x.m_value; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator^=(const CDat& x) -{ - m_value ^= x.m_value; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator++() -{ - m_value++; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -CDat& CDat::operator--() -{ - m_value--; - return *this; -} - -/*----------------------------------------------------------------------------*/ - -std::ostream& operator<<(std::ostream& stream, CDat cdat) -{ - stream << cdat.m_value; - return stream; -} - -/*----------------------------------------------------------------------------*/ - -std::istream& operator>>(std::istream & stream, CDat& cdat) -{ - stream >> cdat.m_value; - return stream; -} - -/* vim: set et sw=2 ts=2: */ diff --git a/ue3/mycpu/cdat.h b/ue3/mycpu/cdat.h index 8b067f9..dc8a07c 100644 --- a/ue3/mycpu/cdat.h +++ b/ue3/mycpu/cdat.h @@ -1,29 +1,28 @@ /** * @module cdat * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) - * @brief TODO + * @brief Datatype template for mycpu * @date 10.05.2009 */ -#ifndef CDAT_H -#define CDAT_H +#ifndef CDATT_H +#define CDATT_H #include #include /** - * @class CDat + * @class CDatT * - * TODO - * - * On error TODO will be thrown. + * Datatype template for mycpu. */ -class CDat - : boost::operators +template +class CDatT + : boost::operators > { public: /** - * @method CDat + * @method CDatT * @brief Default ctor * @param - * @return - @@ -31,11 +30,11 @@ class CDat * @exception bad_alloc * @conditions none */ - CDat() + CDatT() {} /** - * @method ~CDat + * @method ~CDatT * @brief Default dtor * @param - * @return - @@ -43,177 +42,226 @@ class CDat * @exception none * @conditions none */ - ~CDat() + ~CDatT() {} /** - * @method CDat - * @brief Copy constructor for CDat - * @param other reference to CDat which will be copied + * @method CDatT + * @brief Copy constructor for CDatT + * @param other reference to CDatT which will be copied * @return - * @globalvars none * @exception none * @conditions none */ - CDat(const CDat& other) + CDatT(const CDatT& other) : m_value(other.m_value) {} /** - * @method CDat + * @method CDatT * @brief Copy constructor for int - * @param newval new value for CDat + * @param newval new value for CDatT * @return - * @globalvars none * @exception none * @conditions none */ - CDat(int newval) + CDatT(T newval) : m_value(newval) {} /** * @method value - * @brief returns value of CDat + * @brief returns value of CDatT * @param - - * @return value of CDat + * @return value of CDatT * @globalvars none * @exception none * @conditions none */ - int value() const; + T value() const + { + return m_value; + } /** * @method operator< * @brief implementation of operator < - * @param reference to CDat + * @param reference to CDatT * @return true if cdat is less than object x * @globalvars none * @exception none * @conditions none */ - bool operator<(const CDat& x) const; + bool operator<(const CDatT& x) const + { + return m_value < x.m_value; + } /** * @method operator== * @brief implementation of operator == - * @param reference to CDat + * @param reference to CDatT * @return true if cdat equals object x * @globalvars none * @exception none * @conditions none */ - bool operator==(const CDat& x) const; + bool operator==(const CDatT& x) const + { + return m_value == x.m_value; + } /** * @method operator+= * @brief implementation of operator += - * @param reference to CDat - * @return refecence to CDat + * @param reference to CDatT + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator+=(const CDat& x); + CDatT& operator+=(const CDatT& x) + { + m_value += x.m_value; + return *this; + } /** * @method operator-= * @brief implementation of operator -= - * @param reference to CDat - * @return refecence to CDat + * @param reference to CDatT + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator-=(const CDat& x); + CDatT& operator-=(const CDatT& x) + { + m_value -= x.m_value; + return *this; + } /** * @method operator*= * @brief implementation of operator *= - * @param reference to CDat - * @return refecence to CDat + * @param reference to CDatT + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator*=(const CDat& x); + CDatT& operator*=(const CDatT& x) + { + m_value *= x.m_value; + return *this; + } /** * @method operator/= * @brief implementation of operator /= - * @param reference to CDat - * @return refecence to CDat + * @param reference to CDatT + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator/=(const CDat& x); + CDatT& operator/=(const CDatT& x) + { + m_value /= x.m_value; + return *this; + } /** * @method operator%= * @brief implementation of operator %= - * @param reference to CDat - * @return refecence to CDat + * @param reference to CDatT + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator%=(const CDat& x); + CDatT& operator%=(const CDatT& x) + { + m_value %= x.m_value; + return *this; + } /** * @method operator|= * @brief implementation of operator |= - * @param reference to CDat - * @return refecence to CDat + * @param reference to CDatT + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator|=(const CDat& x); + CDatT& operator|=(const CDatT& x) + { + m_value |= x.m_value; + return *this; + } /** * @method operator&= * @brief implementation of operator &= - * @param reference to CDat - * @return refecence to CDat + * @param reference to CDatT + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator&=(const CDat& x); + CDatT& operator&=(const CDatT& x) + { + m_value &= x.m_value; + return *this; + } /** * @method operator^= * @brief implementation of operator ^= - * @param reference to CDat - * @return refecence to CDat + * @param reference to CDatT + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator^=(const CDat& x); + CDatT& operator^=(const CDatT& x) + { + m_value ^= x.m_value; + return *this; + } /** * @method operator++ * @brief implementation of operator ++ * @param - - * @return refecence to CDat + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator++(); + CDatT& operator++() + { + m_value++; + return *this; + } /** * @method operator-- * @brief implementation of operator -- * @param - - * @return refecence to CDat + * @return refecence to CDatT * @globalvars none * @exception none * @conditions none */ - CDat& operator--(); + CDatT& operator--() + { + m_value--; + return *this; + } /** * @method operator<< @@ -225,7 +273,11 @@ class CDat * @exception none * @conditions none */ - friend std::ostream& operator<<(std::ostream& stream, CDat cdat); + friend std::ostream& operator<<(std::ostream& stream, CDatT cdat) + { + stream << cdat.m_value; + return stream; + } /** * @method operator>> @@ -237,13 +289,21 @@ class CDat * @exception none * @conditions none */ - friend std::istream& operator>>(std::istream & stream, CDat& cdat); + friend std::istream& operator>>(std::istream & stream, CDatT& cdat) + { + stream >> cdat.m_value; + return stream; + } private: /* members */ - int m_value; + T m_value; }; + +/** define CDat */ +typedef CDatT CDat; + #endif /* vim: set et sw=2 ts=2: */ -- cgit v1.2.3