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


kni
Author(s): Neuronics AG (see AUTHORS.txt); ROS wrapper by Martin Günther
autogenerated on Mon Oct 6 2014 10:45:32