OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
controlw.h
Go to the documentation of this file.
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 
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)
19  { return ControlWord(cw & i.cw); }
20  void operator*=(ControlWord i) { cw &= i.cw; }
21 
22  // set bits
24  { return ControlWord(cw | i.cw); }
25  void operator+=(ControlWord i) { cw |= i.cw; }
26 
27  // reset bits
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
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; }
45 };
46 
47 
48 #endif
void operator+=(ControlWord i)
Definition: controlw.h:25
ControlWord()
Definition: controlw.h:14
ControlWord operator^(ControlWord i) const
Definition: controlw.h:37
void operator*=(ControlWord i)
Definition: controlw.h:20
bool operator<=(ControlWord i) const
Definition: controlw.h:34
#define FREE_CHECK(Class)
Definition: myexcept.h:316
ControlWord operator+(ControlWord i) const
Definition: controlw.h:23
bool operator>=(ControlWord i) const
Definition: controlw.h:33
ControlWord operator-(ControlWord i) const
Definition: controlw.h:28
ControlWord operator~() const
Definition: controlw.h:39
void operator-=(ControlWord i)
Definition: controlw.h:30
ControlWord operator*(ControlWord i) const
Definition: controlw.h:18
ControlWord(int i)
Definition: controlw.h:15
int operator!() const
Definition: controlw.h:43
int operator+() const
Definition: controlw.h:42