diff options
| author | manuel <manuel@nc8430.lan> | 2009-05-10 19:25:36 +0200 |
|---|---|---|
| committer | manuel <manuel@nc8430.lan> | 2009-05-10 19:25:36 +0200 |
| commit | 6a813b50e4fc3bba829c3a94495d6061ea92bada (patch) | |
| tree | 95bcc378dbf62a60ff558f59b0487ed6c949a047 /ue3/mycpu | |
| parent | a7e42a67aae98ade48f7ba7199ed021ca276f373 (diff) | |
| download | ooprog-6a813b50e4fc3bba829c3a94495d6061ea92bada.tar.gz ooprog-6a813b50e4fc3bba829c3a94495d6061ea92bada.tar.bz2 ooprog-6a813b50e4fc3bba829c3a94495d6061ea92bada.zip | |
fixing .hgignore
adding cdat
Diffstat (limited to 'ue3/mycpu')
| -rw-r--r-- | ue3/mycpu/Makefile | 4 | ||||
| -rw-r--r-- | ue3/mycpu/cdat.cpp | 126 | ||||
| -rw-r--r-- | ue3/mycpu/cdat.h | 249 |
3 files changed, 377 insertions, 2 deletions
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= | |||
| 11 | LIBS= -L/usr/local/lib | 11 | LIBS= -L/usr/local/lib |
| 12 | 12 | ||
| 13 | BIN= mycpu | 13 | BIN= mycpu |
| 14 | OBJS= mycpu.o | 14 | OBJS= mycpu.o cdat.o |
| 15 | HEADERS= | 15 | HEADERS= cdat.h |
| 16 | 16 | ||
| 17 | .SUFFIXES: .cpp .o | 17 | .SUFFIXES: .cpp .o |
| 18 | 18 | ||
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 @@ | |||
| 1 | /** | ||
| 2 | * @module cdat | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief TODO | ||
| 5 | * @date 10.05.2009 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include "cdat.h" | ||
| 9 | |||
| 10 | |||
| 11 | int CDat::value() const | ||
| 12 | { | ||
| 13 | return m_value; | ||
| 14 | } | ||
| 15 | |||
| 16 | /*----------------------------------------------------------------------------*/ | ||
| 17 | |||
| 18 | bool CDat::operator<(const CDat& x) const | ||
| 19 | { | ||
| 20 | return m_value < x.m_value; | ||
| 21 | } | ||
| 22 | |||
| 23 | /*----------------------------------------------------------------------------*/ | ||
| 24 | |||
| 25 | bool CDat::operator==(const CDat& x) const | ||
| 26 | { | ||
| 27 | return m_value == x.m_value; | ||
| 28 | } | ||
| 29 | |||
| 30 | /*----------------------------------------------------------------------------*/ | ||
| 31 | |||
| 32 | CDat& CDat::operator+=(const CDat& x) | ||
| 33 | { | ||
| 34 | m_value += x.m_value; | ||
| 35 | return *this; | ||
| 36 | } | ||
| 37 | |||
| 38 | /*----------------------------------------------------------------------------*/ | ||
| 39 | |||
| 40 | CDat& CDat::operator-=(const CDat& x) | ||
| 41 | { | ||
| 42 | m_value -= x.m_value; | ||
| 43 | return *this; | ||
| 44 | } | ||
| 45 | |||
| 46 | /*----------------------------------------------------------------------------*/ | ||
| 47 | |||
| 48 | CDat& CDat::operator*=(const CDat& x) | ||
| 49 | { | ||
| 50 | m_value *= x.m_value; | ||
| 51 | return *this; | ||
| 52 | } | ||
| 53 | |||
| 54 | /*----------------------------------------------------------------------------*/ | ||
| 55 | |||
| 56 | CDat& CDat::operator/=(const CDat& x) | ||
| 57 | { | ||
| 58 | m_value /= x.m_value; | ||
| 59 | return *this; | ||
| 60 | } | ||
| 61 | |||
| 62 | /*----------------------------------------------------------------------------*/ | ||
| 63 | |||
| 64 | CDat& CDat::operator%=(const CDat& x) | ||
| 65 | { | ||
| 66 | m_value %= x.m_value; | ||
| 67 | return *this; | ||
| 68 | } | ||
| 69 | |||
| 70 | /*----------------------------------------------------------------------------*/ | ||
| 71 | |||
| 72 | CDat& CDat::operator|=(const CDat& x) | ||
| 73 | { | ||
| 74 | m_value |= x.m_value; | ||
| 75 | return *this; | ||
| 76 | } | ||
| 77 | |||
| 78 | /*----------------------------------------------------------------------------*/ | ||
| 79 | |||
| 80 | CDat& CDat::operator&=(const CDat& x) | ||
| 81 | { | ||
| 82 | m_value &= x.m_value; | ||
| 83 | return *this; | ||
| 84 | } | ||
| 85 | |||
| 86 | /*----------------------------------------------------------------------------*/ | ||
| 87 | |||
| 88 | CDat& CDat::operator^=(const CDat& x) | ||
| 89 | { | ||
| 90 | m_value ^= x.m_value; | ||
| 91 | return *this; | ||
| 92 | } | ||
| 93 | |||
| 94 | /*----------------------------------------------------------------------------*/ | ||
| 95 | |||
| 96 | CDat& CDat::operator++() | ||
| 97 | { | ||
| 98 | m_value++; | ||
| 99 | return *this; | ||
| 100 | } | ||
| 101 | |||
| 102 | /*----------------------------------------------------------------------------*/ | ||
| 103 | |||
| 104 | CDat& CDat::operator--() | ||
| 105 | { | ||
| 106 | m_value--; | ||
| 107 | return *this; | ||
| 108 | } | ||
| 109 | |||
| 110 | /*----------------------------------------------------------------------------*/ | ||
| 111 | |||
| 112 | std::ostream& operator<<(std::ostream& stream, CDat cdat) | ||
| 113 | { | ||
| 114 | stream << cdat.m_value; | ||
| 115 | return stream; | ||
| 116 | } | ||
| 117 | |||
| 118 | /*----------------------------------------------------------------------------*/ | ||
| 119 | |||
| 120 | std::istream& operator>>(std::istream & stream, CDat& cdat) | ||
| 121 | { | ||
| 122 | stream >> cdat.m_value; | ||
| 123 | return stream; | ||
| 124 | } | ||
| 125 | |||
| 126 | /* 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 @@ | |||
| 1 | /** | ||
| 2 | * @module cdat | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief TODO | ||
| 5 | * @date 10.05.2009 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef CDAT_H | ||
| 9 | #define CDAT_H | ||
| 10 | |||
| 11 | #include <boost/operators.hpp> | ||
| 12 | #include <iostream> | ||
| 13 | |||
| 14 | /** | ||
| 15 | * @class CDat | ||
| 16 | * | ||
| 17 | * TODO | ||
| 18 | * | ||
| 19 | * On error TODO will be thrown. | ||
| 20 | */ | ||
| 21 | class CDat | ||
| 22 | : boost::operators<CDat> | ||
| 23 | { | ||
| 24 | public: | ||
| 25 | /** | ||
| 26 | * @method CDat | ||
| 27 | * @brief Default ctor | ||
| 28 | * @param - | ||
| 29 | * @return - | ||
| 30 | * @globalvars none | ||
| 31 | * @exception bad_alloc | ||
| 32 | * @conditions none | ||
| 33 | */ | ||
| 34 | CDat() | ||
| 35 | {} | ||
| 36 | |||
| 37 | /** | ||
| 38 | * @method ~CDat | ||
| 39 | * @brief Default dtor | ||
| 40 | * @param - | ||
| 41 | * @return - | ||
| 42 | * @globalvars none | ||
| 43 | * @exception none | ||
| 44 | * @conditions none | ||
| 45 | */ | ||
| 46 | ~CDat() | ||
| 47 | {} | ||
| 48 | |||
| 49 | /** | ||
| 50 | * @method CDat | ||
| 51 | * @brief Copy constructor for CDat | ||
| 52 | * @param other reference to CDat which will be copied | ||
| 53 | * @return - | ||
| 54 | * @globalvars none | ||
| 55 | * @exception none | ||
| 56 | * @conditions none | ||
| 57 | */ | ||
| 58 | CDat(const CDat& other) | ||
| 59 | : m_value(other.m_value) | ||
| 60 | {} | ||
| 61 | |||
| 62 | /** | ||
| 63 | * @method CDat | ||
| 64 | * @brief Copy constructor for int | ||
| 65 | * @param newval new value for CDat | ||
| 66 | * @return - | ||
| 67 | * @globalvars none | ||
| 68 | * @exception none | ||
| 69 | * @conditions none | ||
| 70 | */ | ||
| 71 | CDat(int newval) | ||
| 72 | : m_value(newval) | ||
| 73 | {} | ||
| 74 | |||
| 75 | /** | ||
| 76 | * @method value | ||
| 77 | * @brief returns value of CDat | ||
| 78 | * @param - | ||
| 79 | * @return value of CDat | ||
| 80 | * @globalvars none | ||
| 81 | * @exception none | ||
| 82 | * @conditions none | ||
| 83 | */ | ||
| 84 | int value() const; | ||
| 85 | |||
| 86 | /** | ||
| 87 | * @method operator< | ||
| 88 | * @brief implementation of operator < | ||
| 89 | * @param reference to CDat | ||
| 90 | * @return true if cdat is less than object x | ||
| 91 | * @globalvars none | ||
| 92 | * @exception none | ||
| 93 | * @conditions none | ||
| 94 | */ | ||
| 95 | bool operator<(const CDat& x) const; | ||
| 96 | |||
| 97 | /** | ||
| 98 | * @method operator== | ||
| 99 | * @brief implementation of operator == | ||
| 100 | * @param reference to CDat | ||
| 101 | * @return true if cdat equals object x | ||
| 102 | * @globalvars none | ||
| 103 | * @exception none | ||
| 104 | * @conditions none | ||
| 105 | */ | ||
| 106 | bool operator==(const CDat& x) const; | ||
| 107 | |||
| 108 | /** | ||
| 109 | * @method operator+= | ||
| 110 | * @brief implementation of operator += | ||
| 111 | * @param reference to CDat | ||
| 112 | * @return refecence to CDat | ||
| 113 | * @globalvars none | ||
| 114 | * @exception none | ||
| 115 | * @conditions none | ||
| 116 | */ | ||
| 117 | CDat& operator+=(const CDat& x); | ||
| 118 | |||
| 119 | /** | ||
| 120 | * @method operator-= | ||
| 121 | * @brief implementation of operator -= | ||
| 122 | * @param reference to CDat | ||
| 123 | * @return refecence to CDat | ||
| 124 | * @globalvars none | ||
| 125 | * @exception none | ||
| 126 | * @conditions none | ||
| 127 | */ | ||
| 128 | CDat& operator-=(const CDat& x); | ||
| 129 | |||
| 130 | /** | ||
| 131 | * @method operator*= | ||
| 132 | * @brief implementation of operator *= | ||
| 133 | * @param reference to CDat | ||
| 134 | * @return refecence to CDat | ||
| 135 | * @globalvars none | ||
| 136 | * @exception none | ||
| 137 | * @conditions none | ||
| 138 | */ | ||
| 139 | CDat& operator*=(const CDat& x); | ||
| 140 | |||
| 141 | /** | ||
| 142 | * @method operator/= | ||
| 143 | * @brief implementation of operator /= | ||
| 144 | * @param reference to CDat | ||
| 145 | * @return refecence to CDat | ||
| 146 | * @globalvars none | ||
| 147 | * @exception none | ||
| 148 | * @conditions none | ||
| 149 | */ | ||
| 150 | CDat& operator/=(const CDat& x); | ||
| 151 | |||
| 152 | /** | ||
| 153 | * @method operator%= | ||
| 154 | * @brief implementation of operator %= | ||
| 155 | * @param reference to CDat | ||
| 156 | * @return refecence to CDat | ||
| 157 | * @globalvars none | ||
| 158 | * @exception none | ||
| 159 | * @conditions none | ||
| 160 | */ | ||
| 161 | CDat& operator%=(const CDat& x); | ||
| 162 | |||
| 163 | /** | ||
| 164 | * @method operator|= | ||
| 165 | * @brief implementation of operator |= | ||
| 166 | * @param reference to CDat | ||
| 167 | * @return refecence to CDat | ||
| 168 | * @globalvars none | ||
| 169 | * @exception none | ||
| 170 | * @conditions none | ||
| 171 | */ | ||
| 172 | CDat& operator|=(const CDat& x); | ||
| 173 | |||
| 174 | /** | ||
| 175 | * @method operator&= | ||
| 176 | * @brief implementation of operator &= | ||
| 177 | * @param reference to CDat | ||
| 178 | * @return refecence to CDat | ||
| 179 | * @globalvars none | ||
| 180 | * @exception none | ||
| 181 | * @conditions none | ||
| 182 | */ | ||
| 183 | CDat& operator&=(const CDat& x); | ||
| 184 | |||
| 185 | /** | ||
| 186 | * @method operator^= | ||
| 187 | * @brief implementation of operator ^= | ||
| 188 | * @param reference to CDat | ||
| 189 | * @return refecence to CDat | ||
| 190 | * @globalvars none | ||
| 191 | * @exception none | ||
| 192 | * @conditions none | ||
| 193 | */ | ||
| 194 | CDat& operator^=(const CDat& x); | ||
| 195 | |||
| 196 | /** | ||
| 197 | * @method operator++ | ||
| 198 | * @brief implementation of operator ++ | ||
| 199 | * @param - | ||
| 200 | * @return refecence to CDat | ||
| 201 | * @globalvars none | ||
| 202 | * @exception none | ||
| 203 | * @conditions none | ||
| 204 | */ | ||
| 205 | CDat& operator++(); | ||
| 206 | |||
| 207 | /** | ||
| 208 | * @method operator-- | ||
| 209 | * @brief implementation of operator -- | ||
| 210 | * @param - | ||
| 211 | * @return refecence to CDat | ||
| 212 | * @globalvars none | ||
| 213 | * @exception none | ||
| 214 | * @conditions none | ||
| 215 | */ | ||
| 216 | CDat& operator--(); | ||
| 217 | |||
| 218 | /** | ||
| 219 | * @method operator<< | ||
| 220 | * @brief Shift/output operator for outputstream | ||
| 221 | * @param stream reference to outputstream | ||
| 222 | * @param cdat object which will be printed to stream | ||
| 223 | * @return reference to outputstream | ||
| 224 | * @globalvars none | ||
| 225 | * @exception none | ||
| 226 | * @conditions none | ||
| 227 | */ | ||
| 228 | friend std::ostream& operator<<(std::ostream& stream, CDat cdat); | ||
| 229 | |||
| 230 | /** | ||
| 231 | * @method operator>> | ||
| 232 | * @brief Shift/read operator for inputstream | ||
| 233 | * @param stream reference to inputstream | ||
| 234 | * @param cdat reference to object which will be read from stream | ||
| 235 | * @return reference to inputstream | ||
| 236 | * @globalvars none | ||
| 237 | * @exception none | ||
| 238 | * @conditions none | ||
| 239 | */ | ||
| 240 | friend std::istream& operator>>(std::istream & stream, CDat& cdat); | ||
| 241 | |||
| 242 | private: | ||
| 243 | /* members */ | ||
| 244 | int m_value; | ||
| 245 | }; | ||
| 246 | |||
| 247 | #endif | ||
| 248 | |||
| 249 | /* vim: set et sw=2 ts=2: */ | ||
