From 6a813b50e4fc3bba829c3a94495d6061ea92bada Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 10 May 2009 19:25:36 +0200 Subject: fixing .hgignore adding cdat --- ue3/mycpu/Makefile | 4 +- ue3/mycpu/cdat.cpp | 126 +++++++++++++++++++++++++++ ue3/mycpu/cdat.h | 249 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 377 insertions(+), 2 deletions(-) create mode 100644 ue3/mycpu/cdat.cpp create mode 100644 ue3/mycpu/cdat.h (limited to 'ue3/mycpu') diff --git a/ue3/mycpu/Makefile b/ue3/mycpu/Makefile index 0048447..6f57741 100644 --- a/ue3/mycpu/Makefile +++ b/ue3/mycpu/Makefile @@ -11,8 +11,8 @@ LDFLAGS= LIBS= -L/usr/local/lib BIN= mycpu -OBJS= mycpu.o -HEADERS= +OBJS= mycpu.o cdat.o +HEADERS= cdat.h .SUFFIXES: .cpp .o diff --git a/ue3/mycpu/cdat.cpp b/ue3/mycpu/cdat.cpp new file mode 100644 index 0000000..455d3bc --- /dev/null +++ b/ue3/mycpu/cdat.cpp @@ -0,0 +1,126 @@ +/** + * @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 new file mode 100644 index 0000000..8b067f9 --- /dev/null +++ b/ue3/mycpu/cdat.h @@ -0,0 +1,249 @@ +/** + * @module cdat + * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) + * @brief TODO + * @date 10.05.2009 + */ + +#ifndef CDAT_H +#define CDAT_H + +#include +#include + +/** + * @class CDat + * + * TODO + * + * On error TODO will be thrown. + */ +class CDat + : boost::operators +{ + public: + /** + * @method CDat + * @brief Default ctor + * @param - + * @return - + * @globalvars none + * @exception bad_alloc + * @conditions none + */ + CDat() + {} + + /** + * @method ~CDat + * @brief Default dtor + * @param - + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + ~CDat() + {} + + /** + * @method CDat + * @brief Copy constructor for CDat + * @param other reference to CDat which will be copied + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + CDat(const CDat& other) + : m_value(other.m_value) + {} + + /** + * @method CDat + * @brief Copy constructor for int + * @param newval new value for CDat + * @return - + * @globalvars none + * @exception none + * @conditions none + */ + CDat(int newval) + : m_value(newval) + {} + + /** + * @method value + * @brief returns value of CDat + * @param - + * @return value of CDat + * @globalvars none + * @exception none + * @conditions none + */ + int value() const; + + /** + * @method operator< + * @brief implementation of operator < + * @param reference to CDat + * @return true if cdat is less than object x + * @globalvars none + * @exception none + * @conditions none + */ + bool operator<(const CDat& x) const; + + /** + * @method operator== + * @brief implementation of operator == + * @param reference to CDat + * @return true if cdat equals object x + * @globalvars none + * @exception none + * @conditions none + */ + bool operator==(const CDat& x) const; + + /** + * @method operator+= + * @brief implementation of operator += + * @param reference to CDat + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator+=(const CDat& x); + + /** + * @method operator-= + * @brief implementation of operator -= + * @param reference to CDat + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator-=(const CDat& x); + + /** + * @method operator*= + * @brief implementation of operator *= + * @param reference to CDat + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator*=(const CDat& x); + + /** + * @method operator/= + * @brief implementation of operator /= + * @param reference to CDat + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator/=(const CDat& x); + + /** + * @method operator%= + * @brief implementation of operator %= + * @param reference to CDat + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator%=(const CDat& x); + + /** + * @method operator|= + * @brief implementation of operator |= + * @param reference to CDat + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator|=(const CDat& x); + + /** + * @method operator&= + * @brief implementation of operator &= + * @param reference to CDat + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator&=(const CDat& x); + + /** + * @method operator^= + * @brief implementation of operator ^= + * @param reference to CDat + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator^=(const CDat& x); + + /** + * @method operator++ + * @brief implementation of operator ++ + * @param - + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator++(); + + /** + * @method operator-- + * @brief implementation of operator -- + * @param - + * @return refecence to CDat + * @globalvars none + * @exception none + * @conditions none + */ + CDat& operator--(); + + /** + * @method operator<< + * @brief Shift/output operator for outputstream + * @param stream reference to outputstream + * @param cdat object which will be printed to stream + * @return reference to outputstream + * @globalvars none + * @exception none + * @conditions none + */ + friend std::ostream& operator<<(std::ostream& stream, CDat cdat); + + /** + * @method operator>> + * @brief Shift/read operator for inputstream + * @param stream reference to inputstream + * @param cdat reference to object which will be read from stream + * @return reference to inputstream + * @globalvars none + * @exception none + * @conditions none + */ + friend std::istream& operator>>(std::istream & stream, CDat& cdat); + + private: + /* members */ + int m_value; +}; + +#endif + +/* vim: set et sw=2 ts=2: */ -- cgit v1.2.3