Download | Plain Text | No Line Numbers
- /**
- * @module cdat
- * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
- * @brief Datatype template and datatype definition for CCPU and CMem
- * @date 26.05.2009
- */
-
- #ifndef CDAT_H
- #define CDAT_H 1
-
- #include <boost/operators.hpp>
- #include <iostream>
-
- /**
- * @class CDat
- *
- * Datatype template for CCPU and CMem.
- */
- template <class T>
- class CDat
- : public boost::operators<CDat<T> >
- {
- public:
- /**
- * @method CDat
- * @brief Default ctor
- * @param -
- * @return -
- * @globalvars none
- * @exception bad_alloc
- * @pre none
- * @post none
- */
- CDat()
- {}
-
- /**
- * @method ~CDat
- * @brief Default dtor
- * @param -
- * @return -
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- virtual ~CDat()
- {}
-
- /**
- * @method CDat
- * @brief Copy constructor for CDat
- * @param other reference to CDat which will be copied
- * @return -
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat(const CDat& other)
- : m_value(other.m_value)
- {}
-
- /**
- * @method CDat
- * @brief Copy constructor for T
- * @param newval new value for CDat
- * @return -
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat(const T newval)
- : m_value(newval)
- {}
-
- /**
- * @method getValue
- * @brief returns value of CDat
- * @param -
- * @return value of CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- T getValue() const
- {
- return m_value;
- }
-
- /**
- * @method operator T
- * @brief convert to T
- * @param -
- * @return T
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- operator T()
- {
- return m_value;
- }
-
- /**
- * @method operator<
- * @brief implementation of operator <
- * @param x reference to CDat
- * @return true if cdat is less than object x
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- bool operator<(const CDat& x) const
- {
- return m_value < x.m_value;
- }
-
- /**
- * @method operator==
- * @brief implementation of operator ==
- * @param x reference to CDat
- * @return true if cdat equals object x
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- bool operator==(const CDat& x) const
- {
- return m_value == x.m_value;
- }
-
- /**
- * @method operator+=
- * @brief implementation of operator +=
- * @param x reference to CDat
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator+=(const CDat& x)
- {
- m_value += x.m_value;
- return *this;
- }
-
- /**
- * @method operator-=
- * @brief implementation of operator -=
- * @param x reference to CDat
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator-=(const CDat& x)
- {
- m_value -= x.m_value;
- return *this;
- }
-
- /**
- * @method operator*=
- * @brief implementation of operator *=
- * @param x reference to CDat
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator*=(const CDat& x)
- {
- m_value *= x.m_value;
- return *this;
- }
-
- /**
- * @method operator/=
- * @brief implementation of operator /=
- * @param x reference to CDat
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator/=(const CDat& x)
- {
- m_value /= x.m_value;
- return *this;
- }
-
- /**
- * @method operator%=
- * @brief implementation of operator %=
- * @param x reference to CDat
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator%=(const CDat& x)
- {
- m_value %= x.m_value;
- return *this;
- }
-
- /**
- * @method operator|=
- * @brief implementation of operator |=
- * @param x reference to CDat
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator|=(const CDat& x)
- {
- m_value |= x.m_value;
- return *this;
- }
-
- /**
- * @method operator&=
- * @brief implementation of operator &=
- * @param x reference to CDat
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator&=(const CDat& x)
- {
- m_value &= x.m_value;
- return *this;
- }
-
- /**
- * @method operator^=
- * @brief implementation of operator ^=
- * @param x reference to CDat
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator^=(const CDat& x)
- {
- m_value ^= x.m_value;
- return *this;
- }
-
- /**
- * @method operator++
- * @brief implementation of operator ++
- * @param -
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator++()
- {
- m_value++;
- return *this;
- }
-
- /**
- * @method operator--
- * @brief implementation of operator --
- * @param -
- * @return refecence to CDat
- * @globalvars none
- * @exception none
- * @pre none
- * @post none
- */
- CDat& operator--()
- {
- m_value--;
- return *this;
- }
-
- /**
- * @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
- * @pre none
- * @post none
- */
- friend std::ostream& operator<<(std::ostream& stream, CDat cdat)
- {
- stream << cdat.m_value;
- return stream;
- }
-
- /**
- * @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
- * @pre none
- * @post none
- */
- friend std::istream& operator>>(std::istream & stream, CDat& cdat)
- {
- stream >> cdat.m_value;
- return stream;
- }
-
- protected:
- /* members */
- /** internal value of datatype */
- T m_value;
- };
-
- #endif
-
- /* vim: set et sw=2 ts=2: */
-