Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

CONTROLW.H Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

CONTROLW.H

Go to the documentation of this file.
00001 //Owner: Fred
00002 //$$ controlw.h                Control word class
00003 
00004 #ifndef CONTROL_WORD_LIB
00005 #define CONTROL_WORD_LIB 0
00006 
00007 // for organising an int as a series of bits which indicate whether an
00008 // option is on or off.
00009 
00012 class ControlWord {
00013 protected:
00014     int cw;                                       // the control word
00015 public:
00016     ControlWord() : cw(0) {                       // do nothing
00017     }
00018     ControlWord(int i) : cw(i) {                  // load an integer
00019     }
00020 
00021     // select specific bits (for testing at least one set)
00022     ControlWord operator*(ControlWord i) const
00023         { return ControlWord(cw & i.cw); }
00024     void operator*=(ControlWord i)  { cw &= i.cw; }
00025 
00026     // set bits
00027     ControlWord operator+(ControlWord i) const
00028         { return ControlWord(cw | i.cw); }
00029     void operator+=(ControlWord i)  { cw |= i.cw; }
00030 
00031     // reset bits
00032     ControlWord operator-(ControlWord i) const
00033         { return ControlWord(cw - (cw & i.cw)); }
00034     void operator-=(ControlWord i) { cw -= (cw & i.cw); }
00035 
00036     // check if all of selected bits set or reset
00037     bool operator>=(ControlWord i) const { return (cw & i.cw) == i.cw; }
00038     bool operator<=(ControlWord i) const { return (cw & i.cw) == cw; }
00039 
00040     // flip selected bits
00041     ControlWord operator^(ControlWord i) const
00042         { return ControlWord(cw ^ i.cw); }
00043     ControlWord operator~() const { return ControlWord(~cw); }
00044 
00045     // convert to integer
00046     int operator+() const { return cw; }
00047     int operator!() const { return cw==0; }
00048     FREE_CHECK(ControlWord)
00049         };
00050 #endif

Generated on Fri Aug 23 01:37:01 2002 for VirtualU by doxygen1.2.17