Last change
on this file since 4574 was
4565,
checked in by patrick, 19 years ago
|
orxonox/trunk: added the newmat library to the project. needs some translation in directory, temp under util/newmat. is needed by the collision detection engine to perform lin alg operations such as eigenvector decomposition. perhaps we will make our own library to do that later.
|
File size:
1.5 KB
|
Line | |
---|
1 | //$$ controlw.h Control word class |
---|
2 | |
---|
3 | #ifndef CONTROL_WORD_LIB |
---|
4 | #define CONTROL_WORD_LIB 0 |
---|
5 | |
---|
6 | // for organising an int as a series of bits which indicate whether an |
---|
7 | // option is on or off. |
---|
8 | |
---|
9 | class ControlWord |
---|
10 | { |
---|
11 | protected: |
---|
12 | int cw; // the control word |
---|
13 | public: |
---|
14 | ControlWord() : cw(0) {} // do nothing |
---|
15 | ControlWord(int i) : cw(i) {} // load an integer |
---|
16 | |
---|
17 | // select specific bits (for testing at least one set) |
---|
18 | ControlWord operator*(ControlWord i) const |
---|
19 | { return ControlWord(cw & i.cw); } |
---|
20 | void operator*=(ControlWord i) { cw &= i.cw; } |
---|
21 | |
---|
22 | // set bits |
---|
23 | ControlWord operator+(ControlWord i) const |
---|
24 | { return ControlWord(cw | i.cw); } |
---|
25 | void operator+=(ControlWord i) { cw |= i.cw; } |
---|
26 | |
---|
27 | // reset bits |
---|
28 | ControlWord operator-(ControlWord i) const |
---|
29 | { return ControlWord(cw - (cw & i.cw)); } |
---|
30 | void operator-=(ControlWord i) { cw -= (cw & i.cw); } |
---|
31 | |
---|
32 | // check if all of selected bits set or reset |
---|
33 | bool operator>=(ControlWord i) const { return (cw & i.cw) == i.cw; } |
---|
34 | bool operator<=(ControlWord i) const { return (cw & i.cw) == cw; } |
---|
35 | |
---|
36 | // flip selected bits |
---|
37 | ControlWord operator^(ControlWord i) const |
---|
38 | { return ControlWord(cw ^ i.cw); } |
---|
39 | ControlWord operator~() const { return ControlWord(~cw); } |
---|
40 | |
---|
41 | // convert to integer |
---|
42 | int operator+() const { return cw; } |
---|
43 | int operator!() const { return cw==0; } |
---|
44 | FREE_CHECK(ControlWord) |
---|
45 | }; |
---|
46 | |
---|
47 | |
---|
48 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.